# Library

> Surveys, discussion guides and announcements saved in the Library, which a study can run by id.

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

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

## List surveys

`GET /v1/surveys`

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

The workspace's surveys, newest first: `{title, status, questions, question_count, audience_ids}`.

**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. |
| `status` | query | `string` | No | Only draft or only ready items. One of `draft`, `ready`. |

**Example**

```bash
curl https://api.imario.ai/v1/surveys \
  -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).

## Create a survey

`POST /v1/surveys`

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

A survey in the Library. Questions are closed_question, open_question, ranking, media_stimulus or url_task; a `ready` survey can be run by id (`POST /studies` with kind survey and `instrument_id`).

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | No | Named from the first question when left out. Up to 200 characters. |
| `status` | `string` | No | ready (can be run) or draft. One of `draft`, `ready`. Default `"ready"`. |
| `questions` | `object[]` | No | Up to 100 items. |
| `questions[].type` | `string` | Yes | closed_question, open_question, ranking, media_stimulus, url_task, or instruction (discussion guides only). One of `closed_question`, `open_question`, `ranking`, `media_stimulus`, `url_task`, `instruction`. |
| `questions[].question` | `string` | No | The question's text. Up to 4,000 characters. |
| `questions[].text` | `string` | No | An instruction's text. Up to 4,000 characters. |
| `questions[].options` | `string[]` | No | closed_question: 2 to 30 answers. Up to 30 items. |
| `questions[].multi_select` | `boolean` | No | closed_question: people may pick several. |
| `questions[].randomize_options` | `boolean` | No | closed_question: shuffle the order per person. |
| `questions[].items` | `string[]` | No | ranking: 2 to 30 items to order. Up to 30 items. |
| `questions[].media` | `string[]` | No | media_stimulus: up to 6 file ids (images or videos from /files) or https links to pictures. Up to 6 items. |
| `questions[].url` | `string` | No | url_task: the page (http or https). Up to 2,048 characters. |
| `questions[].task_description` | `string` | No | url_task: what to do on it. Up to 2,000 characters. |
| `questions[].probes` | `string[]` | No | Discussion guides: follow-up questions the interviewer asks. Up to 10 items. |
| `questions[].required` | `boolean` | No | Whether the question must be answered. Default `true`. |
| `audience_ids` | `string[]` | No | Audiences the survey is meant for (a suggestion). Up to 20 items. |

**Example**

```bash
curl https://api.imario.ai/v1/surveys \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Breakfast habits",
    "questions": [
      {
        "type": "closed_question",
        "question": "How often do you eat breakfast at home?",
        "options": ["Every day", "A few times a week", "Rarely", "Never"]
      },
      {
        "type": "open_question",
        "question": "What would make breakfast at home easier?"
      }
    ]
  }'
```

## Retrieve a survey

`GET /v1/surveys/{survey_id}`

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

One survey of this workspace's Library with its full content. A test key also reads its own sandbox surveys.

**Example**

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

## Update a survey

`PATCH /v1/surveys/{survey_id}`

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

Fields left out are kept; `questions`, when sent, replaces the list.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | No | Up to 200 characters. |
| `status` | `string` | No | One of `draft`, `ready`. |
| `questions` | `object[]` | No | Up to 100 items. |
| `questions[].type` | `string` | Yes | closed_question, open_question, ranking, media_stimulus, url_task, or instruction (discussion guides only). One of `closed_question`, `open_question`, `ranking`, `media_stimulus`, `url_task`, `instruction`. |
| `questions[].question` | `string` | No | The question's text. Up to 4,000 characters. |
| `questions[].text` | `string` | No | An instruction's text. Up to 4,000 characters. |
| `questions[].options` | `string[]` | No | closed_question: 2 to 30 answers. Up to 30 items. |
| `questions[].multi_select` | `boolean` | No | closed_question: people may pick several. |
| `questions[].randomize_options` | `boolean` | No | closed_question: shuffle the order per person. |
| `questions[].items` | `string[]` | No | ranking: 2 to 30 items to order. Up to 30 items. |
| `questions[].media` | `string[]` | No | media_stimulus: up to 6 file ids (images or videos from /files) or https links to pictures. Up to 6 items. |
| `questions[].url` | `string` | No | url_task: the page (http or https). Up to 2,048 characters. |
| `questions[].task_description` | `string` | No | url_task: what to do on it. Up to 2,000 characters. |
| `questions[].probes` | `string[]` | No | Discussion guides: follow-up questions the interviewer asks. Up to 10 items. |
| `questions[].required` | `boolean` | No | Whether the question must be answered. Default `true`. |
| `audience_ids` | `string[]` | No | Up to 20 items. |

**Example**

```bash
curl -X PATCH https://api.imario.ai/v1/surveys/SURVEY_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Breakfast habits, wave 2",
    "status": "ready"
  }'
