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

# API overview

> Public programmatic API for SnapIt — upload invoices, check balance, and top up credits.

# API overview

The programmatic API is authenticated with tenant API keys and lives under `/api/v1`.

| Endpoint | Purpose |
| - | - |
| `GET /api/v1/credits/balance` | Credit balance and cost per invoice |
| `GET /api/v1/credits/packages` | List packages available for top-up |
| `POST /api/v1/credits/checkout` | Start Stripe Checkout (returns payment URL) |
| `POST /api/v1/credits/checkout/confirm` | Confirm payment and add credits |
| `POST /api/v1/invoices/upload/init` | Reserve an invoice slot |
| `POST /api/v1/invoices/upload/:invoiceId/file` | Attach file and enqueue extraction |
| `POST /api/v1/invoices/upload` | One-step upload |
| `GET /api/v1/invoices/:id` | Poll processing status and get extracted JSON |

Authenticate every request with:

```bash theme={null}
Authorization: Bearer sk_live_your_key_here
```

Full key lifecycle: [Authentication](/api-reference/authentication).

## Typical integration flow

<Steps>
  <Step title="Check balance">
    `GET /api/v1/credits/balance` — if balance is below `creditCostPerInvoice`, top up first.
  </Step>

  <Step title="Top up (when needed)">
    List packages → start checkout → open the Stripe URL → confirm with `sessionId`.
  </Step>

  <Step title="Upload">
    One-step `POST /api/v1/invoices/upload`, or init + attach for large files.
  </Step>

  <Step title="Poll">
    `GET /api/v1/invoices/:id` until `ready` is `true`, then read `data`.
  </Step>
</Steps>

<Note>
  Upload returns **202 Accepted** immediately. Credits are deducted when the upload is accepted
  (before OCR finishes). If the extraction queue is unavailable, credits are **refunded** and the
  API returns **503**.
</Note>

<Note>
  `statusUrl` in upload responses is a **relative** path (for example `/api/v1/invoices/{id}`).
  Prepend your API host (`https://api.trysnapit.com` in production).
</Note>

You can also buy credits in the app under **Settings → Billing**. Full guide: [Credits and billing](/guides/credits).

Use the interactive playground on each endpoint page below, or the committed OpenAPI file at [`openapi/programmatic.json`](/openapi/programmatic.json).


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