# Errors

> Every Besday API error code with its HTTP status and meaning, the JSON error envelope, and which errors are safe to retry.

Source: https://besday.com/docs/api/errors · Updated 2026-12-03 · OpenAPI: https://besday.com/api/v1/openapi.json

Errors use conventional HTTP status codes and one JSON shape. Branch on `error.type` for behaviour (retry or not) and on `error.code` for the exact reason; show `error.message` to people.

### The error object

Every error answer has this shape, with the matching HTTP status.

| Field | Type | Description |
|---|---|---|
| `error.type` | string | Broad class: decides whether to retry. |
| `error.code` | string | Specific reason. Stable; see [Errors](https://besday.com/docs/api/errors). |
| `error.message` | string | A sentence for a person. |
| `error.param` | string | The parameter at fault, when there is one. |
| `error.request_id` | string | Quote it to support. Also in the `X-Request-Id` header. |

Example:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "Choose a supported video length.",
    "param": "duration_seconds",
    "request_id": "2f0c3e5a-7c1d-4a8e-9b6f-0d2e4c6a8b10"
  }
}
```

## Error types

| Type | Status | What to do |
|---|---|---|
| `authentication_error` | 401 | The API key is missing, malformed, revoked, or no longer allowed to act for the brand. |
| `permission_error` | 403 | The key is valid but may not do this (a read-only key writing, an unverified email paying, a spending limit). |
| `not_found_error` | 404 | The object does not exist or does not belong to your brand. |
| `invalid_request_error` | 400 | The request is malformed, a parameter is invalid, or the object is in a state that does not allow the action (400, 409, 413 or 422). |
| `payment_error` | 402 | The brand does not have enough credits for this order. |
| `rate_limit_error` | 429 | Too many requests with this key. Wait for the number of seconds in Retry-After. |
| `api_error` | 500 | Something went wrong on Besday’s side. Safe to retry with the same Idempotency-Key. |

## Error codes

| Code | Status | Meaning |
|---|---|---|
| `api_key_missing` | 401 | No `Authorization: Bearer` header was sent. |
| `api_key_invalid` | 401 | The key is malformed, unknown or revoked, or its team member, brand or account is no longer active. |
| `insufficient_scope` | 403 | A `read` key tried to change something. Create a `read_write` key. |
| `email_unverified` | 403 | The key’s team member has not verified their email address, which Besday requires before paying. |
| `member_limit` | 403 | Paying would pass the monthly spending limit the brand owner set for this team member. |
| `credits_blocked` | 423 | Spending is paused on this brand’s credits. Contact Besday support. |
| `not_found` | 404 | No such object for your brand. |
| `route_not_found` | 404 | No such endpoint. Check the method and path against the reference. |
| `invalid_json` | 400 | The body is not valid JSON. |
| `parameter_invalid` | 422 | A parameter is missing or invalid; `param` names it. |
| `order_state` | 409 | The order is not in a status that allows this action. |
| `already_paid` | 409 | The order is already paid. |
| `creator_unavailable` | 409 | The creator is not taking new orders right now. |
| `download_locked` | 403 | Originals of a real creator’s order unlock when you approve the delivery; the watermarked preview is available before. |
| `idempotency_key_reused` | 409 | This Idempotency-Key was already used with a different request. |
| `idempotency_in_progress` | 409 | A request with this Idempotency-Key is still being processed. Retry in a second. |
| `limit_reached` | 409 | The brand already has the most objects of this kind allowed (for example 5 webhook endpoints). |
| `url_not_allowed` | 422 | A webhook URL must be https on port 443 and resolve only to public internet addresses. |
| `insufficient_credits` | 402 | The order costs more credits than the brand has. The error carries the shortfall and a link to buy credits. |
| `rate_limited` | 429 | Too many requests. Retry after the seconds in the Retry-After header. |
| `internal_error` | 500 | An unexpected error. It was logged with the request id. |

## Which errors to retry

- **Retry** `429` after `Retry-After` seconds, and `500`/`503` with exponential backoff, always with the same `Idempotency-Key`.
- **Do not retry** `400`, `401`, `403`, `404`, `409` or `422` unchanged: fix the request first.
- **402** `insufficient_credits`: buy credits (the error has `buy_credits_url` and `shortfall_credits`), then pay again.

## Validation errors

A 422 names the first bad parameter in `param` and lists every problem in `errors`:

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "Choose a supported video length.",
    "param": "duration_seconds",
    "errors": [
      {
        "param": "duration_seconds",
        "message": "Choose a supported video length."
      },
      {
        "param": "product_url",
        "message": "Enter a valid link, like https://yourbrand.com/product"
      }
    ],
    "request_id": "2f0c3e5a-7c1d-4a8e-9b6f-0d2e4c6a8b10"
  }
}
```