```

## Delete a survey

`DELETE /v1/surveys/{survey_id}`

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

Soft: the item leaves the Library and every picker, and is no longer offered to new studies. Studies that ran with it, a study already submitted with it and their reports keep working. `usage` says how many finished studies used it and how many are still running.

**Example**

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

## List discussion guides

`GET /v1/discussion-guides`

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

The workspace's interview guides, newest first: `{title, status, opening_message, sections: [{title, description, questions}], question_count, audience_ids}`.

**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. |
| `status` | query | `string` | No | Only draft or only ready items. One of `draft`, `ready`. |

**Example**

```bash
curl https://api.imario.ai/v1/discussion-guides \
  -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).

## Create a discussion guide

`POST /v1/discussion-guides`

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

An interview guide in sections. Questions may carry follow-up `probes`; `instruction` blocks are said to the respondent before the next question. A `ready` guide can be run by id (`POST /studies` with kind interview).

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | No | Up to 200 characters. |
| `status` | `string` | No | One of `draft`, `ready`. Default `"ready"`. |
| `opening_message` | `string` | No | What the interviewer says first. Up to 4,000 characters. |
| `sections` | `object[]` | No | Up to 30 items. |
| `sections[].title` | `string` | No | Up to 200 characters. |
| `sections[].description` | `string` | No | Up to 2,000 characters. |
| `sections[].questions` | `object[]` | No | Up to 100 items. |
| `sections[].questions[].type` | `string` | Yes | closed_question, open_question, ranking, media_stimulus, url_task, or instruction (discussion guides only). One of `closed_question`, `open_question`, `ranking`, `media_stimulus`, `url_task`, `instruction`. |
| `sections[].questions[].question` | `string` | No | The question's text. Up to 4,000 characters. |
| `sections[].questions[].text` | `string` | No | An instruction's text. Up to 4,000 characters. |
| `sections[].questions[].options` | `string[]` | No | closed_question: 2 to 30 answers. Up to 30 items. |
| `sections[].questions[].multi_select` | `boolean` | No | closed_question: people may pick several. |
| `sections[].questions[].randomize_options` | `boolean` | No | closed_question: shuffle the order per person. |
| `sections[].questions[].items` | `string[]` | No | ranking: 2 to 30 items to order. Up to 30 items. |
| `sections[].questions[].media` | `string[]` | No | media_stimulus: up to 6 file ids (images or videos from /files) or https links to pictures. Up to 6 items. |
| `sections[].questions[].url` | `string` | No | url_task: the page (http or https). Up to 2,048 characters. |
| `sections[].questions[].task_description` | `string` | No | url_task: what to do on it. Up to 2,000 characters. |
| `sections[].questions[].probes` | `string[]` | No | Discussion guides: follow-up questions the interviewer asks. Up to 10 items. |
| `sections[].questions[].required` | `boolean` | No | Whether the question must be answered. Default `true`. |
| `audience_ids` | `string[]` | No | Up to 20 items. |

**Example**

```bash
curl https://api.imario.ai/v1/discussion-guides \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Switching banks",
    "opening_message": "Thanks for joining. This conversation is about how you choose a bank.",
    "sections": [
      {
        "title": "Your current bank",
        "questions": [
          {
            "type": "open_question",
            "question": "How did you choose your current bank?",
            "probes": ["What almost made you choose another one?"]
          }
        ]
      }
    ]
  }'
```

## Retrieve a discussion guide

`GET /v1/discussion-guides/{guide_id}`

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

One discussion guide of this workspace's Library with its full content. A test key also reads its own sandbox discussion guides.

**Example**

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

## Update a discussion guide

`PATCH /v1/discussion-guides/{guide_id}`

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

