Skip to content

Error handling.

Understanding structured error responses and retry strategies.

Oct 23, 2026
On this page

Every Agent API response follows a predictable structure. Success and error responses use the same envelope format, so AI agents and automation tools can parse them without special cases. Framework errors on agent paths use the envelope too, and so does the MCP endpoint. Limits, errors and retries lists every code in one table.

Response envelope

Success response

{
  "error": false,
  "data": {
    "id": "9e1a...",
    "name": "Downtown Club"
  }
}

Paginated list responses include pagination metadata:

Schematic JSON (omitted fields use ...):

{
  "error": false,
  "data": [...],
  "pagination": {
    "current_page": 1,
    "per_page": 25,
    "total": 42
  }
}

Authenticated requests that reach rate limiting include these headers. Authentication and feature-gate failures may omit them. On HTTP 429, honor Retry-After; the reset timestamp on successful responses is not an exact window boundary:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 58
X-RateLimit-Reset: 1741260060

Error response

{
  "error": true,
  "code": "VALIDATION_FAILED",
  "message": "The request data did not pass validation.",
  "retry_strategy": "fix_request",
  "details": {
    "errors": {
      "card_id": ["The card_id field is required."],
      "purchase_amount": ["The purchase_amount must be at least 0.01."]
    }
  }
}

Error fields

Field Type Description
error boolean Always true for error responses
code string Machine-readable error code (e.g., AUTH_INVALID_KEY)
message string Human-readable description
retry_strategy string How the caller should handle this error
details object Optional additional context (validation errors, limits, etc.)

Retry strategies

The retry_strategy field tells AI agents and automation tools how to handle the error:

Strategy Meaning What To Do
no_retry The request itself is invalid Fix the integration. Wrong key, wrong scope, resource not found.
fix_request Request body has errors Fix the request payload and try again (validation errors).
backoff Temporary issue Honor Retry-After. Retry only when the operation is safe to repeat; reconcile other writes first.
retry_later The platform can't do this right now Apple Wallet signing isn't set up. Try later and don't loop. Check the Apple Wallet API.
contact_support Requires human intervention Feature disabled, limit reached, account deactivated.

Retry strategy examples

no_retry: Don't retry. The request was wrong.

{
  "code": "AUTH_INVALID_KEY",
  "retry_strategy": "no_retry"
}

fix_request: Fix the data and try again.

{
  "code": "VALIDATION_FAILED",
  "retry_strategy": "fix_request",
  "details": {
    "errors": {
      "card_id": ["The card_id field is required."]
    }
  }
}

backoff: Wait before a safe retry. After an ambiguous purchase failure, repeat the request only if the original included source_reference and the sale facts match. Reconcile redemptions, deductions, and unreferenced purchases before retrying. See the production checklist.

{
  "code": "INTERNAL_ERROR",
  "retry_strategy": "backoff"
}

Recommended backoff: 1s → 2s → 4s → 8s → 16s → stop.

contact_support: Human intervention needed.

{
  "code": "FEATURE_DISABLED",
  "retry_strategy": "contact_support",
  "details": {
    "permission": "loyalty_cards_permission"
  }
}

Error code reference

Authentication errors (401/403)

Code HTTP Retry Description
AUTH_MISSING_KEY 401 no_retry No key in the Authorization: Bearer or X-Agent-Key header
AUTH_INVALID_KEY 401 no_retry Key format wrong or hash mismatch
AUTH_KEY_REVOKED 401 no_retry Key is no longer active
AUTH_KEY_EXPIRED 401 no_retry Key past its expiration date
AUTH_OWNER_INACTIVE 403 contact_support Owner account deactivated
AUTH_ANONYMOUS_MEMBER 403 no_retry Anonymous members cannot use keys
AUTH_INSUFFICIENT_SCOPE 403 no_retry Key lacks required scope
AUTH_WRONG_ROLE 403 no_retry Key role doesn't match endpoint

Validation errors (422)

Code HTTP Retry Description
VALIDATION_FAILED 422 fix_request Request body failed validation
LIMIT_REACHED 422 contact_support Partner resource limit hit

Resource errors (404)

Code HTTP Retry Description
NOT_FOUND 404 no_retry Resource not found or doesn't belong to partner

Permission errors (403)

Code HTTP Retry Description
FEATURE_DISABLED 403 contact_support Feature not enabled for partner

Server errors (500)

Code HTTP Retry Description
INTERNAL_ERROR 500 backoff Unexpected server error

Rate limiting (429)

Code HTTP Retry Description
RATE_LIMITED 429 backoff Exceeded requests per minute limit

The 429 response includes extra headers and details:

Retry-After: 23
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1741260023

See Rate limiting in Authentication for full details.

