> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pilotstatus.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Start a card top-up (Stripe Elements)

> Creates a PENDING top-up order and a card PaymentIntent for `amount` (workspace currency, rounded to cents), for a card form on your own page. Call `stripe.confirmPayment()` with `clientSecret`, then `POST /v1/billing/payment-intents/{id}/sync`. The wallet is credited exactly once, by `sync` or by our Stripe webhook. `saveCard: true` also saves the card. Optional `Idempotency-Key`: same key and body within 24 h → the same intent, with `Idempotent-Replayed: true`; same key, other body → `409 IDEMPOTENCY_KEY_REUSED`; still running → `409 IDEMPOTENCY_KEY_IN_USE`. Owner only (`billing:wallet:topup`). Card data goes from the payer's browser straight to Stripe (Payment Element) and never reaches Pilot Status. The `clientSecret` lets whoever holds it confirm the intent: do not cache or log it. Sent with `Cache-Control: no-store`.

**Requires a tenant-scoped key** — a workspace key, or an account key with `x-workspace-id`.

> [!WARNING]
>
> Nothing is charged here: the payment happens when Stripe.js confirms it on your page. See [Transparent checkout](https://docs.pilotstatus.com.br/guides/transparent-checkout.md).


## OpenAPI

````yaml openapi.json POST /v1/billing/payment-intents
openapi: 3.1.0
info:
  title: Pilot Status API
  version: 1.0.0
  license:
    name: Pilot Status Terms of Service
    url: https://pilotstatus.com.br/terms
  description: >-
    Public REST API for Pilot Status. Authenticate with the `x-api-key: ps_...`
    header (or `x-api-key-id`). Base URL: https://pilotstatus.com.br
servers:
  - url: https://pilotstatus.com.br
security:
  - apiKey: []
  - apiKeyId: []
paths:
  /v1/billing/payment-intents:
    post:
      tags:
        - Billing
      summary: Start a card top-up (Stripe Elements)
      description: >-
        Creates a PENDING top-up order and a card PaymentIntent for `amount`
        (workspace currency, rounded to cents), for a card form on your own
        page. Call `stripe.confirmPayment()` with `clientSecret`, then `POST
        /v1/billing/payment-intents/{id}/sync`. The wallet is credited exactly
        once, by `sync` or by our Stripe webhook. `saveCard: true` also saves
        the card. Optional `Idempotency-Key`: same key and body within 24 h →
        the same intent, with `Idempotent-Replayed: true`; same key, other body
        → `409 IDEMPOTENCY_KEY_REUSED`; still running → `409
        IDEMPOTENCY_KEY_IN_USE`. Owner only (`billing:wallet:topup`). Card data
        goes from the payer's browser straight to Stripe (Payment Element) and
        never reaches Pilot Status. The `clientSecret` lets whoever holds it
        confirm the intent: do not cache or log it. Sent with `Cache-Control:
        no-store`.


        **Requires a tenant-scoped key** — a workspace key, or an account key
        with `x-workspace-id`.
      operationId: post_billing_payment_intents
      parameters:
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
            maxLength: 255
          description: Optional. Up to 255 characters, no control characters.
          example: topup-customer-42-2026-10-28
        - name: x-workspace-id
          in: header
          required: false
          schema:
            type: string
          description: >-
            Only with an account key (`ps_account_`): the workspace to act on,
            from `GET /v1/workspaces`. Without it an account key gets `400
            WORKSPACE_ID_REQUIRED`.
          example: cmh2a9z8y0002ws8example1q
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                purpose:
                  type: string
                  enum:
                    - wallet_topup
                  description: Only `wallet_topup` today.
                  example: wallet_topup
                amount:
                  type: number
                  description: Positive, in the workspace's currency.
                  example: 150
                saveCard:
                  type: boolean
                  description: Also save the card as the workspace's card. Default `false`.
                  example: true
              required:
                - purpose
                - amount
      responses:
        '200':
          description: The intent
          content:
            application/json:
              example:
                clientSecret: pi_3QabcDEF_secret_xyz
                paymentIntentId: pi_3QabcDEF
                orderId: cmh2b7q4s0003to8example8t
                amount: 150
                currency: BRL
                publishableKey: pk_live_...
          headers:
            Cache-Control:
              schema:
                type: string
              example: no-store
            Idempotent-Replayed:
              schema:
                type: string
              description: '`true` on a replay.'
              example: 'true'
        '400':
          description: >-
            `INVALID_BODY`, `UNKNOWN_FIELDS`, `INVALID_PURPOSE`,
            `INVALID_AMOUNT`, `INVALID_FIELD_TYPE`, `AMOUNT_TOO_SMALL` or
            `IDEMPOTENCY_KEY_INVALID`
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: >-
                  amount must be a positive number. | amount deve ser um número
                  positivo.
                code: INVALID_AMOUNT
        '401':
          description: Missing, invalid or revoked API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Invalid API key
        '403':
          description: >-
            Number-scoped key (`NUMBER_SCOPE_NOT_ALLOWED`), the user's role does
            not allow it (`PERMISSION_DENIED`), or an account key outside its
            workspaces (`WORKSPACE_MEMBERSHIP_REQUIRED`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: This endpoint requires a tenant-scoped API key
                code: NUMBER_SCOPE_NOT_ALLOWED
        '409':
          description: '`IDEMPOTENCY_KEY_REUSED` or `IDEMPOTENCY_KEY_IN_USE`'
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: >-
                  This Idempotency-Key was already used with different
                  parameters. Use a new key. | Esta Idempotency-Key já foi usada
                  com outros parâmetros. Use uma nova chave.
                code: IDEMPOTENCY_KEY_REUSED
        '503':
          description: Card payments are not available right now
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: >-
                  Card payments are not available right now. | Pagamentos com
                  cartão não estão disponíveis no momento.
                code: PAYMENTS_NOT_CONFIGURED
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Your ps_ API key
    apiKeyId:
      type: apiKey
      in: header
      name: x-api-key-id
      description: API key id (alternative to x-api-key)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.