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

# Errors & status codes

> The error format, HTTP status codes, and common error responses for the Ornn Data API.

## Error format

Errors return a JSON body with an `error` label and a human-readable `message`:

```json theme={null}
{
  "error": "Bad request",
  "message": "Invalid GPU type. Allowed: H100 SXM, H200, A100 SXM4, RTX 5090, B200, RTX PRO 6000 WS"
}
```

## Status codes

| Status | Meaning                                                                                                                           |
| ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `200`  | Success.                                                                                                                          |
| `400`  | Bad request: a missing or invalid parameter.                                                                                      |
| `401`  | Unauthorized: missing, malformed, invalid, or revoked API key.                                                                    |
| `403`  | Forbidden: the request is authenticated but not allowed. Currently only returned when a trial account tries to create an API key. |
| `404`  | Not found: no data for the requested parameters.                                                                                  |
| `429`  | Too many requests. See [Rate limits](/docs/rate-limits).                                                                               |
| `500`  | Internal server error.                                                                                                            |
| `503`  | Service unavailable (e.g. `/health` when the database is unreachable).                                                            |

## Common errors

### 401: Missing key

```json theme={null}
{
  "error": "Unauthorized",
  "message": "API key required. Use Authorization: Bearer YOUR_API_KEY"
}
```

### 401: Invalid or revoked key

```json theme={null}
{ "error": "Unauthorized", "message": "Invalid API key" }
```

```json theme={null}
{ "error": "Unauthorized", "message": "API key is inactive" }
```

### 403: Trial account

Trial accounts cannot create API keys. `POST /api/create-api-key` returns:

```json theme={null}
{ "success": false, "error": "API keys are not available on trial accounts" }
```

See [Manage API keys](/docs/manage-api-keys) for details.

### 400: Unknown GPU

```json theme={null}
{
  "error": "Bad request",
  "message": "Invalid GPU type. Allowed: H100 SXM, H200, A100 SXM4, RTX 5090, B200, RTX PRO 6000 WS"
}
```

### 400: Missing required parameter

```json theme={null}
{
  "error": "Bad request",
  "message": "datetime query parameter is required (format: YYYY-MM-DD HH:MM:SS or ISO 8601)"
}
```

### 404: No data

```json theme={null}
{ "error": "No data available", "message": "No daily index data found for H100 SXM" }
```

<Note>
  Endpoints that return the **nearest** record, such as [`/api/gpu/{gpuName}/history`](/docs/api-reference/historical-prices/get-index-value-nearest-a-timestamp), won't 404 for an out-of-range timestamp. They return the closest match and report the gap in `time_difference`.
</Note>

## Handling errors

Always check the HTTP status before reading the body.

```python theme={null}
import requests

resp = requests.get(
    "https://api.ornnai.com/api/gpu/H100 SXM",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
)
if not resp.ok:
    err = resp.json()
    raise RuntimeError(f"{resp.status_code}: {err.get('message', err.get('error'))}")

data = resp.json()["data"]
```
