> ## Documentation Index
> Fetch the complete documentation index at: https://paperplane-justin-winter-s-projects.vercel.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Buy a credit pack

> Returns a Stripe-hosted checkout URL (default) or, with `checkout_ui_mode: "embedded"`, a Stripe Embedded Checkout `payment_client_secret` to mount in place. The credit code is emailed once payment settles either way.



## OpenAPI

````yaml /openapi.json post /v1/credits/checkout
openapi: 3.1.0
info:
  title: paperplane API
  version: 1.0.0
  summary: Send real physical mail from code.
  description: >-
    Upload a PDF or paste text; we print it and hand it to USPS the next
    business day. No account required — pay per letter with a Stripe link or a
    prepaid credit code, and use `sandbox: true` to exercise the whole flow for
    free.


    Every failure returns the same envelope: `status`, a stable machine-readable
    `code`, a human `reason`, and a `next` array of concrete recovery steps.


    This document is generated from the same zod schemas the server validates
    with, so it cannot describe an endpoint that does not exist.
  contact:
    name: paperplane support
    url: https://sendpaperplane.com/contact
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
  termsOfService: https://sendpaperplane.com/terms
servers:
  - url: https://sendpaperplane.com
    description: Production
security: []
tags:
  - name: Mail
    description: Quote, send, track, and cancel letters.
  - name: Credits
    description: Prepaid balances that pay for letters without a card.
  - name: Reviews
    description: Post-delivery feedback. Identity is derived from the order, not supplied.
  - name: Addresses
    description: >-
      Typeahead and reverse geocoding. Convenience only; USPS verification is
      authoritative.
  - name: Meta
    description: Machine-readable description of this API.
paths:
  /v1/credits/checkout:
    post:
      tags:
        - Credits
      summary: Buy a credit pack
      description: >-
        Returns a Stripe-hosted checkout URL (default) or, with
        `checkout_ui_mode: "embedded"`, a Stripe Embedded Checkout
        `payment_client_secret` to mount in place. The credit code is emailed
        once payment settles either way.
      operationId: createCreditCheckout
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditCheckoutRequest'
            example:
              pack: value
              email: jordan@example.com
      responses:
        '200':
          description: >-
            Checkout link (`checkout_ui_mode: "hosted"`, the default) or a
            Stripe Embedded Checkout `payment_client_secret` (`checkout_ui_mode:
            "embedded"`) — a discriminated union keyed on `checkout_ui_mode`,
            never both.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditCheckoutResponse'
              example:
                status: ok
                checkout_ui_mode: hosted
                payment_url: https://checkout.stripe.com/c/pay/cs_test_a1b2c3
        '400':
          description: '`unknown_pack` or a malformed email.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: >-
            `no_checkout_url` — Stripe created the session but returned no URL
            to send the payer to.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: >-
            `payments_not_configured` — Stripe is not configured on this
            deployment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CreditCheckoutRequest:
      type: object
      properties:
        pack:
          type: string
        email:
          type: string
          format: email
          pattern: >-
            ^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$
        checkout_ui_mode:
          type: string
          enum:
            - hosted
            - embedded
      required:
        - pack
        - email
    CreditCheckoutResponse:
      type: object
      properties:
        status:
          type: string
          const: ok
        checkout_ui_mode:
          type: string
          enum:
            - hosted
            - embedded
        payment_url:
          type: string
          format: uri
        payment_client_secret:
          type: string
      required:
        - status
        - checkout_ui_mode
      oneOf:
        - $ref: '#/components/schemas/HostedCreditCheckoutResponse'
        - $ref: '#/components/schemas/EmbeddedCreditCheckoutResponse'
    Error:
      type: object
      properties:
        status:
          type: string
          enum:
            - failed
            - action_required
        code:
          type: string
        reason:
          type: string
        next:
          type: array
          items:
            type: string
      required:
        - status
        - code
        - reason
        - next
    HostedCreditCheckoutResponse:
      type: object
      properties:
        status:
          type: string
          const: ok
        checkout_ui_mode:
          type: string
          const: hosted
        payment_url:
          type: string
          format: uri
      required:
        - status
        - checkout_ui_mode
        - payment_url
    EmbeddedCreditCheckoutResponse:
      type: object
      properties:
        status:
          type: string
          const: ok
        checkout_ui_mode:
          type: string
          const: embedded
        payment_client_secret:
          type: string
      required:
        - status
        - checkout_ui_mode
        - payment_client_secret

````