# Errors

> Every error code the API answers, what it means and what to do next. Each error's `docs_url` links to its section here.

Base URL: `https://api.checksharecode.co.uk` · Auth: `authorization: Bearer <key>` · Web version: https://checksharecode.co.uk/docs/errors · Sign up: https://checksharecode.co.uk/signup?ref=md

## The error body

The API answers an error with JSON holding an `error` object. Switch on `code`: it and the HTTP status are the contract. `message` is written for a person and may change.

400 Bad Request:

```json
{
  "error": {
    "code": "INVALID_INPUT",
    "message": "date_of_birth must be YYYY-MM-DD",
    "field": "date_of_birth",
    "docs_url": "https://checksharecode.co.uk/docs/errors#invalid-input",
    "request_id": "req_5f2a8c1e9b7d4a6f"
  },
  "mode": "test"
}
```

| Field | When | Meaning |
| --- | --- | --- |
| code | Always | One of the codes below. |
| message | Always | What went wrong and what to do next, for a person. |
| docs_url | Every code below | This page, at the code's section. |
| field | `INVALID_INPUT` | The request field the refusal is about, when it is about one field. |
| request_id | The check endpoints | The request's id, also its `X-Request-Id` header. Give it to support. |
| check_code_used | Driving licence checks | Whether DVLA or DVA saw the check code. What to do for each value is under Responses, errors and limits. |
| first_check | `CHECK_CODE_ALREADY_USED` | The earlier check that sent the code. |
| upgrade_url, add_card_url | `QUOTA_EXCEEDED`, `PAYMENT_REQUIRED` | Where a person changes plan, or adds a card for extra checks on Free. |
| claim_url, upgrade_urls | Unclaimed agent keys | What the agent gives its user, so they claim the account. See Build with an agent. |

Beside `error`, a check endpoint's error carries `mode` once the key was read, as its results do: `test` for a sandbox key. A sandbox answer is never a real person's.

## INVALID_INPUT

**HTTP 400.** Fix the field named in `field` (and in `message`). Don't retry as is. The management API answers `409` with this code for a change that conflicts, such as a key revoking itself.

## UNAUTHENTICATED

**HTTP 401.** No API key reached us: the `Authorization` header is missing or isn't `Bearer <your API key>`. Keys are at https://checksharecode.co.uk/app/keys. Don't retry as is.

## INVALID_KEY

**HTTP 401.** We don't know this key: it was cut off when copied, revoked or rolled, or is the hidden key a team member sees. `message` says which. Copy it again from https://checksharecode.co.uk/app/keys. The agent routes also answer `403` or `409` with this code, saying why. Don't retry as is.

## QUOTA_EXCEEDED

**HTTP 402.** The Free plan's free live checks are used up. Send the person who manages billing to `upgrade_url` (the plans) or `add_card_url` (a card for extra checks on Free). An unclaimed agent's live key gets a payment challenge and `claim_url` instead: see Build with an agent.

## PAYMENT_REQUIRED

**HTTP 402.** The subscription is past due. Send the person who manages billing to `upgrade_url` to settle the latest invoice; checks run again once it is paid.

## PERMISSION_DENIED

**HTTP 403.** This key can read this but not change it: an unclaimed agent's live key. Give your user `claim_url`; once they claim the account, its keys can make changes.

## NOT_FOUND

**HTTP 404.** gov.uk has no record matching this share code and date of birth together. Either could be wrong, or the code has expired: gov.uk says a code has expired only the first time it is checked with the right date of birth, and "Details do not match our records" every time after (and for a wrong date of birth). Ask the applicant to check both, or for a new code if it's more than 90 days old. For an SIA licence check: the SIA register has no licence with that number, so check the 16 digits against the front of the licence card.

## CHECK_NOT_FOUND

**HTTP 404.** No asynchronous check with that id for this key's account and mode: a sandbox key can't read a live check, or the other way round. Use the id from the `Location` the check gave you.

## RESOURCE_NOT_FOUND

**HTTP 404.** The management API has no key, webhook delivery or team member with that id in this key's account and mode. List them first to get the id.

## ENDPOINT_NOT_FOUND

**HTTP 404.** No endpoint at that method and path on api.checksharecode.co.uk. Its paths start /v1/: see https://api.checksharecode.co.uk/openapi.json. Not `NOT_FOUND`, which means gov.uk has no record.

## CHECK_CODE_ALREADY_USED

**HTTP 409.** Driving licence only. Your account sent this licence number and check code in the last 21 days, and a code works once, so it was not sent to DVLA again and is not charged. `first_check` names the earlier check: its asynchronous id (`chk_…`), which you can read back, or its request id. Otherwise ask the driver for a new code.

## SHARE_CODE_UNUSABLE

**HTTP 422.** gov.uk won't use this share code for this check, for example a status code (it starts with S) sent to right to work, or an expired code on its first check. Ask them for a new one. Counts as a check, like `NOT_FOUND`, and is not retried.

## CHECK_CODE_UNUSABLE

**HTTP 422.** Driving licence only. DVLA did not accept the licence number and check code: the number is wrong, or the code is wrong, expired, used or cancelled. DVLA does not say which. DVLA may also answer that it couldn't display the licence details with the information given: most likely its lock-out page, when DVLA briefly pauses checks after failed attempts (the pauses seen so far cleared within about a minute). Then `check_code_used` is `true`: check the licence number, and send a new code after a minute. Ask the driver to check their licence number and make a new code. Counts as a check, 2 of your allowance, and is not retried.

## RATE_LIMITED

**HTTP 429.** Too many requests. Wait the `Retry-After` seconds, then retry.

## INTERNAL

**HTTP 500.** Our fault. Retry once, then contact us with the `request_id` (or `X-Request-Id` header) if it has one.

## GOVUK_UNEXPECTED

**HTTP 502.** gov.uk, DVLA or the SIA register returned a page we didn't expect. Retry later. For a driving licence, only when `check_code_used` is `false`.

## BUSY

**HTTP 503.** All check slots in use, or (driving licence) DVLA briefly pauses checks after failed attempts: we hold your account's licence checks for up to 75 seconds after one of its codes is refused, and every account's while DVLA shows its lock-out page, and nothing is sent. Either way the check didn't run, isn't charged, and a licence check's code is unused (`check_code_used` is `false`). Retry the same request after the `Retry-After` seconds.

## TIMEOUT

**HTTP 504.** gov.uk or DVLA was too slow. Safe to retry, except a driving licence whose `check_code_used` is not `false`.

See also: [Responses, errors and limits](https://checksharecode.co.uk/docs/api/check.md) · [Asynchronous checks](https://checksharecode.co.uk/docs/api/check-async.md)
