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

# API Reference — Overview

> The two surfaces, auth posture, the error envelope, rate limits, phase gating, and versioning rules for the Skia Agentic Settlement API.

# API Reference — Overview

The generated endpoint pages in this group are built **directly from the spec
of record** — `docs/mvp-spec-v0.4.7.yaml` (OpenAPI 3.1.0). This page is the
narrative companion: what does not fit per-endpoint.

## Two surfaces

| Surface | Paths | Namespace | Role |
| - | - | - | - |
| Settlement primitives | 23 | `/api` | quotes, commit/reveal, wallets, smart accounts, tiering, registry, webhooks |
| Invoice ledger | 8 | `/v1` | the obligation layer's versioned, long-lived contract |

The `/v1` namespace is the one recorded exception to the all-`/api` prefix —
it marks the obligation layer's contract, distinct from the `/api`
settlement primitives its payments resolve into. Auth, rate-limiting, and
gateway posture are shared. The `/api/invoices` app lane serves the desk
console and shares the SAME handlers as `/v1` — one law, two mounts.

## Authentication

* Scheme: `ethSigAuth` — HTTP bearer, `bearerFormat: ethereum-signature`.
* **Testnet posture (disclosed)**: the bearer is simulated — the token is the
  caller's wallet address. Commit/reveal authenticate as the taker
  (`senderWallet`); invoice reads are two-party; invoice writes are role-bound
  (issuer issues and credits; debtor acknowledges, disputes, pays, binds).
* Missing/bad bearer → `401 UNAUTHORIZED`. A bearer that does not own the
  action → `403` (FORBIDDEN, or `INVOICE_PARTY_MISMATCH` on the invoice
  surface).
* Real signature verification is the CONTRACT-4 mainnet gate — disclosed, not
  hidden.

## The error envelope

Every error is one shape:

```json theme={null}
{
  "code": "INVOICE_STATE_INVALID",
  "message": "terminal invoice states take no payment intents",
  "details": { },
  "retryable": false
}
```

The code table is **generated, never hand-invented** (the MCP-2 rule: no code
can be invented by hand — equally, no row left orphan). Today it carries
**77 rows across six groups**: `validation`, `commit-reveal`,
`phase-gating`, `custody-sponsored`, `transport`, and `invoice` (15 rows).
The full table lives in the spec's `info.x-error-codes` block and is served
live by `GET /api/registry`.

## Rate limits

* Responses carry `X-RateLimit-*` headers; exceeded limits answer `429` with
  `Retry-After`.
* The faucet is an anonymous-write surface (relayed on-chain transfers) — it
  has its own cooldown window and is the first thing to armor at the gateway
  (a WAF rate-limit rule on `/api/` is the standing recommendation).
* Commit carries a high burst allowance (1000/60s class); the invoice bind
  endpoint runs a 120/60s per-bearer limiter.

## Idempotency

* `POST /api/commit` and the invoice payment intent accept an
  `Idempotency-Key` header.
* On the invoice surface the key namespace is scoped **per invoice** —
  uniqueness is `(invoiceId, idempotencyKey)`; the same key + different
  payload is `409 INVOICE_IDEMPOTENCY_CONFLICT`; a key on a terminal attempt
  replays the same terminal record and never re-executes.
* Omitting the key on a new intent takes the derived `(invoiceId, attemptSeq)`
  key.

## Phase gating

The phase-gating contract ships in the error table so agents code against it
once. Phase-1 reality: the trigger set is empty everywhere except **one**
place — the `swap-sponsored` payment template answers `501 PHASE_GATED`
(RESERVED Phase 2, behind the public-bundler receipt gate).

## Versioning

* The API version lives in `info.version` (currently **0.4.7**), not in a base
  path — with the `/v1` namespace as the one recorded exception above.
* **Wire rule: additive only** — no renames, no removals, no shape edits on
  existing fields. Every spec change lands in a new versioned file
  (`docs/mvp-spec-v0.4.X.yaml`) with a recorded amendment; corrections are
  in-band, never silent.
* The generated API reference regenerates from the spec file on every merge —
  there is no stale-copy risk by construction.

## Money formats

* Display amounts are decimal strings; settlement fields are exact uint256
  base-unit strings (pure string math — no float loss anywhere).
* On the invoice surface money is **integer atomic-unit arithmetic only** —
  floats never touch it.
* Simulated lanes surface `txHash: null` and honest `settlementMode` labels —
  never link a null or synthetic hash to an explorer.

## Pagination

`GET /v1/receivables` is cursor-paginated (`limit` up to 100, `cursor` = the
last invoiceId). Disclosed caveat: a lexicographic cursor is **not
insertion-monotonic** — an invoice issued mid-scan whose id sorts lower than
the cursor lands on an earlier page and is missed by the continuing scan; a
fresh scan without a cursor always sees it. The stable-scan ordering is a
known service change.

## Where to next

* Generated endpoint pages: pick any path in this group's navigation.
* The concepts behind the wire: [Invoices](https://docs.skia.money/concepts/invoices.md),
  [Settlements](https://docs.skia.money/concepts/settlements.md), [Attestations](https://docs.skia.money/concepts/attestations.md).


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