# Studies

> Price and run a study, follow it, read its results and responses, and ask for the AI read of a group.

Source: https://imario.ai/docs/api/reference/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).

## Price a study

`POST /v1/studies/estimate`

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

Price a study without running it. Free; nothing is created.

**Request body**

What to ask, whom, and with what material. Each kind reads its own fields:

- `closed_question`: `question`, `options` (2 to 8)
- `open_question`: `question`
- `survey`, `interview`: `questions` (or the `instrument_id` of one saved in the Library), and `question` as a one-line label
- `focus_group`: `topics` (1 to 12, in order)
- `preference_test`: `question`, `options` (2 to 12); `file_ids` for options that are pictures or videos: one file per option, in option order
- `creative_test`: `question`, and 1 to 3 images or videos as `file_ids` (from POST /files) or public `image_urls`
- `page_test`: `question`, `url`
- `pr_test`: `stimulus` (the announcement, verbatim), optional `society`

A field another kind reads is refused (`kind_mismatch`), never dropped.

| Field | Type | Required | Description |
|---|---|---|---|
| `kind` | `string` | Yes | One of `closed_question`, `open_question`, `survey`, `interview`, `focus_group`, `preference_test`, `creative_test`, `page_test`, `pr_test`. |
| `question` | `string` | No | The exact question respondents receive. Up to 1,000 characters. |
| `audience_ids` | `string[]` | Yes | Audience ids (GET /audiences). Up to 8 items. |
| `respondents` | `integer` | No | Respondents per audience (default: the kind's small default, within today's API budget). From 1 to 100,000. |
| `respondents_by_audience` | `object` | No | Per-audience override \{id: n\}. |
| `options` | `string[]` | No | The answer options: 2 to 8 for a closed_question, 2 to 12 for a preference_test (one per version compared). Up to 12 items. |
| `topics` | `string[]` | No | Up to 12 items. |
| `url` | `string` | No | Up to 2,048 characters. |
| `image_urls` | `string[]` | No | Up to 3 items. |
| `file_ids` | `string[]` | No | Images or videos from POST /files. Up to 12 items. |
| `questions` | `object[]` | No | Up to 50 items. |
| `questions[].question` | `string` | Yes | The question as respondents read it. Up to 1,000 characters. |
| `questions[].options` | `string[]` | No | 2 to 12 answer options; leave out for an open question. Up to 12 items. |
| `questions[].multi_select` | `boolean` | No | Respondents may pick more than one option. Default `false`. |
| `instrument_id` | `string` | No | A survey or discussion guide saved in the Library. Up to 64 characters. |
| `stimulus` | `string` | No | Up to 6,000 characters. |
| `society` | `object` | No | How a PR test plays out (all optional). |
| `society.platform` | `string` | No | weibo \| xiaohongshu \| x \| reddit \| internal (default: a generic feed). Up to 32 characters. |
| `society.days` | `integer` | No | Simulated days (default 5). From 1 to 14. |
| `society.ticks_per_day` | `integer` | No | From 1 to 2. |
| `society.statement` | `string` | No | The statement people's agreement is measured on. Up to 300 characters. |
| `society.events` | `object[]` | No | Later facts placed on the timeline. Up to 20 items. |
| `society.events[].day` | `integer` | No | From 1 to 14. Default `1`. |
| `society.events[].text` | `string` | Yes | Up to 3,000 characters. |
| `society.variants` | `string[]` | No | Other versions of the announcement to rank against it. Up to 4 items. |
| `society.actors` | `object[]` | No | Up to 10 items. |
| `society.actors[].name` | `string` | Yes | Up to 80 characters. |
| `society.actors[].type` | `string` | No | Up to 20 characters. Default `"media"`. |
| `society.actors[].reach` | `number` | No | From 0 to 1. Default `0.8`. |
| `society.actors[].trust` | `number` | No | From 0 to 1. Default `0.6`. |
| `notes` | `string` | No | The research goal, for the report. Up to 2,000 characters. |
| `follow_up_of` | `string` | No | A study id: ask the same respondents again, with their earlier answers in front of them. Up to 64 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/studies/estimate \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "closed_question",
    "question": "Which name would make you most likely to try this oat drink?",
    "options": ["Morning Oat", "Field Glass", "Plain Oat"],
    "audience_ids": ["AUDIENCE_ID"],
    "respondents": 50
  }'
