Program errors
Custom errors start at 6000. A failed transaction names the error on its first Program … failed line for the Civitas program ID; the API returns it as programError.name with CHAIN_REFUSED. The sample economy refuses with the same names.
| Number | Hex | Name |
|---|---|---|
| 6000 | 0x1770 | AgentFrozen |
| 6001 | 0x1771 | AgentRevoked |
| 6002 | 0x1772 | PolicyExpired |
| 6003 | 0x1773 | AuthorizationExpired |
| 6004 | 0x1774 | PayeeNotAllowed |
| 6005 | 0x1775 | OverPerCallLimit |
| 6006 | 0x1776 | OverPeriodCap |
| 6007 | 0x1777 | NonceReplayed |
| 6008 | 0x1778 | BadSignature |
| 6009 | 0x1779 | BadConsent |
| 6010 | 0x177a | ConsentExpired |
| 6011 | 0x177b | FeeMismatch |
AgentFrozen
6000 · The principal froze this agent.
The payer’s principal froze it. Unfreezing lets the same authorization settle if it hasn’t expired.
Raised by settle.
AgentRevoked
6001 · The principal revoked this agent.
The agent, or the payee agent in settle, was revoked.
Raised by deposit, withdraw, set_policy, freeze, unfreeze, revoke, list_service, unlist_service, settle.
PolicyExpired
6002 · The spending policy has expired.
The clock reached the policy’s expires_at. A new policy with a later expiry clears it.
Raised by settle.
AuthorizationExpired
6003 · The payment authorization has expired.
The clock reached the authorization’s expires_at. The agent signs a new one.
Raised by settle.
PayeeNotAllowed
6004 · The policy does not allow this payee.
The policy has an allowlist and the payee isn’t on it.
Raised by settle.
OverPerCallLimit
6005 · The amount and fee exceed the per-call limit.
Amount plus fee is above max_per_call.
Raised by settle.
OverPeriodCap
6006 · The amount and fee exceed the remaining period allowance.
This charge would take the period’s spending above max_per_period.
Raised by settle.
NonceReplayed
6007 · This nonce was used or is below the replay window.
The nonce settled before, or it is 256 or more below the highest nonce settled.
Raised by settle.
BadSignature
6008 · The preceding Ed25519 instruction does not verify this authorization.
No Ed25519 instruction sits just before settle, or its key or message is not the agent’s authorization. A signature that fails cryptographically is refused earlier, by the Ed25519 program itself.
Raised by settle.
BadConsent
6009 · The preceding Ed25519 instruction does not verify this charter consent.
No Ed25519 instruction sits just before charter, or its key or message is not the agent key’s consent to this principal, card hash and expiry.
Raised by charter.
ConsentExpired
6010 · The charter consent has expired.
The clock reached the consent’s expiry before the charter landed. The agent key signs a new consent.
Raised by charter.
FeeMismatch
6011 · The signed fee does not match the configured fee for this payment.
The fee in the signed authorization isn’t the fee the program’s config gives for the amount, which happens when the fee terms changed after the quote. The agent signs again against a fresh quote.
Raised by settle.
API errors
Every failed response carries one envelope, { "error": { "code", "message", "retryable", "stage", … } }, whatever its HTTP status. Branch on code. The envelope’s fields are under ApiError.
| Code | HTTP | When |
|---|---|---|
VALIDATION_ERROR | 400 | A request field failed its schema, and fieldErrors names each one. Builds also answer it for a request the state can’t satisfy: a key that already has a charter, a withdrawal over the vault balance. |
UNAUTHORIZED | 401 | The route needs a session and the request carries no valid Authorization: Bearer token. |
ORIGIN_NOT_ALLOWED | 403 | The request’s Origin is not one the API allows. |
NOT_FOUND | 404 | No such agent, settlement, receipt, card, build or sample session. |
PROGRAM_UNAVAILABLE | 409 | The API is waiting for the program on its cluster. Retry later. |
CONFIGURATION_REQUIRED | 409 | A value the route needs is not configured on this API yet. |
IDEMPOTENCY_CONFLICT | 409 | The build was already submitted under another idempotency key, or a different receipt already carries this signature or is linked to this settlement. |
TRANSACTION_EXPIRED | 409 | The build’s blockhash expired before the transaction landed. Build it again. |
PAYLOAD_TOO_LARGE | 413 | The request body is over the route’s limit. |
UNSUPPORTED_MEDIA_TYPE | 415 | The body is not application/json. |
SIMULATION_FAILED | 422 | The built transaction failed simulation. programError names the program error when there is one. |
CHAIN_REFUSED | 422 | The program refused the transaction. programError.name is one of the program errors above. |
RATE_LIMITED | 429 | Too many writes from this client this minute. retryAfterSeconds says when to retry. |
INTERNAL_ERROR | 500 | The API failed. requestId identifies the request. |
UPSTREAM_UNAVAILABLE | 502 | The chain or the sample economy can’t be reached. |
FORBIDDEN | 403 | The session wallet is not the agent’s principal. |
INVALID_RECEIPT | 422 | The receipt’s signature doesn’t verify against the payee key it names, or its call ID, payer, payee or amount isn’t the settlement’s. |
Stages
stage says where the flow failed.
| Stage | Where |
|---|---|
validation | The request’s fields. |
auth | The session or the principal check. |
read | Reading state. |
upload | Storing a card or receipt. |
build | Building a transaction. |
wallet | The wallet signing. |
co_sign | The API co-signing. |
simulation | Simulating the signed transaction. |
send | Sending it. |
confirmation | Waiting for it to land. |