# Errors

Knock uses standard HTTP response codes to indicate the success or failure of your API requests.

- `2xx` success status codes confirm that your request worked as expected.

- `4xx` error status codes indicate an error caused by incorrect or missing request information (e.g. providing an incorrect API key).

- `5xx` error status codes indicate a Knock server error.

For failed requests, the Knock API returns an `application/json` response with the following shared error structure:

```json title="Example error response"
{
  "code": "api_key_missing",
  "message": "No valid API key provided",
  "status": 401,
  "type": "authentication_error"
}
```

Branch on `code` to handle an error in your application, and use `type` to group codes into a category. The `message` may change to improve its explanation, so don't match on it. See [error codes](/api-reference/overview/error-codes) for the codes you're most likely to encounter and how to resolve each one.

A request to a path the API does not route returns JSON in a different shape, `{ "errors": { "detail": "404 Not Found" } }`. Check that the path matches an endpoint in this reference.
