# Errors and Status Codes

| Status | Meaning | What to do |
|---|---|---|
| `400` | The request path or body is malformed. | Fix the request. |
| `401` | Missing, malformed or unknown API key. | Send `Authorization: Bearer <key>`. Check you are using the right environment's key. |
| `402` | `POST /v1-preview/jobs/{jobId}/submit` only: the account has used its monthly credit cap. | Do not retry. Ask GoSmarter to raise the cap, or wait for the next UTC month. See [Billing and usage](/billing). |
| `403` | The key is valid but the account is `Suspended` or `Closed`, **or** the key is not correctly configured (for example its mode does not match its account; the message says "This API key is not correctly configured"). | Contact GoSmarter. Do not retry. |
| `404` | No such route (only the documented paths exist), or no such job for your account. | Check the path (it starts with `/v1-preview/`) and the job id. |
| `405` | The method is not supported on that route. | Use the method shown in the API reference. |
| `409` | The request conflicts with the job's state: no file uploaded yet when you submit, the result requested before the job finished, an `Idempotency-Key` reused with different parameters or for a deleted job, a submit already being processed, or the uploaded file changing while it was checked. | Read the `error` message. Upload the file first (and let the upload finish), poll until the job is terminal, or use a new key; if a submit is in progress, call it again shortly. |
| `413` | The request body is too large for this gateway, or the uploaded file is larger than the account limit (on submit). | Certificate PDFs are never sent through the API gateway; see [Rate limits and size limits](/rate-limits) and [Jobs and results](/jobs). |
| `422` | On submit: the upload is not a readable PDF, or it is over the page cap. The job ends as `failed`. | Create a new job with a valid file. |
| `429` | A gateway rate limit or an account limit (jobs per hour, day or month, jobs in progress, jobs waiting for a file) was reached. | Wait for the `Retry-After` header (seconds), then retry with backoff. Submit or delete waiting jobs if that is the limit. |
| `500` | The gateway is misconfigured, or could not check its rate limit, and refused to forward your request. | Retry later and contact GoSmarter if it persists. |
| `502` | The service answered in a way the gateway does not accept. | Retry; contact GoSmarter if it persists. |
| `503` | The service could not reach its database, could not be reached by the gateway, timed out, could not issue an upload URL, or every upload-validation slot was busy. | Retry with exponential backoff. If you submitted, call submit again: it is safe to repeat. If you were creating a job, send an `Idempotency-Key` and retry with the same one. |

Webhook routes (see [Webhooks](/webhooks)) use the same codes: `400` for a `url` that is not `https`, not on port 443, carries credentials, or whose host is or resolves to a private, loopback, link-local or other non-public address, and for an unknown event name; `404` for an endpoint that does not exist for your account; `409` when the account already has five endpoints (delete one first) or an endpoint changed while you were rotating its secret (retry). Retiring a previous secret that is already gone is safe and returns `200`.

## PDF export errors

`GET /v1-preview/jobs/{id}/pdf` ([PDF exports](/pdf-exports)) puts a stable code at the start of the `error` message:

| Status | Code | Meaning |
|---|---|---|
| `400` | | `groupBy` is missing or unknown, or `heat` was used without `groupBy=heat`. |
| `404` | | No such job for your account, or `heat` is not in the result. |
| `409` | | The job has not finished, or has no completed certificate. |
| `410` | `pdf_export_source_expired` | The source PDFs are no longer stored (kept 7 days). The JSON result is still available. |
| `413` | `pdf_export_size_limit` | The export would be larger than 200 MiB. Use `heat=` or `groupBy=certificate`. |
| `422` | `pdf_export_heat_limit` | One certificate lists more than 200 heats. |
| `422` | `pdf_export_page_limit` | The export would hold more than 2000 pages (a page shared by several heats counts in each). |
| `422` | `pdf_export_heat_has_no_pages` | `heat` is in the result but has no page numbers, so it has no PDF. |
| `503` | | Too many exports are being prepared; retry after the `Retry-After` seconds. |

Errors come back as JSON. Service errors on a job that does not belong to your account are `404` (the same as a job that does not exist). Gateway errors use the `application/problem+json` shape (`title`, `status`, optional `detail`); service errors carry an `error` message. Parse the HTTP status first and treat the body as human-readable text.
