# Errors and reason codes

Every reason code Abazi returns with a decision, what the owner sees, what the agent should do next, and whether a retry can help.

<ShortProductTruth>Every policy decision carries one machine-readable reason code. Agents act on `next_action`; owners read the title and body. The codes and their text come from one catalog, versioned with the policy.</ShortProductTruth>

## The error shape [#the-error-shape]

Every non-2xx response has one shape. `code` is the error class and maps to the HTTP status; `reason_code` is set when a policy or a rule decided.

```json title="Error body"
{ "code": "POLICY_DENIED", "reason_code": "HARD_CAP_EXCEEDED", "message": "...", "details": {}, "request_id": "req_..." }
```

| Status | `code` values |
| --- | --- |
| 400 | `VALIDATION_ERROR` (field errors in `details.errors`) |
| 401 | `UNAUTHENTICATED`, `AGENT_CREDENTIAL_INVALID` |
| 403 | `FORBIDDEN`, `PASSKEY_REQUIRED`, `POLICY_DENIED`, `ROLE_NOT_GRANTABLE` |
| 404 | `NOT_FOUND` |
| 409 | `IDEMPOTENCY_CONFLICT`, `ILLEGAL_STATE`, `CONFLICT`, `APPROVAL_NOT_ALLOWED`, `CONSENT_REQUIRED` |
| 422 | `MERCHANT_NOT_PAYABLE` |
| 429 | `RATE_LIMITED` |
| 502, 503 | `MERCHANT_UNREACHABLE`, `RAIL_UNAVAILABLE` |

Each operation page lists the statuses it can return. Do not parse `message`; branch on `code` and `reason_code`.

## Where codes appear [#where-codes-appear]

The codes below are the ones the policy engine, the approval flow and the card authorization stream return.

- **To the agent**: in the MCP tool result or the REST response, together with `next_action` and whether retrying makes sense.
- **To the owner**: on the payment in the Console, with the policy trace, and on the receipt.
- **In webhooks**: on payment and approval events.

The policy engine checks its steps in a fixed order and returns the code of the first step that hits. See [Mandates and policy](/docs/concepts/mandates-and-policy#how-a-decision-is-made) for the order.

## Denials [#denials]

<ReasonCodeTable decision="DENY" />

## Asks for approval [#asks-for-approval]

<ReasonCodeTable decision="REQUIRE_APPROVAL" />

## Allowed [#allowed]

<ReasonCodeTable decision="ALLOW" />

## Card declines [#card-declines]

<ReasonCodeTable decision="DECLINE" />

## How an agent should handle a code [#how-an-agent-should-handle-a-code]

| If the code is | The agent should |
| --- | --- |
| A deny with retry "no" | Stop and report. Retrying the same purchase gives the same answer: the engine is deterministic. |
| A deny with retry "yes" | Wait and try later. Only a pause by the operator is retryable. |
| An ask for approval | Poll the purchase status. A person decides within the approval window or the request expires. |
| `WITHIN_POLICY` | Nothing; the payment proceeds and a receipt follows. |

## Next steps [#next-steps]

<Cards>
  <Card title="Mandates and policy" href="/docs/concepts/mandates-and-policy" description="Why a step hits, and why an approval cannot clear a deny." />
  <Card title="MCP tools" href="/docs/mcp" description="Where the agent receives the code and next action." />
  <Card title="Approvals" href="/docs/concepts/approvals" description="What happens after REQUIRE APPROVAL." />
</Cards>

