# Your errors, grouped by reason

`GET /errors`

Requires the `businesses` scope.

Every 4xx/5xx your key got over the window, grouped by `reason`: how many, when first and last, the endpoints they hit, a day-by-day series (Israel days), the newest request id to open with `GET /requests/{requestId}`, and the guide for the reason. The window is what the request log still holds (7 days by default).

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `days` | integer |  | Window in days, up to what the request log holds. Default `7`. |

## Response

`200`: `{ "ok": true, … }`

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `days` | integer | **required** | The window answered. |
| `total` | integer | **required** | Errors in the window. |
| `errors` | array of object | **required** |  |

Errors: `400`, `401`, `403`, `404`, `429`. Every failure answers `{ "error", "reason", "hint", "param", "doc_url", "retryable", "request_id" }`: branch on `reason`, and read `hint` for what to change (https://docs.billos.co.il/errors.md).

## Examples

### cURL

```bash
curl -X GET "$BASE/errors?days=" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/errors`, {
  method: 'GET',
  headers: {
    'X-Api-Key': KEY,
  },
})
const data = await res.json()
if (!data.ok) throw new Error(data.reason)
```
### Python

```python
import requests
res = requests.get(
    f"{BASE}/errors",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```