# Errors

Find out why a request failed from its status code and the message in the response.

HTML version: https://t.momentic.studio/docs/api/errors

## Status codes

| Code | When                                                                                                                                                                                                                                                                                                                  |
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 200  | The request worked. A DELETE returns no body.                                                                                                                                                                                                                                                                         |
| 201  | A record was created. The body is the record.                                                                                                                                                                                                                                                                         |
| 400  | No User-Agent header; no account id; a bad page, per_page, date or updated_since; a report without from or to, or over one year; a body that is not JSON (an HTML page, as in Harvest).                                                                                                                               |
| 401  | Bearer with a token that is empty, expired, revoked or not valid, or a token sent in the URL where that is not accepted.                                                                                                                                                                                              |
| 403  | The token lacks the scope, or the person's role may not do this.                                                                                                                                                                                                                                                      |
| 404  | No Bearer credentials (an empty body, as in Harvest); no record with that id that the person can read (an id of another workspace too); an account id that is not the token's workspace (plain text: No such account.); an unknown path, or a path with a method it does not take (an HTML page: Harvest has no 405). |
| 413  | The body is over 256 KB.                                                                                                                                                                                                                                                                                              |
| 422  | The request was read but refused: a missing or invalid field, a closed month, an archived project, a task that is not on the project, an endpoint this app does not support.                                                                                                                                          |
| 429  | Over a rate limit. Wait the seconds in Retry-After.                                                                                                                                                                                                                                                                   |
| 500  | The server failed. Retry later.                                                                                                                                                                                                                                                                                       |

## Body

The bodies are Harvest's, checked against the real Harvest API. A 400 or 422 has message only, worded as Harvest words it where Harvest has the same error, such as Name can't be blank or Invalid from date provided: "notadate". Several missing fields are listed in one message, separated by commas.

```json
{
  "message": "Project can't be blank, Task can't be blank, Spent date can't be blank"
}
```

A 404 for a record has status and error, without a message:

```json
{
  "status": 404,
  "error": "Not Found"
}
```

A 401 has error and error_description. A request without an account id is a 400 with error bad_request and error_description Harvest-Account-Id header required. A 403, 413, 429 or 500 has status, error and message, where message says what to change.
