# Errors

> Every failure code of the HTTP API and MCP tools with its HTTP status and what to do, and where the CLI's exit codes are listed.

Source: https://docs.corfedo.ai/reference/errors/

The HTTP API and the MCP tools share one set of failure codes. A failure has a `code`, a `message` and a `correlationId`. Include the `correlationId` when you report a problem to whoever runs Corfedo.

## Failure body

```json
{
  "code": "ambiguous_repository",
  "message": "Several repositories have this name; use a canonical name.",
  "correlationId": "0HN8…",
  "candidates": ["github.com/acme/payments", "gitlab.com/acme/payments"]
}
```

| Field | Present |
| --- | --- |
| `code`, `message`, `correlationId` | Always |
| `candidates` | With `ambiguous_repository` and `repository_not_found`: canonical names to choose from |
| `retryAfterSeconds` | With `resource_exhausted` and `unavailable`. The `Retry-After` header carries the same value. |
| `scope` | With `missing_scope`: the scope the credential lacks |
| `limit` | With `limit_exceeded`: the spending limit that was reached and when it resets |

## Codes

| HTTP status | Code | Meaning | What to do |
| --- | --- | --- | --- |
| 400, or 405, 413 or 415 for a wrong method, a body over the size limit or a wrong content type | `invalid_argument` | A field is missing, unknown, malformed or out of range. For search, the message names the problem in the query and how to rewrite it. | Fix the request |
| 400 | `ambiguous_repository` | Several repositories you can read have this name | Use a canonical name from `candidates` |
| 400 | `https_required` | The request used plain HTTP | Use the `https://` address |
| 401 | `unauthenticated` | No credential, or it expired or was revoked | Get a new credential, or sign in again |
| 403 | `permission_denied` | Your access does not allow the operation, or Corfedo AI is off for this kind of client | Ask for access, or ask an administrator to turn Corfedo AI on in **Client access** |
| 403 | `missing_scope` | The credential lacks the scope in `scope` | Sign in again with the permission, or use a key that has it |
| 403 | `network_not_allowed` | The workspace's or the key's network list leaves out your address | Connect from an allowed network, see [Client access](https://docs.corfedo.ai/workspace/client-access/) |
| 404 | `not_found` | The resource does not exist, or you cannot read it | Check the ID or path |
| 404 | `repository_not_found` | No repository you can read has this name | Check the name. `candidates` can list similar names. |
| 409 | `conflict` | The request conflicts with the current state | Read the current state and try again |
| 409 | `revision_changed` | The object changed after you read it | Read it again, then repeat the change |
| 409 | `already_exists` | Another object already has this name | Choose another name |
| 409 | `failed_precondition` | The installation's configuration does not allow it | Ask whoever runs Corfedo |
| 409 | `limit_exceeded` | A monthly AI spending limit is reached. No answer started. | Wait for the reset in `limit`, or ask an administrator to raise the [limit](https://docs.corfedo.ai/workspace/ai/spending-limits/) |
| 409 | `conversation_busy` | An answer in this conversation is still running | Wait for it to end, or cancel it |
| 409 | `client_message_conflict` | The client message ID was already used for another request | Use a new ID for a new message |
| 409 | `other_source` | The conversation was started from another kind of client | Continue it where it started, or start a new conversation |
| 409 | `profile_unavailable` | The AI profile chosen for this kind of client is not available to you | Ask an administrator to change the profile or its availability |
| 410 | `continuation_expired` | A page continuation is too old | Start the paged request again |
| 429 | `resource_exhausted` | Corfedo is at capacity | Retry after `retryAfterSeconds` |
| 500 | `internal` | An unexpected failure | Retry later. Report the `correlationId` if it persists. |
| 503 | `unavailable` | A service Corfedo needs is busy or not ready | Retry after `retryAfterSeconds` |
| 504 | `deadline_exceeded` | The operation ran out of time | Narrow the request, or try again |

Over the HTTP API, a code read whose revision or continuation is no longer served is not a failure. It answers with the status `stale` and the `currentRevision`, see [Pages](https://docs.corfedo.ai/connect/api/#pages). An MCP tool returns the same case as the error `stale_revision` with `currentRevision`. Read again at that revision.

## MCP connection errors

The MCP endpoint refuses some requests before any tool runs. The body then has `error` and `correlationId` instead of `code` and `message`.

| HTTP status | `error` | Meaning |
| --- | --- | --- |
| 403 | `invalid_origin` | A browser request from an origin the endpoint does not accept |
| 413 | `request_too_large` | The request body is too large |

## Answer stream errors

An answer stream that fails sends an `error` event with `code`, `message` and `retryable`, then ends. A run that ends without an answer reports its outcome on the run, not as a failure code. See [Streaming](https://docs.corfedo.ai/connect/api/ai/streaming/).

## CLI exit codes

The CLI maps these failures to exit codes, see [CLI commands](https://docs.corfedo.ai/reference/cli/#exit-codes). With `--format json`, `error.code` holds the code from this page or a CLI code such as `credential_store_unavailable` or `connection_mismatch`.
