> ## 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.

# Sync a card top-up

> Call after `stripe.confirmPayment()` resolves. Reads the PaymentIntent from Stripe and, when it `succeeded`, credits the wallet — exactly once: a repeat, or a call after our Stripe webhook already credited it, answers `credited: false`. Never charges (it is not Stripe's `/confirm`). `canceled` marks the order `FAILED`. Never reads a body. Owner only.

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



## OpenAPI

````yaml openapi.json POST /v1/billing/payment-intents/{id}/sync
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/{id}/sync:
    post:
      tags:
        - Billing
      summary: Sync a card top-up
      description: >-
        Call after `stripe.confirmPayment()` resolves. Reads the PaymentIntent
        from Stripe and, when it `succeeded`, credits the wallet — exactly once:
        a repeat, or a call after our Stripe webhook already credited it,
        answers `credited: false`. Never charges (it is not Stripe's
        `/confirm`). `canceled` marks the order `FAILED`. Never reads a body.
        Owner only.


        **Requires a tenant-scoped key** — a workspace key, or an account key
        with `x-workspace-id`.
      operationId: post_billing_payment_intents_id_sync
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: The `paymentIntentId` (`pi_…`).
          example: pi_3QabcDEF
        - 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
      responses:
        '200':
          description: Result
          content:
            application/json:
              schema:
                type: object
                properties:
                  paymentIntentId:
                    type: string
                  status:
                    type: string
                    description: Stripe's status.
                  amount:
                    type: number
                  currency:
                    type: string
                  orderId:
                    type:
                      - string
                      - 'null'
                  orderStatus:
                    type: string
                    enum:
                      - COMPLETED
                      - PENDING
                      - FAILED
                      - UNCHANGED
                  credited:
                    type: boolean
                    description: '`true` only on the call that credited the wallet.'
                  balance:
                    type:
                      - number
                      - 'null'
                    description: Wallet balance right after this credit, or `null`.
                  cardSaved:
                    type: boolean
              example:
                paymentIntentId: pi_3QabcDEF
                status: succeeded
                amount: 150
                currency: BRL
                orderId: cmh2b7q4s0003to8example8t
                orderStatus: COMPLETED
                credited: true
                balance: 212.4
                cardSaved: true
        '400':
          description: The id is not a `pi_…`
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: >-
                  The id must be a Stripe PaymentIntent id (pi_…). | O id deve
                  ser o id de um PaymentIntent do Stripe (pi_…).
                code: INVALID_PAYMENT_INTENT_ID
        '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
        '404':
          description: Not a top-up intent of this workspace
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: >-
                  Payment intent not found for this workspace. | Payment intent
                  não encontrado neste workspace.
                code: PAYMENT_INTENT_NOT_FOUND
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.