> ## Documentation Index
> Fetch the complete documentation index at: https://docs.finalsay-hitl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> Every error the Agent API returns, and what your agent should do about it.

Errors are JSON with an `error` code. Some include more fields, shown below.

```json theme={"theme":{"light":"github-light","dark":"vesper"}}
{ "error": "invalid_api_key" }
```

## Error codes

| HTTP | `error` | When | What to do |
| - | - | - | - |
| 400 | `invalid_payload` | The body failed validation, or the merged timeout is invalid (for example a fallback mode with no instruction). `issues` lists the problems. | Fix the request. Don't retry as-is. |
| 401 | `missing_agent_auth` | `X-Agent-Id` or `X-Api-Key` is missing. | Send both headers. |
| 401 | `invalid_agent` | The agent doesn't exist or was archived. | Check the agent ID, or list agents with `GET /v1/agents`. |
| 401 | `invalid_api_key` | The key is wrong, revoked, or from another workspace. | Create a new key under **Workspace settings → API keys**. |
| 401 | `missing_api_key` | `GET /v1/agents` without `X-Api-Key`. | Send the key. |
| 403 | `USAGE_APPROVAL_LIMIT` | The workspace has used its plan's approvals for this period. | Don't retry in a loop. Queue the work and tell a person. See [Plans and limits](https://docs.finalsay-hitl.com/guide/plans-and-limits.md). |
| 404 | `not_found` | No approval with this `request_id` for this agent. | Check you're using `request_id` (not `approval_id`) and the same agent that created it. |
| 409 | `idempotency_conflict` | This `request_id` was already used with a different body. | Use a new `request_id` for a new approval, or resend the original body exactly. |
| 429 | `rate_limited` | More than 60 create attempts for this agent in 60 seconds. | Back off with jitter, then retry. |
| 500 | `approval_creation_failed` | Unexpected server error on create. | Retry with the **same** `request_id`, so you don't create a duplicate. |
| 500 | `agents_list_failed` | Unexpected server error listing agents. | Retry later. |

## Error bodies with extra fields

> [accordion] 400 invalid\_payload
>
> ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> {
>   "error": "invalid_payload",
>   "issues": {
>     "formErrors": [],
>     "fieldErrors": { "question": ["Too big: expected string to have <=500 characters"] }
>   }
> }
> ```

> [accordion] 403 USAGE\_APPROVAL\_LIMIT
>
> ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> { "error": "USAGE_APPROVAL_LIMIT", "code": "USAGE_APPROVAL_LIMIT", "over_limit": true }
> ```
>
> Approvals that are already pending still get answered and delivered.

> [accordion] 409 idempotency\_conflict
>
> ```json theme={"theme":{"light":"github-light","dark":"vesper"}}
> {
>   "error": "idempotency_conflict",
>   "message": "An approval with this request_id already exists for this agent, but the new body does not match the original. …",
>   "request_id": "deploy-v2.4-prod",
>   "existing_approval_id": "1d7c…"
> }
> ```
>
> The comparison covers `correlation_id`, `question`, `context_markdown`, `notification_summary`, `options`, the
> merged `timeout`, and `callback` (URL and headers).

## Order of checks on create

`POST /v1/approvals` checks, in order: authentication, the body, the rate limit, the `request_id` (idempotency), then
your plan's quota. So a malformed body returns `400` even when you're rate limited, and a replay of an existing
`request_id` succeeds even when you're over quota.

## How integrations report errors

| Integration | What you see |
| - | - |
| [CLI](https://docs.finalsay-hitl.com/integrations/cli.md) | Exit code `1` for API errors (`2` for a payload over a limit, caught before sending). With `--json`: `{ "error", "message", "exit_code" }`. |
| [MCP](https://docs.finalsay-hitl.com/integrations/mcp.md) | A tool error carrying the API's `error` code. |
| [n8n](https://docs.finalsay-hitl.com/integrations/n8n.md) and [Zapier](https://docs.finalsay-hitl.com/integrations/zapier.md) | The step fails with the API's error message. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.