# Errors

The error body, the status and error codes shared by all operations, budget refusals, and how a client should react to each.

Errors use conventional HTTP status codes and a small JSON body with a machine-readable code, so a client can handle the common cases once. This page lists the codes that any operation can return. Codes that belong to a single operation are listed with that operation in the reference.

## The error body

```json
{
  "error": "insufficient_scope",
  "detail": "This API key does not have the 'run' scope required for POST /api/run."
}
```

- `error` is a short machine-readable code, usually in snake_case. Branch on the HTTP status and this code.

- `detail` is optional text for a developer. Its wording can change, so do not parse it.

- Some errors add fields, for example `retryAfterSec` on a rate limit or `invoked` and `budget` on a budget refusal.

- The MCP endpoint reports errors as JSON-RPC error objects instead. See [MCP](https://centerofagentic.com/docs/mcp).

A governance denial is not an HTTP error

When policy refuses a run, `POST /api/run` still answers `200`. The body has `decision` set to `deny`, a `reasonCode` such as `PKG_REVOKED` or `SPEND_OVER_BUDGET`, an empty `output` and the `receipt` that records the refusal. Always read `decision` on a successful run response. See [Runs](https://centerofagentic.com/docs/api/runs).

## Errors any operation can return

| Status | Code | Cause | What to do |
| --- | --- | --- | --- |
| 401 | `unauthenticated` | No `Authorization` header, an unknown, revoked or expired key, or a key whose creating admin could not be confirmed as an active member of the workspace. | Do not retry in a loop. Check the header, and check in Settings that the key is still listed, before you create a new one. |
| 403 | `no_active_organization` | A browser session with no workspace selected. API keys always carry their workspace. | Select a workspace in the web workspace. |
| 403 | `capability_denied` | The operation is reserved for a signed-in person, or the person behind the credential (for a key, the admin who created it) has the **Business Owner** access profile, which does not include the operation. | Perform the action in the web workspace, or have a workspace admin create a new key. See [Availability](https://centerofagentic.com/docs/surfaces). |
| 403 | `external_credential_not_supported` | An external agent's key was used on a route other than the external agent operations. | Use a workspace API key. |
| 403 | `insufficient_scope` | The key lacks the scope the operation needs. `detail` names the scope, the method and the path. | Use a key that has the scope. See [Authentication](https://centerofagentic.com/docs/authentication). |
| 403 | `admin_required`, `full_session_required` | Returned by individual operations that only a signed-in workspace admin or member may perform. | Perform the action in the web workspace. |
| 404 | `not_found` | No such resource in this workspace. A resource in another workspace looks the same as a missing one. | Check the id and that the key belongs to the right workspace. |
| 405 | `method_not_allowed` | The path exists but does not support the HTTP method. The `Allow` header lists the methods it does support. | Fix the method. |
| 409 | `revision_conflict` | A protected change was decided against authorization state that has since changed. | Read the current state and decide again. Do not replay the request automatically. |
| 429 | `rate_limited` | Too many requests of one kind in the current window. The response carries `Retry-After`. | Wait, then retry. See [Rate limits](https://centerofagentic.com/docs/reference/rate-limits). |
| 500 | `server_error` | An unexpected failure. `detail` may carry a message. | Retry reads with backoff. For writes and runs, check the outcome first. |
| 503 | `database_unavailable` | Storage is temporarily unreachable or over its quota. `detail` gives a short description. | Retry with backoff. |
| 503 | `server_error` | A service the operation depends on is not configured or not available. | Retry later. |

Operations that start a run add their own launch errors. The ones a new integration meets first are `426 agent_protocol_required`, when an agent under managed activation is run without the `X-CoA-Agent-Protocol` header, `428 agent_launch_required`, when the `X-CoA-Agent-Ticket` header is missing, and `409 agent_admission_unavailable`, when the agent has no active version or the ticket has expired or does not match the request. [Runs](https://centerofagentic.com/docs/api/runs) lists them all.

## Budget and accounting refusals

Operations that call a model check the workspace's budgets before the model is called. A workspace admin sets budgets under **Settings → Budgets**. Budget checks work from cost estimates and the spend the platform has recorded, and complete model-spend accounting is still in progress, so treat a budget as a control on new work and not as a guarantee about your model provider's invoice. A refusal takes one of these forms, and most of them carry `invoked` to say whether the model provider was reached:

| Status | Code | Meaning |
| --- | --- | --- |
| 200 | `decision: "deny"` with `reasonCode: "SPEND_OVER_BUDGET"` | An agent run would exceed the workspace's monthly budget or the budget for its authority level, or a configured budget could not be verified. A receipt records the refusal. |
| 402 | `over_budget` | The workspace is over its monthly budget. Returned by model-calling operations other than agent runs, such as model comparisons. |
| 402 | `spend_reservation_refused` | The estimated cost of the request does not fit under a configured budget. |
| 409 | `spend_reservation_refused` | The budget state changed, conflicted or expired while the request was being admitted. |
| 503 | `spend_reservation_refused` | The budget state cannot be verified right now. |
| 503 | `spend_state_unavailable` | This month's spend cannot be verified. The platform refuses instead of assuming zero. |
| 503 | `model_usage_request_identity_required` | The request has no `X-CoA-Model-Request` header and usage accounting requires one; a conversation turn answers the same for a malformed value. The model was not called. Send the header and repeat the request. For an activated agent, request a new launch ticket first: the refused request used its own. |
| 503 | `model_usage_accounting_unavailable`, `model_usage_reconciliation_required` | Usage accounting is unavailable, or an earlier attempt has an unknown outcome. `invoked` says whether the model provider may have been called. |

```json
{
  "error": "spend_reservation_refused",
  "invoked": false,
  "decisionId": "c5d8e2f1-6a47-4b39-9e10-2d4f6a8b0c13",
  "budget": {
    "allowed": false,
    "reason": "cap_exceeded",
    "scope": "tenant",
    "estimate": 0.3,
    "spendEnforced": false,
    "actualDollarBound": false
  },
  "detail": "Budget estimate admission refused. Reconcile the existing operation; never automatically repeat paid work."
}
```

`budget` carries the evidence that could be verified. Its fields vary: the example shows a subset, some can be missing and others, such as the budget amount and the spend counted against it, can be present. Branch on the status, `error` and `invoked`, and keep `budget` for diagnosis. `decisionId` can be `null`. On a streaming operation the same body arrives as an `error` event when the refusal happens after the stream has opened.

Do not retry these automatically

With `invoked` set to `false`, the refused model call was not sent: change the budget or wait for the state to recover, then send the request again deliberately. With `invoked` set to `true`, the model provider may have been called and may have charged for it: look for the receipt before you repeat anything. An agent with connections makes several model and tool calls in one request, so when a later call is refused the earlier ones have already run, and that request writes no receipt: check the connected system before you run again.

## Handling errors in a client

- Branch on the HTTP status first, then on `error`. Handle a code you do not know by its status class.

- `401` and `403` are not retryable. Stop, fix the credential or the scope, and alert someone rather than loop.

- `409` means the state moved. Read it again before deciding what to send.

- `429 rate_limited` tells you how long to wait in `Retry-After`. For other `429` codes see [Rate limits](https://centerofagentic.com/docs/reference/rate-limits).

- On `5xx`, retry `GET` requests with exponential backoff and jitter. For writes and runs, confirm what happened before repeating: the receipt list is the durable record of runs.

- Log the status, the `error` code and, when present, the receipt `id` and `decisionId`. Keep `detail` in logs; do not show it to end users.

```bash
http_status=$(curl -s -o response.json -w "%{http_code}" \
  https://centerofagentic.com/api/agents \
  -H "Authorization: Bearer $COA_API_KEY")

if [ "$http_status" != "200" ]; then
  echo "Request failed with $http_status: $(jq -r .error response.json)" >&2
fi
```

## Next steps

- [**Rate limits** Limits per key and per workspace, and how to back off.](https://centerofagentic.com/docs/reference/rate-limits)

- [**Automation and CI** Which responses to retry and which to stop on.](https://centerofagentic.com/docs/guides/automation)

- [**Troubleshooting** Start from the status and error code you see.](https://centerofagentic.com/docs/guides/troubleshooting)

Source: https://centerofagentic.com/docs/api/errors

## Related pages

- [MCP](https://centerofagentic.com/docs/mcp)
- [Runs](https://centerofagentic.com/docs/api/runs)
- [Availability](https://centerofagentic.com/docs/surfaces)
- [Authentication](https://centerofagentic.com/docs/authentication)
- [Rate limits](https://centerofagentic.com/docs/reference/rate-limits)
- [Rate limits Limits per key and per workspace, and how to back off.](https://centerofagentic.com/docs/reference/rate-limits)
- [Automation and CI Which responses to retry and which to stop on.](https://centerofagentic.com/docs/guides/automation)
- [Troubleshooting Start from the status and error code you see.](https://centerofagentic.com/docs/guides/troubleshooting)
