# Errors

Every error response has a JSON body with a stable `code` and a `message` for people, and the status tells you whether a retry can help.

## Error body

```json
{
  "error": {
    "code": "rate_limited_per_minute",
    "message": "This organization has reached its per-minute limit."
  }
}
```

Branch on `error.code`. The `message` is a plain sentence that can change, so show it to people or log it, but don't parse it.

Some errors also carry a header. A `401` has `WWW-Authenticate: Bearer`, a `405` has `Allow: POST`, and a `429`, a `402` with `credit_limit_reached`, or a `503` with `server_busy` has `Retry-After` in whole seconds.

Every response from `POST /v1/sign` and `POST /v1/validate`, success or error, carries `X-Request-Id`. It is the id of that request in Lens Proof's own record, so quote it when you ask about a request. The record holds no file data. A `402` or `429` from signing also carries the `X-Lens-*` headers that show where your organization stands against its limits, described in [Limits](/docs/limits#response-headers).

## Error codes

| Status | Code | Meaning | What to do |
| --- | --- | --- | --- |
| 400 | `unsupported_request` | The request has a query string or a header outside the accepted list. | Send only the file and the accepted headers, as listed in [Headers](/docs/reference#headers). |
| 400 | `invalid_ai_disclosure` | `X-Lens-AI-Source` or `X-Lens-AI-Oversight` has an unsupported value, or `X-Lens-AI-Oversight` was sent without `X-Lens-AI-Source`. | Use the supported AI disclosure header values in [Headers](/docs/reference#headers), or omit both headers. |
| 400 | `ai_disclosure_required` | The API key requires an AI disclosure policy, and `X-Lens-AI-Source` was omitted. | Send `X-Lens-AI-Source`, or use a key whose policy does not require AI disclosure. |
| 400 | `ai_disclosure_locked` | The API key locks AI disclosure to configured values, and the request sent a conflicting AI disclosure header. | Omit the AI disclosure headers to apply the key's locked values, or send headers that match the key's policy. |
| 400 | `unrecognized_file` | The body is not a file of any supported media type. | Send the raw bytes of the file, not a form upload, base64 text, JSON, or the file's path. With curl, put `@` before the path, as in `--data-binary @photo.jpg`. |
| 401 | `unauthorized` | The key is missing, malformed, unknown, or wrong. | Check the `Authorization` header and the key. A retry with the same key gets the same answer. |
| 402 | `insufficient_credits` | Your trial organization has used all of its starter signatures. | [Contact sales](https://lensproof.app/contact-sales) for more API access. |
| 402 | `credit_limit_reached` | Your organization reached its monthly credit limit. Signing resumes at 00:00 UTC on the first day of the next month. | Do not retry before then. `Retry-After` is the number of seconds until the count starts again. An admin can ask for a higher limit in the developer console, or [contact sales](https://lensproof.app/contact-sales). The refused request does not count. |
| 402 | `billing_hold` | Signing is on hold for your organization. The `message` says whether Lens Proof put the hold on, or an invoice is past due, and when an invoice holds signing it names the invoice number. Your keys are kept. | Pay the invoice the message names, quoting its number as the payment reference, or [contact sales](https://lensproof.app/contact-sales). An organization admin can find the invoice in the developer console, under Billing. Signing resumes on the same keys when the hold ends. Validation is not held. |
| 403 | `origin_not_allowed` | The request has an `Origin` header, which browsers send. | Call the API from your server, not from a web page. |
| 403 | `key_revoked` | The key was revoked. | Use another key, or ask an organization admin to create one in the developer console. |
| 403 | `key_expired` | The key has expired. | Use another key, or ask an organization admin to rotate it or create one in the developer console. |
| 403 | `customer_paused` | API access is not open for your organization: it is paused, or not approved yet. | [Contact sales](https://lensproof.app/contact-sales). |
| 404 | `not_found` | The API is not enabled on this host. | Check that the URL is `https://sign-api.lensproof.app/v1/sign` or `https://sign-api.lensproof.app/v1/validate`. |
| 405 | `method_not_allowed` | The method is not `POST`. | Send a `POST` request. |
| 413 | `file_too_large` | The file is larger than the cap for its type: 10 MB, or 30 MB for a video (32 MB when you validate one). | Send a file within that cap. See [Limits](/docs/limits). |
| 415 | `unsupported_media_type` | The `Content-Type` is missing or is not a supported media type. | Set `Content-Type` to one of the [supported media types](/docs/media-types). |
| 415 | `type_mismatch` | The bytes of the file are not the type that `Content-Type` names. | The message names the type the bytes turned out to be. Send the file again with `Content-Type` set to that type. The file's name plays no part. |
| 422 | `unreadable_file` | The file sent to `POST /v1/sign` is the type it declares, but it could not be read for signing. It may be damaged or incomplete, for example a video cut off partway, or built in a way that is not supported. | A retry gets the same answer. Check that the file opens, or export it again, then send the new file. |
| 422 | `no_credentials` | The file sent to [`POST /v1/validate`](/docs/validate) has no Content Credentials. | Nothing to validate. Send a file that carries Content Credentials. |
| 422 | `manifest_unreadable` | The file sent to `POST /v1/validate` has Content Credentials that could not be read. | The Content Credentials are damaged or not in a form the validator reads. A retry gets the same answer. |
| 422 | `remote_manifest_not_fetched` | The file sent to `POST /v1/validate` points to Content Credentials stored elsewhere. | The API does not fetch them. Validate a file with Content Credentials embedded in it. |
| 422 | `report_too_large` | The validation report would be larger than 16 MB. | A retry gets the same answer. Contact Lens Proof if you need this file validated. |
| 429 | `rate_limited_per_minute` | Your organization reached its limit for this minute. | Wait the number of seconds in `Retry-After`, then retry. |
| 429 | `rate_limited_per_day` | Your organization reached its limit for this UTC day. | Wait the number of seconds in `Retry-After`, then retry. |
| 429 | `trial_daily_cap` | Starter signing reached its daily capacity across all trial accounts. | Wait the number of seconds in `Retry-After`, or [contact sales](https://lensproof.app/contact-sales) for more API access. |
| 500 | `internal_error` | The API hit an error it did not expect. | Retry with backoff, and contact Lens Proof if it keeps happening. |
| 502 | `signing_failed` | Signing failed, and no file was returned. | Retry with backoff, and contact Lens Proof if it keeps happening. |
| 502 | `validation_failed` | Validation failed, and no report was returned. | Retry with backoff, and contact Lens Proof if it keeps happening. |
| 503 | `service_unavailable` | Signing or validation is not available right now. | Retry with backoff. |
| 503 | `server_busy` | The server is already signing or validating as many files as it can. | Wait the number of seconds in `Retry-After`, then retry. |
| 504 | `validation_timeout` | Validation took longer than 30 seconds, and no report was returned. | Retry once. A file that times out again is likely to keep timing out. |

[Limits](/docs/limits#retries) explains which errors count toward your rate limits and how to retry. Requests to `POST /v1/validate` have their own limit, described in [Limits](/docs/limits#validation).
