# Reports

> Saved reports (D345), run on the data as it is now.

| Operation | Method and path | Scope |
|---|---|---|
| [List saved reports](https://docs.kaizenaflow.com/reference/admin-api/reports#reports-list) | `GET /reports` | [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read) |
| [Run a saved report](https://docs.kaizenaflow.com/reference/admin-api/reports#reports-run) | `GET /reports/{id}/run` | [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read) |

## List saved reports {#reports-list}

`GET https://kaizenaflow.com/api/admin/v1/reports`

The store's saved reports (D345), by name, each saying whether it can run as saved.

- **Operation:** `reports.list`
- **Scope:** [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read)
- **Answers:** `200`, the answer under `data`.

### Query parameters {#reports-list-query}

| Name | Type | Required | Description |
|---|---|---|---|
| `updated_after` | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |

### Answer {#reports-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].title` | string |   |
| `data[].runs` | boolean | Its spec can run as saved. |
| `data[].updated_at` | string (date-time) |   |

### Errors {#reports-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#reports-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/reports' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/reports", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/reports",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Run a saved report {#reports-run}

`GET https://kaizenaflow.com/api/admin/v1/reports/{id}/run`

Runs the saved report on the data as it is now, as the Reports page runs it: its rows and totals in the main currency, without VAT. Nothing is written.

- **Operation:** `reports.run`
- **Scope:** [`reports:read`](https://docs.kaizenaflow.com/reference/scopes#reports-read)
- **Answers:** `200`, the answer under `data`.

### Path parameters {#reports-run-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#reports-run-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.report_id` | string (uuid) |   |
| `data.title` | string |   |
| `data.currency` | string | The main currency every amount is in, without VAT. |
| `data.columns` | list of objects |   |
| `data.columns[].metric` | string |   |
| `data.columns[].adds_up` | boolean |   |
| `data.rows` | list of objects |   |
| `data.rows[].keys` | any |   |
| `data.rows[].values` | map of string to number or null |   |
| `data.rows[].previous` | map of string to number or null or null |   |
| `data.rows[].rest` | boolean |   |
| `data.totals` | object |   |
| `data.totals.values` | map of string to number or null |   |
| `data.totals.previous` | map of string to number or null or null |   |
| `data.hidden_rows` | integer |   |
| `data.period` | any | The period it covers, as the report builder states it. |

### Errors {#reports-run-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#reports-run-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/reports/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/run' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/reports/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/run", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/reports/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/run",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/reports · made from the API contract 1.57