```

**Response**

Takes exactly the body POST /studies takes. Returns a `study_estimate`: `credits` (what POST /studies would charge), `rule`, `credits_per_respondent`, `respondents` (the panel billed), `audiences` (`[{id, name, respondents}]`), `default_respondents`, `max_respondents_under_cap` (the largest panel per audience today's API budget still covers), `balance`, `sufficient` (whether POST /studies would accept it as priced), `blocked` (the budget rule that would refuse it), `confirm_recommended`, `estimated_minutes`, `api_budget` `{daily, spent_today, remaining_today}`, and `rejected` (`[{id, reason, name?, hint?}]`: audiences POST /studies would refuse).

## Run a study

`POST /v1/studies`

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

Ask an audience. **Spends the workspace's credits** (editor or above).

**Request body**

The same body as [Price a study](https://imario.ai/docs/api/reference/studies#price-a-study).

**Example**

```bash
curl https://api.imario.ai/v1/studies \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "closed_question",
    "question": "Which name would make you most likely to try this oat drink?",
    "options": ["Morning Oat", "Field Glass", "Plain Oat"],
    "audience_ids": ["AUDIENCE_ID"],
    "respondents": 50
  }'
```

**Response**

Returns the `study` at once (`queued`, or `waiting_for_audience` while an audience's people are still being found); poll GET /studies/\{id\} or subscribe to `study.completed` / `study.failed`. The price is the one POST /studies/estimate quotes; it is claimed against the workspace's API daily budget on submission, and the credits are debited in one go when the study starts, on the people actually seated, so the charge can come in below the estimate. A study that fails is refunded. Audiences the workspace may not use are refused (`audience_rejected`, 403), never dropped. Send an `Idempotency-Key` header so a retry cannot run the study twice.

A `study` object:

- `id`, `livemode`, `created_at`, `kind` (`closed_question`, `open_question`, `survey`, `interview`, `focus_group`, `preference_test`, `creative_test`, `page_test`, `pr_test`)
- `status`: `queued` | `waiting_for_audience` | `running` | `completed` | `failed` | `canceled`
- `question`, `audiences` (`[{id, name, respondents}]`), `respondents` (the panel asked for)
- `credits`: `{estimated, charged}` (what the submission was priced at, and what the ledger shows it charged, net of any refund)
- `outcome`: `answers` | `partial_answers` | `no_answers`, once it ended (null before)
- `progress`: `{answered, total}` while it runs
- `completed_at`, `conversation_id` and `web_url` (the study in the iMario app; null in test mode)
- `error`: `{code, message}` when it failed

Events: `study.completed`, `study.failed`.

## List studies

`GET /v1/studies`

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

The workspace's studies, newest first.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `kind` | query | `string` | No | Only studies of this kind. One of `closed_question`, `open_question`, `survey`, `interview`, `focus_group`, `preference_test`, `creative_test`, `page_test`, `pr_test`. |
| `status` | query | `string` | No | Only studies in this status. One of `queued`, `waiting_for_audience`, `running`, `completed`, `failed`, `canceled`. |
| `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/studies?status=completed&limit=20" \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

**Response**

