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

# Billing & Credits

> Fund your platform balance and pay as you go.

Apocor is **pay-as-you-go**. You maintain a platform **credit balance**; per-card issuance fees are debited from it. Top up by sending stablecoin to a deposit address tied to your organization.

## Overview

```bash cURL theme={null}
curl -s 'https://sandbox.apocor.ai/v1/billing' \
  -H 'Authorization: Bearer YOUR_TOKEN'
```

```json theme={null}
{
  "data": {
    "balanceCents": 250000,
    "currency": "USD",
    "wallets": [{ "id": "wal_1", "chain": "base", "address": "0xabc…", "isPrimary": true }],
    "pricing": { "issuanceFeeCents": 200, "enforced": true }
  }
}
```

| Field                      | Meaning                                      |
| -------------------------- | -------------------------------------------- |
| `balanceCents`             | Current credit balance in cents              |
| `pricing.issuanceFeeCents` | Fee charged per card issued                  |
| `pricing.enforced`         | Whether issuance is blocked when underfunded |

## Adding credit

<Steps>
  <Step title="Create a deposit address">
    ```bash cURL theme={null}
    curl -s -X POST 'https://sandbox.apocor.ai/v1/billing/deposit-address' \
      -H 'Authorization: Bearer YOUR_TOKEN' -H 'Content-Type: application/json' \
      -d '{ "amount_cents": 50000 }'
    ```

    Returns a `depositAddress` (render it as a QR) and a `flowId` to track settlement.
  </Step>

  <Step title="Send funds">
    Send the stablecoin amount to the returned address from any wallet.
  </Step>

  <Step title="Poll for settlement">
    ```bash cURL theme={null}
    curl -s 'https://sandbox.apocor.ai/v1/billing/flow/FLOW_ID' \
      -H 'Authorization: Bearer YOUR_TOKEN'
    ```

    Your balance is credited when `status` becomes `COMPLETED`.
  </Step>
</Steps>

## Insufficient credit

When issuance fees are enforced and your balance is too low, `POST /v1/cards` returns `402`:

```json theme={null}
{ "error": { "code": "INSUFFICIENT_CREDIT", "message": "Top up your balance to issue cards" } }
```

Top up and retry — no card is created and no fee is charged when this occurs.
