# Errors

The shape of every TimeSubmit API error, and each error code with its HTTP status and what it means.

## The error shape

An error answers with its HTTP status and the same shape every time. Branch on `code`, which does not change. `message` is written for people and names the parameter or field that is wrong.

```json
{
  "error": {
    "code": "invalid_request",
    "message": "paymentTermDays must be a number of days."
  }
}
```

## Error codes

| Code | Status | When |
| --- | --- | --- |
| `unauthorised` | 401 | No key, or one that is unknown, revoked or expired. Every case answers the same. |
| `api_not_included` | 403 | Your plan does not include the API. Keys work again when it does. |
| `insufficient_scope` | 403 | The key does not have the scope this operation needs. |
| `read_only` | 403 | Your organisation is read-only, so writes are refused. Reads still work. |
| `client_limit_reached` | 403 | Your plan's client limit is reached. |
| `project_limit_reached` | 403 | Your plan's project limit is reached. |
| `not_on_plan` | 403 | The request needs a feature your plan does not include, such as purchase orders. |
| `not_found` | 404 | No record has this id in your organisation. Another organisation's record answers the same. Also the answer to a method and path that is not an operation. |
| `invalid_request` | 400 | A parameter or a body field breaks a rule; the message names it. |
| `already_exists` | 409 | The record already exists, such as a second assignment of the same pair. |
| `idempotency_conflict` | 409 | This Idempotency-Key was used in the last day with a different request. |
| `rate_limited` | 429 | The key has used its allowance. Retry-After says when to try again. |
| `unreadable_invoice` | 500 | An old invoice whose lines and total disagree. Contact support. |
| `gone` | 410 | This version of the API has been retired. Move to the version the versioning page names. |

For `unauthorised` and `insufficient_scope`, see [authentication](https://www.timesubmit.com/developers/authentication) for keys and scopes. A 429 `rate_limited` answer carries a `Retry-After` header: see [rate limits](https://www.timesubmit.com/developers/rate-limits).