Fields left out are kept; `sections`, when sent, replaces them all.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | No | Up to 200 characters. |
| `status` | `string` | No | One of `draft`, `ready`. |
| `opening_message` | `string` | No | Up to 4,000 characters. |
| `sections` | `object[]` | No | Up to 30 items. |
| `sections[].title` | `string` | No | Up to 200 characters. |
| `sections[].description` | `string` | No | Up to 2,000 characters. |
| `sections[].questions` | `object[]` | No | Up to 100 items. |
| `sections[].questions[].type` | `string` | Yes | closed_question, open_question, ranking, media_stimulus, url_task, or instruction (discussion guides only). One of `closed_question`, `open_question`, `ranking`, `media_stimulus`, `url_task`, `instruction`. |
| `sections[].questions[].question` | `string` | No | The question's text. Up to 4,000 characters. |
| `sections[].questions[].text` | `string` | No | An instruction's text. Up to 4,000 characters. |
| `sections[].questions[].options` | `string[]` | No | closed_question: 2 to 30 answers. Up to 30 items. |
| `sections[].questions[].multi_select` | `boolean` | No | closed_question: people may pick several. |
| `sections[].questions[].randomize_options` | `boolean` | No | closed_question: shuffle the order per person. |
| `sections[].questions[].items` | `string[]` | No | ranking: 2 to 30 items to order. Up to 30 items. |
| `sections[].questions[].media` | `string[]` | No | media_stimulus: up to 6 file ids (images or videos from /files) or https links to pictures. Up to 6 items. |
| `sections[].questions[].url` | `string` | No | url_task: the page (http or https). Up to 2,048 characters. |
| `sections[].questions[].task_description` | `string` | No | url_task: what to do on it. Up to 2,000 characters. |
| `sections[].questions[].probes` | `string[]` | No | Discussion guides: follow-up questions the interviewer asks. Up to 10 items. |
| `sections[].questions[].required` | `boolean` | No | Whether the question must be answered. Default `true`. |
| `audience_ids` | `string[]` | No | Up to 20 items. |

**Example**

```bash
curl -X PATCH https://api.imario.ai/v1/discussion-guides/GUIDE_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "opening_message": "Thanks for joining. We will talk about banks for about ten minutes."
  }'
```

## Delete a discussion guide

`DELETE /v1/discussion-guides/{guide_id}`

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

Soft: the item leaves the Library and every picker, and is no longer offered to new studies. Studies that ran with it, a study already submitted with it and their reports keep working. `usage` says how many finished studies used it and how many are still running.

**Example**

```bash
curl -X DELETE https://api.imario.ai/v1/discussion-guides/GUIDE_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY"
```

## List announcements

`GET /v1/announcements`

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

The workspace's announcements (what a PR test runs on): `{title, status, versions}`.

**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. |
| `status` | query | `string` | No | Only draft or only ready items. One of `draft`, `ready`. |

**Example**

```bash
curl https://api.imario.ai/v1/announcements \
  -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).

## Create an announcement

`POST /v1/announcements`

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

The announcement (version A) and up to four other wordings of it.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | No | Up to 200 characters. |
| `status` | `string` | No | One of `draft`, `ready`. Default `"ready"`. |
| `versions` | `string[]` | No | The announcement (A) and up to four other wordings; a PR test ranks them by how they move opinion. Up to 5 items. |

**Example**

```bash
curl https://api.imario.ai/v1/announcements \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Basic plan price change",
    "versions": [
      "From 1 March the Basic plan costs $9 a month instead of $7. Everything in it stays the same.",
      "From 1 March the Basic plan costs $9 a month. It now includes priority support."
    ]
  }'
```

## Retrieve an announcement

`GET /v1/announcements/{announcement_id}`

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

One announcement of this workspace's Library with its full content. A test key also reads its own sandbox announcements.

**Example**

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

## Update an announcement

`PATCH /v1/announcements/{announcement_id}`

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

Fields left out are kept; `versions`, when sent, replaces them.

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | `string` | No | Up to 200 characters. |
| `status` | `string` | No | One of `draft`, `ready`. |
| `versions` | `string[]` | No | Up to 5 items. |

**Example**

```bash
curl -X PATCH https://api.imario.ai/v1/announcements/ANNOUNCEMENT_ID \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "draft"
  }'
```

## Delete an announcement

`DELETE /v1/announcements/{announcement_id}`

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

Soft: the item leaves the Library and every picker, and is no longer offered to new studies. Studies that ran with it, a study already submitted with it and their reports keep working. `usage` says how many finished studies used it and how many are still running.

**Example**

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