Reference

Errors

Every error from the CortexPay API has the same JSON shape and a stable, machine-readable code. Switch on the code, show the message.
Code samples in

Error shape#

400 Bad Request
{
  "error": {
    "code": "validation_failed",
    "message": "rules.maxPerPayment: Expected integer base units",
    "details": [{ "path": "rules.maxPerPayment", "message": "Expected integer base units" }]
  }
}

code is stable and safe to branch on. message is written for people and may change. details is optional and depends on the code: field issues for validation_failed, retryAfter for rate_limited.

Status codes#

StatusCodeMeaning
400bad_requestA malformed request: missing header, bad cursor, wrong parameter.
400validation_failedThe body did not match the schema. details lists up to 8 { path, message } issues.
401unauthorizedNo valid session or API key: missing, malformed, revoked or expired, or its workspace has expired.
403forbiddenAuthenticated, but the role or the key's scopes do not allow this. The message names what is missing.
404not_foundThe resource does not exist in this workspace. Other workspaces' resources also return 404.
409variousConflicts with the current state; see below.
413payload_too_largeSandbox x402 resources accept bodies up to 16 KB.
422variousWell-formed but not allowed right now; see below.
429rate_limitedRate limit hit. The Retry-After header and details.retryAfter give the seconds to wait.
500internal_errorUnexpected failure. Safe to retry with the same Idempotency-Key.
503variousA dependency this call needs is unavailable or not configured on this deployment, for example the AI assistant.

Common codes#

CodeStatusMeaning
idempotency_key_reused409The Idempotency-Key was already used with a different body.
request_in_progress409A request with this Idempotency-Key is still running. Retry shortly.
quote_expired409The 5-minute quote expired. Request a new quote.
quote_closed409The quote was already used or closed.
version_conflict409The policy changed since you read it. Reload and publish against the latest version.
already_paused / not_paused409The agent is already in the state you asked for.
agent_revoked / already_revoked409Revocation is permanent.
approval_decided / approval_expired409The approval is no longer pending.
key_revoked409The API key was already revoked.
last_owner / last_workspace409A workspace always keeps one owner, and you always keep one workspace.
policy_invalid422The rules are inconsistent; details.fields lists each problem.
policy_archived422Agents on an archived policy cannot pay.
sandbox_only422A sandbox workspace tried to call a non-sandbox service or URL.
sandbox_service422A live workspace tried to call a sandbox service.
service_unavailable422The service is not operational.
unsupported_payment_requirements422The service offered no payment option CortexPay can sign.
payments_frozen422New payment authorizations are frozen for this workspace.
live_funding_unavailable422Live agents are funded on-chain, not through CortexPay.
funding_cap / insufficient_balance422Sandbox funding limits, or not enough balance to withdraw.
insufficient_credits422Not enough infrastructure credits for the action.
unsafe_url422The URL is not public HTTPS (private, loopback or link-local addresses are refused).
webhook_limit / key_limit422The workspace reached its number of webhook endpoints or API keys.
rate_limited429Too many requests in this minute. Wait Retry-After seconds.
internal_error500Something failed on CortexPay's side; the request was not completed.

Refusals are not errors#

A payment the policy refuses, a service that fails after payment, or a payment waiting for approval is a normal result of POST /api/services/request or /api/payments/authorize: HTTP 200 (or 202 while waiting) with status, evaluation.reasonCode and error in the body.

Retrying safely
Retry 429, 5xx and network failures with the same Idempotency-Key. Do not retry other 4xx responses unchanged: fix the request and send it with a new key. A key that already failed can replay the same error, and a key reused with a different body returns idempotency_key_reused.