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

# Send leftover card funds to an external crypto wallet

> Unloads the card budget into the applicant spend account (if needed), converts USD to the requested stablecoin, and sends it on-chain to `address`. Idempotency-Key is required (72h). Emits card.withdrawn / card.withdraw_failed. Poll GET /v1/cards/{id}/withdrawals/{withdrawal_id} if the POST times out (409 includes withdrawal_id while in flight).



## OpenAPI

````yaml /openapi.json post /v1/cards/{id}/withdraw-to-wallet
openapi: 3.1.0
info:
  title: Apocor Core API
  version: 1.0.0
  description: >-
    The Apocor Cards API is the integration surface for issuing and managing
    cards. Authenticate with your Apocor API key, onboard applicants, run KYC,
    and issue virtual or physical cards — all through one white-labeled API.
  contact:
    name: Apocor Support
    url: https://apocor.ai
servers:
  - url: https://sandbox.apocor.ai
    description: Sandbox (live)
  - url: https://api.apocor.ai
    description: Production
  - url: http://localhost:4000
    description: Local development
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Exchange Apocor API keys for a short-lived access token.
  - name: Applicants
    description: End-users and businesses, plus their identity verification (KYC).
  - name: KYC
    description: >-
      Identity verification settings, hosted sessions, BYOK share tokens, direct
      document upload, and issuer readiness.
    x-group: Identity verification (KYC)
  - name: Accounts
    description: Funding accounts that back issued cards.
  - name: Programs
    description: Card programs that define product type, currency, and BIN.
  - name: Cardholders
    description: Approved applicants turned into cardholders.
  - name: Cards
    description: Issue and manage virtual and physical cards.
  - name: Transactions
    description: Card transaction history from the issuer or local ledger.
  - name: Widget SDK
    description: >-
      Public Apocor-branded proxy for Method 1 Widget.js (no auth). PAN/CVV
      still render in issuer PCI iframes.
  - name: Card funding
    description: >-
      Fund prepaid cards with stablecoins: Apocor wallet service or
      bring-your-own (BYO) external wallet.
    x-group: Card funding
paths:
  /v1/cards/{id}/withdraw-to-wallet:
    post:
      tags:
        - Card funding
        - Cards
      summary: Send leftover card funds to an external crypto wallet
      description: >-
        Unloads the card budget into the applicant spend account (if needed),
        converts USD to the requested stablecoin, and sends it on-chain to
        `address`. Idempotency-Key is required (72h). Emits card.withdrawn /
        card.withdraw_failed. Poll GET
        /v1/cards/{id}/withdrawals/{withdrawal_id} if the POST times out (409
        includes withdrawal_id while in flight).
      operationId: createCardsByIdWithdrawToWallet
      parameters:
        - $ref: '#/components/parameters/IdPath'
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            maxLength: 255
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - address
                - amount
              properties:
                address:
                  type: string
                amount:
                  type: string
                  example: '25.00'
                chain:
                  type: string
                  example: BASE
                currency:
                  type: string
                  enum:
                    - USDC
                    - USDT
                program_id:
                  type: string
            example:
              address: '0x1234567890abcdef1234567890abcdef12345678'
              chain: BASE
              currency: USDC
              amount: '25.00'
      responses:
        '200':
          description: Withdrawal submitted or confirmed.
          content:
            application/json:
              example:
                data:
                  withdrawal_id: cmtwdxxxxxxxxxxxxxxx
                  card_id: card_abc123
                  applicant_id: app_abc123
                  status: PENDING
                  chain: BASE
                  currency: USDC
                  address: '0x1234567890abcdef1234567890abcdef12345678'
                  requested: '25.00'
                  unloaded_from_card: '25.00'
                  fees:
                    - amount: '0.08'
                      currency: USDC
                  net: '24.92'
                  transaction_hash: null
        '202':
          description: >-
            Withdrawal accepted; on-chain send still pending. Poll the
            withdrawal_id.
        '400':
          $ref: '#/components/responses/BadRequest'
        '402':
          description: Insufficient funds to withdraw.
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: >-
            In-flight Idempotency-Key. error.withdrawal_id is present when the
            operation was accepted.
components:
  parameters:
    IdPath:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: Resource identifier.
  responses:
    BadRequest:
      description: The request was invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: INVALID_REQUEST
              message: Applicant must be approved
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: NOT_FOUND
              message: Not found
  schemas:
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Stable, machine-readable error code.
            message:
              type: string
              description: Human-readable explanation.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Bearer access token obtained from `POST /v1/oauth/token` using your
        Apocor API key.

````