# Reports API

Source: https://aicallstudio.com/docs/api/reports. Authentication, scopes, limits, errors and webhooks: https://aicallstudio.com/docs/api

### List saved reports

`GET /api/v1/reports` (scope `reports:read`)

Your saved custom reports and dashboards (Reports -> Custom): the ones shared with the workspace and the key creator's own. Archived ones are left out. Use an id to run one.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `kind` | string, or null, in the query | Only reports, or only dashboards. |

**Answer (200): these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `data` (required) | list of objects | — |
| `data[].id` (required) | string (uuid) | — |
| `data[].name` (required) | string | — |
| `data[].kind` (required) | string | report or dashboard. |
| `data[].source` | string, or null | What a report counts (calls, messages and so on), in words. |
| `data[].shared` (required) | boolean | Shared with the workspace, or kept by the key's owner. |
| `data[].updated_at` | string (date-time), or null | — |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |

```bash
curl "https://aicallstudio.com/api/v1/reports" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN"
```

### Run a saved report

`GET /api/v1/reports/{report_id}/run` (scope `reports:read`)

Run a saved custom report or dashboard now and get its figures, exactly as the Custom reports screen would show them to the key's owner. A report comes as JSON or CSV; a dashboard as JSON. Each run is a real query, capped at 10 seconds, and a key may run 30 a minute.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `report_id` (required) | string (uuid), in the path | — |
| `format` | string, in the query | json, or csv for a report's table. Default: json. |

**Answer (200): these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `id` (required) | string (uuid) | — |
| `name` (required) | string | — |
| `kind` (required) | string | — |
| `result` | object, or null | A report: its columns, rows, totals and range, as the Custom reports screen shows them. |
| `pages` | list of object, or null | A dashboard: each page with its widgets' figures. |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `404` | No saved report of yours has this id. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |
| `503` | Reports are switched off on the platform for now. |

```bash
curl "https://aicallstudio.com/api/v1/reports/YOUR_REPORT_ID/run?format=csv" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN" \
  -o contacts.csv
```
