Errors
Every error the API and the Ayo program raise, with what causes it.
The error envelope
Every failed API request answers with one JSON object under error. Branch on code; show message.
| Field | Type | What it is |
|---|---|---|
code | string | A stable error code; branch on it |
message | string | A sentence that can be shown to a person |
retryable | boolean | Whether the same request can succeed later |
stage | string | The step of the flow that failed |
fieldErrors | object, optional | For VALIDATION_ERROR: each invalid field with its problems |
programError | object, optional | For a refused transaction: the program address, error name and number |
retryAfterSeconds | integer, optional | For RATE_LIMITED: seconds to wait |
requestId | string, optional | An ID for this request, for logs |
API error codes
| Code | HTTP | Raised when |
|---|---|---|
VALIDATION_ERROR | 400 | A field is missing or malformed. fieldErrors names each one. |
UNAUTHORIZED | 401 | The request needs credentials it didn't carry. |
ORIGIN_NOT_ALLOWED | 403 | The browser origin isn't on the API's allow list. |
NOT_FOUND | 404 | No agent, service, tab, receipt or build with that ID. |
PROGRAM_UNAVAILABLE | 409 | Ayo's program isn't deployed on the cluster the API reads. |
CONFIGURATION_REQUIRED | 409 | The program's Config account hasn't been initialized. |
IDEMPOTENCY_CONFLICT | 409 | The idempotency key was already used with a different body. |
TRANSACTION_EXPIRED | 409 | The blockhash expired before the transaction landed. Build it again. |
PAYLOAD_TOO_LARGE | 413 | The body is larger than the API accepts. |
UNSUPPORTED_MEDIA_TYPE | 415 | The body isn't JSON. |
SIMULATION_FAILED | 422 | The transaction failed simulation. programError names the program and its error. |
CHAIN_REFUSED | 422 | The cluster rejected the transaction. |
RATE_LIMITED | 429 | Too many requests. Wait retryAfterSeconds. |
INTERNAL_ERROR | 500 | The API failed. Retrying may help. |
UPSTREAM_UNAVAILABLE | 502 | The RPC or the Ring indexer behind the API didn't answer. |
WALLET_REJECTED | 409 | The wallet declined to sign. |
WALLET_CHANGED | 422 | The wallet changed the transaction in a way the API can't accept. |
RPC_UNAVAILABLE | 503 | The RPC node didn't answer. Retry. |
AGENT_PAUSED | 409 | The agent is paused. Its owner can resume it. |
TAB_NOT_OPEN | 409 | The tab isn't open, so it can't take this action. |
NOT_OWNER | 403 | The signer doesn't own this agent or service. |
WINDOW_NOT_ELAPSED | 409 | The settlement window hasn't passed, so the tab can't be flagged yet. |
INVALID_VOUCHER | 422 | The voucher doesn't verify for this tab and agent. |
Stages
stage names the step of the flow that failed.
| Stage | Failed while |
|---|---|
validation | The request was checked |
auth | Credentials were checked |
read | Data was read |
upload | A file was uploaded |
build | The transaction was built |
wallet | The wallet signed |
co_sign | The API co-signed |
simulation | The transaction was simulated |
send | The transaction was sent |
confirmation | The transaction was followed to confirmation |
Program errors
Raised by Ayo's program and returned in programError (API) or in the transaction logs as a custom error number. Anchor numbers program errors from 6000.
| Number | Name | Raised when |
|---|---|---|
| 6000 | NotOwner | The signer does not control this account. |
| 6001 | AgentPaused | The agent is paused. |
| 6002 | TabNotOpen | This action requires an open tab. |
| 6003 | TabNotSettling | This action requires a tab awaiting confirmation. |
| 6004 | TabFinal | This tab has already reached a final state. |
| 6005 | WindowNotElapsed | The settlement window has not elapsed. |
| 6006 | InvalidVoucher | The voucher does not match a verified Ed25519 instruction. |
| 6007 | InvalidTerms | The public registration or billing terms are invalid. |
| 6008 | OutstandingTabs | The service has outstanding tabs under its current terms. |
SDK
The service middleware answers refused calls with an HTTP status and a one-line message, listed under Responses. What the SDK throws to your own code is listed under What fetch throws, What settle throws and What serve throws.