Codes shared by every agent path

Limits, errors and retries lists every code, including the many that belong to one feature, such as purchases, stamps, vouchers, email campaigns and stored-money passes. The codes below come from checks that every agent request passes through: transport, read-through, idempotency, approvals and the dashboard's own form rules. Idempotency and approvals explains the repeat and approval codes.

Code HTTP Retry When it happens
AUTH_AMBIGUOUS_KEY 400 fix_request The request sent both Authorization: Bearer and X-Agent-Key with different values. Send one.
ORIGIN_NOT_ALLOWED 403 no_retry The request carried an Origin header, which means it came from a web page. Call the API from a server or a desktop client.
DEMO_MODE 403 no_retry A demo installation refuses changes and approvals. Reads still work.
PAYLOAD_TOO_LARGE 413 fix_request The body is larger than 256 KiB. details.max_bytes gives the limit. Send fewer items per call.
METHOD_NOT_ALLOWED 405 fix_request The path doesn't accept this method. GET and DELETE on /mcp get this answer with Allow: POST.
BAD_REQUEST 400 fix_request The request couldn't be read.
UNSUPPORTED_MEDIA_TYPE 415 fix_request Send the body as application/json.
READ_THROUGH_NOT_ALLOWED 403 no_retry The X-Agent-Partner header was sent by a credential that can't use it, or on a path that isn't a business read. Only the platform owner's credential can read another business. Approvals aren't readable through another business.
READ_THROUGH_READ_ONLY 403 no_retry A change was sent with read-through to another business. Reading through works for reads only.
WRITE_REFUSED 422 fix_request A business owner's change: the dashboard form refused it, and message says why, for example a plan rule or an unoffered choice.
WRITE_REFUSED 409 no_retry A platform owner's change: the console refused it, and message says why.
SETTING_NOT_AGENT_WRITABLE 422 fix_request A setting the Agent API can't change: credentials, uploads, language settings, the AI and Agent API switches, or the billing provider. details names it. Nothing was saved.
INVALID_IDEMPOTENCY_KEY 422 fix_request The idempotency key isn't 1 to 80 characters from A-Z, a-z, 0-9, hyphen and underscore.
IDEMPOTENCY_CONFLICT 409 fix_request The key was already used for a different request. Use a new key for a new request.
IDEMPOTENCY_IN_PROGRESS 409 backoff A request with this key is still running. Retry with the same key after Retry-After (1 second).
APPROVAL_PENDING 409 backoff The owner hasn't decided yet. Give them the review link and try again.
APPROVAL_REJECTED 409 no_retry The owner rejected the change. It won't run.
APPROVAL_STALE 409 fix_request The record changed after the owner reviewed it, or an earlier run failed partway. Check the record, then prepare the change again.
APPROVAL_USED 409 no_retry The approval already ran. Read the approval to get its result.
APPROVAL_EXPIRED 410 fix_request The 10 minutes passed. Prepare the change again.
APPROVAL_IN_PROGRESS 409 backoff The change is running now. Read the approval in a moment.
APPROVAL_REQUIRED 409 no_retry An email send to members was called without an approval the owner gave. Nothing was sent. Prepare the send and let the owner approve it.
APPROVAL_MISMATCH 409 no_retry The request isn't the change the owner approved, so nothing ran. Prepare the change again. A run that couldn't finish answers INTERNAL_ERROR instead.
PLATFORM_UNAVAILABLE 409 retry_later Apple Wallet signing isn't set up on this platform. Try later. Don't loop.
UNAVAILABLE 503 backoff The service is temporarily unavailable.
TOOLS_UNAVAILABLE 503 backoff The tool definitions aren't available yet on this installation. Ask the platform owner.
SPEC_UNAVAILABLE 503 backoff The API description could not be read, so Reward Loyalty can't tell whether a change needs approval. It refuses every change until it can read it again, which can happen for a moment while an update rewrites it. Nothing changed, reads still answer, and an approval already given stays open. Try again shortly. If it lasts, ask the platform owner.

For AI agent developers

If you're building an AI agent that consumes this API, branch on retry_strategy:

response = call_agent_api(endpoint, data)

if response["error"]:
    match response["retry_strategy"]:
        case "no_retry":
            log_error(response["code"], response["message"])
            raise PermanentError(response["message"])
        case "fix_request":
            fix_fields(response["details"]["errors"])
            retry_with_fixed_data()
        case "backoff":
            if operation_is_safe_to_repeat:
                wait_exponential(attempt)  # Also honor Retry-After.
                retry()
            else:
                reconcile_before_retry()
        case "contact_support":
            notify_human(response["message"])
            raise NeedsHumanIntervention(response["message"])