Returns the object described under [Run a study](https://imario.ai/docs/api/reference/studies#run-a-study).

Events: `study.completed`, `study.failed`.

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

## Retrieve a study

`GET /v1/studies/{id}`

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

**Example**

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

**Response**

Returns the object described under [Run a study](https://imario.ai/docs/api/reference/studies#run-a-study).

Events: `study.completed`, `study.failed`.

## Cancel a study that has not started

`POST /v1/studies/{id}/cancel`

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

Cancels a study that is `queued` or `waiting_for_audience` (editor or above). A study a worker has started runs to the end (409 `study_already_started`). Anything it was charged is refunded, and what it claimed of today's API budget goes back.

**Example**

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

**Response**

Returns the object described under [Run a study](https://imario.ai/docs/api/reference/studies#run-a-study).

Events: `study.completed`, `study.failed`.

## Read a study's results

`GET /v1/studies/{id}/results`

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

What the study found, per question. Free.

**Example**

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

**Response**

`{object: "study_results", livemode, study_id, status, outcome, answers (how many people answered), summary, confidence, results}`; `results` is empty until the study is `completed`. Each `study_result`: `id`, `index` (1-based), `question` (in the researcher's words; `asked` is what respondents read when the study was asked in another language), `kind` (`single_choice` | `multi_choice` | `ranking` | `open` | `discussion` | `simulation`), `n` (people who answered), `audiences` `[{id, name, respondents, answered}]`, `distribution` (`[{code, label, count, share, by_audience: [{audience_id, audience_name, count, share}]}]`; `share` is the weighted share, 0-1, pooled across audiences by their number of respondents, so it will not equal `count` over `n`; a ranking adds `mean_rank`, and its `share` is the share who ranked it first), `themes` (`[{id, label, share, count, quotes: [{text, text_translated, person_id, audience_id}], by_audience}]`), `values` (a named value, such as a price, bucketed), `summary`, `discussion` (a focus group: topics with the group's positions before and after, participants, closing claims), `simulation` (a PR test: stance by day, arguments, reach), `page` (a page test's first-glance themes and ratings) and `warnings` `[{code, params}]`. `confidence` is `high` | `medium` | `low`.

## List a study's responses

`GET /v1/studies/{id}/responses`

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

Every person's answer to every question, in question order (cursor pages). Free.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `question_id` | query | `string` | No | Only this result's question. Up to 64 characters. |
| `audience_id` | query | `string` | No | Only this audience's people. Up to 64 characters. |
| `person_id` | query | `string` | No | Only this person. Up to 64 characters. |
| `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/studies/STUDY_ID/responses?limit=100" \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

**Response**

Each `study_response`: `result_id` and `question_index` (the question in GET /studies/\{id\}/results), `question`, `kind`, `person` `{id, name, audience_id, audience_name, attributes}` and `answer`. The answer's `type` says which fields it fills: `choice` (`choice: {code, label}`), `choices`, `ranking` (options in the person's order) or `text`, each with `text` (the person's own words, in their language), `text_translated` (in the researcher's language, when that differs), `themes`, `value`, and `exchanges` (an interview's questions, answers and follow-ups); `discussion` (a focus group, one per person per topic: `position_before`, `position_after`, `statement_before`, `statement_after`, `moved`, `moved_because`, `scale`); `simulation` (a PR test: `position_before`, `position_after`, `posts`). Empty until the study is `completed`.

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

## List a study's segments

`GET /v1/studies/{id}/segments`

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

The groups this study can be cut into, as the Explorer offers them. Free.

**Example**

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

**Response**

A list of `segment` objects: `id` (pass it as `segment_id` to POST /studies/\{id\}/insights), `dimension` (`audience` | `trait` | `answer` | `theme` | `saved`), `label`, `value`, `people`, and `insights_available` (big enough for an AI read). `answer` and `theme` segments name their `result_id` and `question`; `trait` segments their `trait` (e.g. `age_band`); `saved` segments are audiences already saved out of this study. Empty until the study is `completed`.

## Read what sets a group apart

`POST /v1/studies/{id}/insights`

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

The AI read of one group: what sets it apart from everyone else in the study.

**Request body**

The group to read: a `segment_id` from GET /studies/\{id\}/segments, or `person_ids`.

| Field | Type | Required | Description |
|---|---|---|---|
| `segment_id` | `string` | No | Up to 300 characters. |
| `person_ids` | `string[]` | No | Up to 1,000 items. |
| `label` | `string` | No | Your name for the group. Up to 120 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/studies/STUDY_ID/insights \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "segment_id": "SEGMENT_ID",
    "label": "Chose Morning Oat"
  }'
```

**Response**

10 credits (viewer or above; a read of the same group again is free). Name the group with a `segment_id` from GET /studies/\{id\}/segments or with `person_ids` (at least 5 people of the study). The numbers are computed from the answers; the model contributes only a name and a few sentences. Returns an `insight`: `name`, `bullets` (key phrases in `**bold**`), `signals` (`[{dimension, value, group_pct, panel_pct, group_n, group_total, direction}]`), `group` `{label, segment_id, people, panel_size}`, `credits` `{charged}`, `cached`. A group that answers like everyone else is refused (`no_difference`) and costs nothing; a read that could not be written is refunded.
