# Errors

The REST API reports every failure as a [problem document](https://datatracker.ietf.org/doc/html/rfc9457) with the content type `application/problem+json`. The `slug` names the error; the HTTP status says what kind.

```json
{
  "type": "https://api.veryfront.com/errors/resource-not-found",
  "title": "Resource Not Found",
  "status": 404,
  "detail": "Project does-not-exist-xyz not found",
  "instance": "/projects/does-not-exist-xyz",
  "slug": "resource-not-found",
  "category": "RESOURCE",
  "suggestion": "Verify the resource ID exists and you have access to it."
}
```

| Field        | Meaning                                                                                    |
| ------------ | ------------------------------------------------------------------------------------------ |
| `slug`       | Stable name of the error. Match on this, not on `detail`.                                  |
| `status`     | The HTTP status.                                                                           |
| `category`   | `AUTH`, `RESOURCE`, `VALIDATION`, `DATABASE`, `SUBSCRIPTION`, `INTEGRATION` or `INTERNAL`. |
| `detail`     | What went wrong in this request.                                                           |
| `suggestion` | What to do about it.                                                                       |
| `errors`     | On a validation failure, one entry per field: `field`, `message`, `code`.                  |

A validation failure names each field:

```json
{
  "status": 400,
  "slug": "validation-failed",
  "detail": "name: Required",
  "errors": [{ "field": "name", "message": "Required", "code": "invalid_type" }]
}
```

## Look up an error

`GET /errors` lists every error with its status, category and suggestion. `GET /errors/{slug}` adds the steps to fix it and related errors. Neither needs a key.

```bash
curl https://api.veryfront.com/errors/resource-not-found
```

## Common errors

| Status | Slug                        | Fix                                                                        |
| ------ | --------------------------- | -------------------------------------------------------------------------- |
| 400    | `validation-failed`         | Check the body against the endpoint's reference.                           |
| 401    | `authentication-required`   | Send a valid key. See [Authentication](/docs/reference/authentication.md). |
| 402    | `insufficient-credits`      | Buy credits or upgrade the plan.                                           |
| 402    | `ai-budget-exceeded`        | Raise the monthly AI budget, or wait for it to reset.                      |
| 403    | `authorization-denied`      | Use a credential with the permission.                                      |
| 403    | `key-model-denied`          | Call a model on the key's model list.                                      |
| 404    | `resource-not-found`        | Check the ID and your access to its project.                               |
| 409    | `resource-already-exists`   | Use a different name, or update the existing one.                          |
| 413    | `webhook-payload-too-large` | Send a payload of 64 KiB or less.                                          |
| 429    | `key-rate-limited`          | Wait for `Retry-After`. See [Limits](/docs/reference/limits.md).           |
| 503    | `service-unavailable`       | Retry in a few minutes.                                                    |

## The AI Gateway

The AI Gateway's `/ai/v1` endpoints answer in the error shape of the SDK that calls them, so that SDK can read it: `{ "error": { "message", "type", "code" } }` for OpenAI-style calls, and the Anthropic and Google equivalents. A provider's own error is passed through in that shape.

```json
{
  "error": {
    "message": "Authentication failed. Provide a Veryfront API key as a Bearer token in the Authorization header, or in x-api-key.",
    "type": "authentication_error",
    "param": null,
    "code": "unauthorized"
  }
}
```

Errors in Studio, chat and a run's events have their own page: [Fix errors](/docs/help/errors.md).
