Skip to main content
After you read this page, you can call each route of the Anafi API with the correct host, headers and value formats. You also know which calls are safe to repeat. The public TypeScript SDK @anafi-cc/anafi-sdk calls these routes for you. It also builds the sealed payloads and checks the replies. Use the routes directly when you do not use the SDK, or when you want to know what the SDK sends. See SDK overview.

Base URLs

Each network has its own host. A host serves only its own network. A request about an account on another network gets an answer about the same address on the network of the host. The bank payout routes (tag “Bank payouts”) are served only on polygon-amoy. On polygon and xlayer they answer 404. All other routes are served on all three networks. See Networks.

Authentication

No API key is necessary today. No route reads a cookie or a header for authority. Some routes need a proof from the owner instead: All read routes answer anyone, about any account. Do not put private data in a route that you read for an account.

Limits of today

Call the API from a server, from a script, or through your own same-origin proxy if your page is not on https://app.ana.fi. The Anafi API hosts answer CORS (Access-Control-Allow-Origin) only for https://app.ana.fi today. A browser page on another origin cannot call the API directly. Chain reads and owner-sent transactions do not go through the API, so this limit does not apply to them.
Do not plan an integration on another domain that uses recover or the notification-email code request. These two sign-in (EIP-4361) flows are accepted only when the sign-in message names the domain of the Anafi dapp, app.ana.fi. A sign-in for another domain is refused with 422. An integration on another domain cannot complete these two flows today.
For the origin https://app.ana.fi, a CORS preflight allows the methods GET and POST and the request header Content-Type.

Requests and responses

  • Send a request body as JSON, with the header Content-Type: application/json. Without this header, the route answers 415.
  • A success body is JSON, except GET /api/dsl/docs, which is text/markdown; charset=utf-8.
  • An error body is plain text or JSON, as each route defines. See Errors.
  • POST /api/dsl/generate and the bank payout routes accept a body of at most 2 MB. All other POST routes accept at most 512 KiB. A larger body gets 413.
  • An unknown path answers 404 with an empty body.

Value formats

Small counts are JSON integers: bps, floorUsdCents, dslVersion, maxSendBatchRecipients, seconds.

Field names and enum values

  • Most JSON bodies use camelCase keys, for example accountKind, txHash, amountRaw.
  • These bodies use snake_case keys: the sealed envelope (kem_pk, ct), the sealed reply (nonce, ct), the staging refusal (error, sealed_error), the build object of GET /health, and all plaintext payloads inside a seal. See Sealed requests.
  • Enum values are lowercase snake_case strings, for example safe_module, in_progress, every_source_consulted. One exception: the token symbols keep their letter case.
  • A union is an object with a tag key. The tag key is kind for the outcomes of provisioning, receipts and email codes. It is state for the off-ramp handler and policy.
  • null and absent are different. A field that the reference marks as nullable is always present. A field that the reference marks as optional can be absent, for example gasCharge on an activity row and gas in the fee terms.

Retries and idempotency

A sign-in for recover and the email code request is valid for 5 minutes after its Issued At. An Issued At more than 60 seconds in the future is refused.

Caching

Only GET /api/dsl/docs sets a cache header: Cache-Control: public, max-age=3600. Do not cache the other responses. Fee terms, sponsorship and activity can change at each block.

All operations

Errors

Error bodies, status codes and SDK error classes.

Sealed requests

How to seal a request to the engine and open its reply.

Flows

The order of API calls, signatures and transactions.

SDK errors

The error classes of the SDK.