# Auto Studies

> Give iMario a goal: it plans the research, runs the studies and writes the report, within a budget you set.

Source: https://imario.ai/docs/api/reference/auto-studies

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).

## Start an auto study

`POST /v1/auto-studies`

**Scope** `auto:write` · **Role** editor or above

Starts a study that plans its own research, runs it and writes the report. Spends over time, up to `budget_credits`, from the key's payer; a workspace with an API daily budget has the whole budget claimed against today's at once (402 `daily_budget_exceeded` when it does not fit). Needs `auto:write` and the editor role.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `goal` | `string` | Yes | What the study should find out, in plain words. 8 to 4,000 characters. |
| `audience_ids` | `string[]` | No | Audiences to ask (GET /audiences). Optional: without one the study defines its own. Up to 8 items. |
| `markets` | `string[]` | No | Countries the study is about, e.g. ["United States"]. Up to 4 items. |
| `budget_credits` | `integer` | No | The most the study may spend. Maximum: the platform's Auto ceiling. Default: that ceiling, or what remains of the workspace's API daily budget today when less. At least 50. |
| `file_ids` | `string[]` | No | Documents (up to 6) and images (up to 3) from /files the study reads as material. Up to 9 items. |
| `page_url` | `string` | No | A web page the study may show people. Up to 2,048 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/auto-studies \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "goal": "Find out which of our three onboarding emails gets new users to finish setup, and why",
    "audience_ids": ["AUDIENCE_ID"],
    "budget_credits": 800
  }'
```

**Response**

An `auto_study` object:

- `id` (the study's conversation), `livemode`, `created_at`, `goal`
- `status`: `planning` | `running` | `paused` | `stopping` | `completed` | `failed` | `stopped`
- `paused_reason` (why it paused, e.g. `insufficient_credits`) and `can_continue` (whether Continue would go on now) while `paused`
- `outcome`: how it ended (`completed`, or why it stopped early), once it has
- `plan`: `{decision, objectives, audiences: [{id, name, size, ready}], planned_runs}`
- `markets`, `guidance` (the notes sent so far)
- `runs`: `[{study_id, kind, status, created_at}]` (each a study: GET /studies/\{study_id\})
- `hypotheses`: `[{id, statement, verdict}]` (verdict `untested` until a run tested it)
- `answer`: the study's answer to its goal, once it has one
- `credits`: `{budget, spent}`
- `report_id` (GET /reports/\{report_id\}) once the write-up exists, `finished_at`, `web_url`

Events: `auto_study.paused`; `auto_study.completed` when the study ends (its `status` says how).

## List auto studies

`GET /v1/auto-studies`

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

Newest first.

**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/auto-studies \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

**Response**

Returns the object described under [Start an auto study](https://imario.ai/docs/api/reference/auto-studies#start-an-auto-study).

Events: `auto_study.paused`; `auto_study.completed` when the study ends (its `status` says how).

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

## Retrieve an auto study

`GET /v1/auto-studies/{id}`

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

**Example**

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

**Response**

Returns the object described under [Start an auto study](https://imario.ai/docs/api/reference/auto-studies#start-an-auto-study).

Events: `auto_study.paused`; `auto_study.completed` when the study ends (its `status` says how).

## Send the study a note

`POST /v1/auto-studies/{id}/guidance`

**Scope** `auto:write` · **Role** editor or above

A note the study's director reads before its next decision (as a message typed while a study runs in the web app). 409 `auto_study_not_live` once it has ended.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `text` | `string` | Yes | A note for the study's director. Up to 1,000 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/auto-studies/AUTO_STUDY_ID/guidance \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Focus on people who signed up on a phone."
  }'
```

## Stop an auto study

`POST /v1/auto-studies/{id}/stop`

**Scope** `auto:write` · **Role** editor or above

Stops the study after the run in progress; the report is written on what it has (and paid like any report). A study that has already ended is returned as it is. Allowed to the member who started it, or an editor or above when the workspace's pool pays.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `reason` | `string` | No | Up to 300 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/auto-studies/AUTO_STUDY_ID/stop \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "reason": "We have what we need."
  }'
```

## Continue a paused auto study

`POST /v1/auto-studies/{id}/continue`

**Scope** `auto:write` · **Role** editor or above

A study pauses when its payer cannot cover the next run; it goes on only when Continue is sent (credits landing alone never restart it). 409 `auto_study_not_paused` when it is not paused; 402 `insufficient_credits` while the wallet still cannot pay for the step it paused on.

**Example**

```bash
curl -X POST https://api.imario.ai/v1/auto-studies/AUTO_STUDY_ID/continue \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```
