API
The Agora HTTP API, its conventions, types, errors, every route and the fixture mode.
The API reads the register and builds every transaction the app signs. It speaks JSON over HTTP, with one stream of live settlements over server-sent events. Its address on Mainnet is https://api-production-98ed7929.up.railway.app; the samples call it AGORA_API. The API serves its OpenAPI 3.1 document at GET /openapi.json, generated from the same zod schemas it validates with, and the program's Anchor IDL at GET /idl.json. The schemas also ship in the TypeScript client.
Conventions
- Every u64 is a decimal string, so no amount loses precision in JavaScript; do arithmetic in
BigInt. Units are whole, cash is in atoms with 6 decimals, and prices are cash atoms per unit. - Times are UTC, as ISO 8601 strings.
- Enumerations are open: a field such as a settlement's
kindmay gain values. Treat a value you don't know as valid and show it as it is. - Responses may gain fields. Requests are strict, and an unknown field is a
VALIDATION_ERROR. - No route moves funds by itself. A build route returns an unsigned transaction that the wallet signs, and
POST /v1/transactions/submitsends it: see API: transactions.
Types
| Type | What it is |
|---|---|
Address | A base58 string encoding 32 bytes: a wallet, account or mint. |
Signature | A base58 string encoding a 64-byte transaction signature. |
U64 | An unsigned integer as a decimal string, at most 18446744073709551615. Do arithmetic in BigInt. |
PositiveU64 | A U64 greater than zero. |
BaseUnits | An unsigned integer as a decimal string of up to 78 digits, for totals that can pass the u64 range. |
Base64 | Standard base64. |
Timestamp | An ISO 8601 date and time in UTC. |
Code | An instrument code: 1 to 12 uppercase letters or digits. |
TransactionId | The id a build route returns, 1 to 128 characters. |
Errors
Every failed response, whatever its status, carries one envelope, { "error": { … } }:
| Field | Type | Required | Description |
|---|---|---|---|
error.code | "VALIDATION_ERROR" | "UNAUTHORIZED" | "ORIGIN_NOT_ALLOWED" | "NOT_FOUND" | "PROGRAM_UNAVAILABLE" | "CONFIGURATION_REQUIRED" | "IDEMPOTENCY_CONFLICT" | "TRANSACTION_EXPIRED" | "PAYLOAD_TOO_LARGE" | "UNSUPPORTED_MEDIA_TYPE" | "SIMULATION_FAILED" | "CHAIN_REFUSED" | "RATE_LIMITED" | "INTERNAL_ERROR" | "UPSTREAM_UNAVAILABLE" | yes | A stable code to branch on (see API errors). |
error.message | string | yes | A sentence the app can show. |
error.retryable | boolean | yes | true when the same request can succeed later. |
error.stage | "validation" | "auth" | "read" | "upload" | "build" | "wallet" | "co_sign" | "simulation" | "send" | "confirmation" | yes | validation, auth, read, upload, build, wallet, co_sign, simulation, send or confirmation. |
error.fieldErrors | Record<string, string[]> | no | For VALIDATION_ERROR: messages per request field. |
error.programError | object | no | For a program refusal: which program and error. |
error.programError.programId | Address | yes | The refusing program's address. |
error.programError.name | string | yes | Its error name. |
error.programError.number | integer | no | Its custom error code. |
error.retryAfterSeconds | integer | no | For RATE_LIMITED: seconds to wait. |
error.requestId | string | no | The request's id in the API's logs. |
Branch on error.code. Each code has one HTTP status:
| Code | Status | When |
|---|---|---|
VALIDATION_ERROR | 400 | A path, query or body field failed the contract. fieldErrors names each one. |
UNAUTHORIZED | 401 | A signed request was signed by another key than the wallet it names (POST /v1/admissions). |
ORIGIN_NOT_ALLOWED | 403 | A browser request came from an origin the API doesn't allow. |
NOT_FOUND | 404 | The instrument, account, build or route doesn't exist. |
PROGRAM_UNAVAILABLE | 409 | The program isn't serving the ledger yet. Builds and submissions wait; retry later. |
CONFIGURATION_REQUIRED | 409 | The API lacks a configuration value this request needs. |
IDEMPOTENCY_CONFLICT | 409 | The idempotency key was used with a different build or different details. |
TRANSACTION_EXPIRED | 409 | The build's blockhash expired before it landed. Build again. |
PAYLOAD_TOO_LARGE | 413 | The body is larger than the API accepts. |
UNSUPPORTED_MEDIA_TYPE | 415 | The body isn't application/json. |
SIMULATION_FAILED | 422 | The transaction failed simulation. programError names the program error. |
CHAIN_REFUSED | 422 | The ledger refuses the action as asked. programError names the reason. |
RATE_LIMITED | 429 | Too many requests. Wait retryAfterSeconds. |
INTERNAL_ERROR | 500 | The API failed. requestId identifies the request. |
UPSTREAM_UNAVAILABLE | 502 | The RPC node or database didn't answer. Retry. |
A program refusal names the program error from Errors in programError.name.
Routes
| Method | Path | Client method | What it does |
|---|---|---|---|
GET | /idl.json | idl | Agora program interface |
GET | /health | health | Service readiness |
GET | /v1/config | config | Ledger configuration |
GET | /v1/accounts/{wallet} | account | Account balances, admission and activity |
GET | /v1/instruments | instruments | All instruments |
GET | /v1/instruments/{code} | instrument | Instrument terms and market statistics |
GET | /v1/instruments/{code}/book | book | Open bids and asks |
GET | /v1/instruments/{code}/register | register | Units registered to each owner |
GET | /v1/instruments/{code}/income | income | Distributions paid by the issuer |
GET | /v1/instruments/{code}/candles | candles | OHLC candles folded from fills |
GET | /v1/repo-offers | repoOffers | Open repo offers |
GET | /v1/repos | repos | Repos as borrower or lender |
GET | /v1/issuers/{wallet}/instruments | issuerInstruments | Instruments listed by an issuer |
GET | /v1/settlements | settlements | Page of settlements, newest first |
GET | /v1/transactions/{id} | txStatus | Transaction status |
GET | /v1/events | eventsUrl | Live settlements and resync notices |
POST | /v1/admissions | requestAdmission | Request operator approval |
POST | /v1/faucet | faucet | Get test USD and SOL on localnet |
POST | /v1/transactions/submit | submit | Submit a wallet-signed transaction or signature |
POST | /v1/build/admit | buildAdmit | Build admit |
POST | /v1/build/deposit | buildDeposit | Build deposit |
POST | /v1/build/withdraw | buildWithdraw | Build withdraw |
POST | /v1/build/list-instrument | buildListInstrument | Build list instrument |
POST | /v1/build/issue | buildIssue | Build issue |
POST | /v1/build/post-offer | buildPostOffer | Build post offer |
POST | /v1/build/cancel-offer | buildCancelOffer | Build cancel offer |
POST | /v1/build/take-offer | buildTakeOffer | Build take offer |
POST | /v1/build/post-repo-offer | buildPostRepoOffer | Build post repo offer |
POST | /v1/build/cancel-repo-offer | buildCancelRepoOffer | Build cancel repo offer |
POST | /v1/build/take-repo | buildTakeRepo | Build take repo |
POST | /v1/build/repay | buildRepay | Build repay |
POST | /v1/build/settle-default | buildSettleDefault | Build settle default |
POST | /v1/build/pay-income | buildPayIncome | Build pay income |
POST | /v1/build/claim-income | buildClaimIncome | Build claim income |
Reads are in API: reading the ledger; builds, submission, status, admission requests and the faucet in API: transactions.
Fixtures
Every route is also served under /fixture, against fixture data instead of the chain, with the same schemas. A client built against the fixtures works unchanged against the ledger. Choose a scenario with the X-Fixture header or the fixture query parameter (the header wins), and keep one fixture session per tab with X-Fixture-Session, so admission and submitted transactions persist within it. Naming an error code as the scenario returns that error with its status.
| Scenario | What it serves |
|---|---|
lively | Five instruments with two-sided books, registers, income, candles, repos and settlement history. |
empty | An empty ledger. |
admission-none | The wallet has never asked for admission. |
admission-pending | The wallet's request waits for the operator. |
admitted-holder | The wallet is an admitted holder. |
admitted-issuer | The wallet is an admitted issuer. |
admission-rejected | The operator rejected the wallet's request, with a reason. |
account-empty | Admitted, holding nothing. |
account-full | Admitted, with balances, offers, repos and activity. |
waiting | The program waits for deployment. Builds answer PROGRAM_UNAVAILABLE. |
tx-settles | Submitted transactions confirm after a few status reads. |
tx-fails | Submitted transactions fail with a named program error. |
In fixture mode a build's transactionBase64 encodes a label, not a real transaction: relay it back unchanged to simulate a submission.