> ## Documentation Index
> Fetch the complete documentation index at: https://docs.officehours.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> How the Office Hours API reports errors, and how to handle them.

Every error from the Office Hours API looks the same. You get a standard HTTP status code, a small JSON body, and a few headers you can rely on.

## The error body

Every error body has these four fields and nothing else.

```json theme={null}
{
  "statusCode": 404,
  "code": "NOT_FOUND",
  "message": "Resource not found",
  "requestId": "req-1a2b3c4d"
}
```

| Field | Type | Description |
| - | - | - |
| `statusCode` | integer | The HTTP status code of the response. |
| `code` | string | A stable error code from the table below. Write your logic against this field, not `message`. |
| `message` | string | A short description for people. Messages are kept generic and can change at any time. |
| `requestId` | string | A unique ID for the request. Include it when you contact support so we can find the request in our logs. |

## Status codes

The API only returns the error statuses below. Each one maps to a single error code.

| Status | Code | Meaning |
| - | - | - |
| `400` | `BAD_REQUEST` | The request is malformed or failed validation. |
| `401` | `UNAUTHENTICATED` | The API key is missing, invalid, or expired. |
| `403` | `FORBIDDEN` | Your API key doesn't have the scope this endpoint requires. |
| `404` | `NOT_FOUND` | The resource or route doesn't exist. |
| `405` | `METHOD_NOT_ALLOWED` | This route doesn't support the HTTP method. |
| `409` | `CONFLICT` | The request conflicts with the resource's current state. |
| `413` | `PAYLOAD_TOO_LARGE` | The request body exceeds the size limit. |
| `415` | `UNSUPPORTED_MEDIA_TYPE` | The request's `Content-Type` isn't supported. |
| `429` | `RATE_LIMITED` | Too many requests. Wait for the number of seconds in `Retry-After`, then retry. |
| `500` | `INTERNAL_ERROR` | Something went wrong on our side. The details are logged under the `requestId`. |
| `501` | `NOT_IMPLEMENTED` | The endpoint isn't available yet. |
| `503` | `SERVICE_UNAVAILABLE` | A service we depend on is briefly unavailable. Wait for the number of seconds in `Retry-After`, then retry. |
| `504` | `GATEWAY_TIMEOUT` | A service we depend on timed out. |

## Headers

Error responses include these headers.

| Header | When | Description |
| - | - | - |
| `X-Request-Id` | Always | Matches `requestId` in the body. |
| `Cache-Control: no-store` | Always | Error responses are never cached. |
| `WWW-Authenticate: Bearer` | `401` only | Tells the client that a bearer token is required. |
| `Retry-After` | `429` and `503` only | How many seconds to wait before you retry. |

## Validation errors

When a request fails validation, the `400` response names the invalid fields by path. It never echoes their values back.

```json theme={null}
{
  "statusCode": 400,
  "code": "BAD_REQUEST",
  "message": "Invalid request: scheduledAtStart",
  "requestId": "req-1a2b3c4d"
}
```

## Handling errors

* **`429` and `503`.** Wait for the number of seconds in `Retry-After`, then retry.
* **Other `4xx` errors.** Retrying the same request won't help. Fix the request first.
* **`500` errors.** Note the `requestId` and send it to your Office Hours representative so we can trace the failure.

Here's what a `404` looks like in full.

```bash theme={null}
curl -i https://api.officehours.com/v0/consultations/does-not-exist \
  -H "Authorization: Bearer $OFFICEHOURS_API_KEY"
```

```text theme={null}
HTTP/1.1 404 Not Found
X-Request-Id: req-1a2b3c4d
Cache-Control: no-store
Content-Type: application/json; charset=utf-8

{"statusCode":404,"code":"NOT_FOUND","message":"Resource not found","requestId":"req-1a2b3c4d"}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.