# Reports

> Write a report over one or more studies, read it, download it as PDF, PowerPoint or Markdown, and share it by link.

Source: https://imario.ai/docs/api/reference/reports

Base URL `https://api.imario.ai/v1`. Each call needs a key that holds the scope shown and acts with at least the role shown ([Authentication](https://imario.ai/docs/api/authentication)). Errors are described in [API errors](https://imario.ai/docs/api/errors).

## Price a report over a set of studies

`POST /v1/reports/estimate`

**Scope** `reports:read` · **Role** any member

What a report over `study_ids` costs, before anyone commits to it.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `study_ids` | `string[]` | Yes | The studies (research run ids) the report covers, all from one study session. Up to 50 items. |

**Example**

```bash
curl https://api.imario.ai/v1/reports/estimate \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "study_ids": ["STUDY_ID"]
  }'
```

**Response**

Returns `credits` (the price of a write-up: a share of the run credits it covers, see `tier_split`, never under `minimum`), `credits_due` (what `POST /reports` without `rewrite` would charge now: 0 when `existing_report_id` names a finished report over exactly these studies, which it then opens), `per_study` run credits, the paying `balance`, `blocked` (`daily_budget_exceeded` when the workspace's API budget for today would refuse it) and `sufficient`. Test keys get the live price.

## Write a report over one or more studies

`POST /v1/reports`

**Scope** `reports:write` · **Role** any member

Start the write-up (any member, viewers included). Returns the report at once: `status` `queued` or `running` while it is written (poll `GET /reports/{id}` or subscribe to `report.completed` / `report.failed`), `completed` when a finished report over exactly these studies already existed and `rewrite` is false (opening it is free). A new write-up is charged before it starts, exactly as `POST /reports/estimate` said, and refunded if it fails; `credits.charged` is the report's net charge.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `study_ids` | `string[]` | Yes | The studies (research run ids) the report covers, all from one study session. Up to 50 items. |
| `rewrite` | `boolean` | No | Write it again even when a finished report over exactly these studies exists (a new report, charged again). Default `false`. |

**Example**

```bash
curl https://api.imario.ai/v1/reports \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "study_ids": ["STUDY_ID"]
  }'
```

## List reports, newest first

`GET /v1/reports`

**Scope** `reports:read` · **Role** any member

The workspace's reports (finished, being written, failed), without their bodies (`sections`, `findings`): retrieve one report for those. Test keys see the live reports and their own sandbox reports.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `limit` | query | `integer` | No | How many objects to return (1-100). Default `20`. |
| `cursor` | query | `string` | No | The `next_cursor` of the previous page. Up to 200 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/reports \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

**Response**

Returns a list: `{"object": "list", "data": [...], "has_more": false, "next_cursor": null}`. See [Pagination](https://imario.ai/docs/api/pagination).

## Retrieve a report

`GET /v1/reports/{report_id}`

**Scope** `reports:read` · **Role** any member

The report: `status` queued | running | completed | failed, the `study_ids` it covers, `title`, `language`, `credits.charged`, `web_url`; once completed also `summary`, `sections` (`[{title, markdown}]`, the report's chapters in order), `findings` (`[{title, implication, recommendation, priority, themes}]`), `themes`, `respondents` and `questions`. A report replaced by a wider one stays readable by its id and names it in `superseded_by`.

**Example**

```bash
curl https://api.imario.ai/v1/reports/REPORT_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

## Export a report as PDF, PowerPoint or Markdown

`POST /v1/reports/{report_id}/exports`

**Scope** `reports:write` · **Role** any member

Make a download of a finished report. Returns the export at once (`status` queued); it is made in the background with the same exporters as the report page's downloads. Poll `GET /exports/{id}` or subscribe to `export.completed`; a completed export carries `download_url`, a link valid for one hour (`expires_at`) that needs no API key. Exports cost nothing.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `format` | `string` | Yes | pdf, pptx or markdown. One of `pdf`, `pptx`, `markdown`. |

**Example**

```bash
curl https://api.imario.ai/v1/reports/REPORT_ID/exports \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "format": "pdf"
  }'
```

## Retrieve an export

`GET /v1/exports/{export_id}`

**Scope** `reports:read` · **Role** any member

`status` queued | running | completed | failed; once completed, `download_url` (valid one hour from this response, `expires_at`), `filename`, `content_type` and `size`. Ask again for a fresh link.

**Example**

```bash
curl https://api.imario.ai/v1/exports/EXPORT_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

## Create a public link to a report

`POST /v1/reports/{report_id}/share-links`

**Scope** `reports:write` · **Role** any member

A link anyone holding it can open, until `expires_at` or until it is revoked (`DELETE /share-links/{id}`). The workspace's sharing rules apply: an organization may turn public links off (`public_links_off`) or cap their length (`link_too_long`). `include_responses` decides whether the link shows every respondent's answers. Each call makes a new link.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `expires_in_days` | `integer` | No | Days the link stays open (the workspace may allow fewer). From 1 to 365. Default `7`. |
| `include_responses` | `boolean` | No | Whether the link shows the Responses and Code Book tabs (every respondent's answers). Default `true`. |

**Example**

```bash
curl https://api.imario.ai/v1/reports/REPORT_ID/share-links \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "expires_in_days": 7,
    "include_responses": false
  }'
```

## List a report's share links

`GET /v1/reports/{report_id}/share-links`

**Scope** `reports:read` · **Role** any member

Every link made to this report, newest first, with its `status` (active, expired or revoked).

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `limit` | query | `integer` | No | How many objects to return (1-100). Default `20`. |
| `cursor` | query | `string` | No | The `next_cursor` of the previous page. Up to 200 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/reports/REPORT_ID/share-links \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

**Response**

Returns a list: `{"object": "list", "data": [...], "has_more": false, "next_cursor": null}`. See [Pagination](https://imario.ai/docs/api/pagination).

## Revoke a share link

`DELETE /v1/share-links/{share_link_id}`

**Scope** `reports:write` · **Role** any member

The link stops opening the report at once. Revoking a revoked link returns it unchanged.

**Example**

```bash
curl -X DELETE https://api.imario.ai/v1/share-links/SHARE_LINK_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```
