# Your recent requests

`GET /requests`

Requires the `businesses` scope.

The request log: every call made with your key over the last days (7 by default), newest first, with the status it got, how long it took and the `X-Request-Id` it carried. No bodies and no headers are kept. Page back with `before` (the last row's `at`).

## Query parameters

| Name | Type | | Description |
|---|---|---|---|
| `status` | string |  | `error` = 4xx/5xx only, `ok` = 2xx/3xx only. One of: `ok`, `error`. |
| `endpoint` | string |  | One route pattern, as `GET /usage` lists them (e.g. `POST /businesses/:bid/documents`). |
| `businessId` | string |  | Only calls under one business. |
| `method` | string |  | Only calls with this HTTP method. One of: `GET`, `POST`, `PATCH`, `PUT`, `DELETE`. |
| `reason` | string |  | Only errors with this `reason` (e.g. `validation`), as `GET /errors` groups them. |
| `source` | string |  | Only calls from one kind of client (see `source` on a row). One of: `sdk`, `python`, `cli`, `curl`, `browser`, `other`. |
| `requestId` | string |  | Requests whose id starts with this (the first characters of an `X-Request-Id` are enough). |
| `before` | string |  | Time cursor: requests strictly before this instant. |
| `limit` | integer |  |  Default `50`. |

## Response

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

| Field | Type | | Description |
|---|---|---|---|
| `ok` | boolean | **required** |  |
| `requests` | array of ApiRequest | **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/requests?status=&endpoint=&businessId=" \
  -H "X-Api-Key: $KEY"
```
### Node

```node
const res = await fetch(`${BASE}/requests`, {
  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}/requests",
    headers={"X-Api-Key": KEY},
)
data = res.json()
```