# Connections

> The workspace's connected data sources, what each offers now, and a new sync.

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

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 the workspace's connections

`GET /v1/connections`

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

Newest first. A `connection` object: `id`, `livemode`, `created_at`, `provider` (its key, e.g. `hubspot`), `provider_name`, `account_label`, `status` (`active` | `syncing` | `expired` | `revoked`), `error_message`, `last_sync_at`, `stale` (a sync that stopped reporting).

**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/connections \
  -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).

## What a connection offers now

`GET /v1/connections/{id}/items`

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

The provider's items (fields, surveys, recordings...) read from the provider right now, as the web's confirm screen shows them, with `notes` and a `summary`. For a stream provider (recordings, threads), `watch` (JSON) previews what a standing scope takes in. Not paged: `has_more` is always false.

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `watch` | query | `string` | No | A stream provider's scope, as JSON. Up to 2,000 characters. |

**Example**

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

## Sync a connection

`POST /v1/connections/{id}/sync`

**Scope** `connections:write` · **Role** editor or above · Live keys only

Queues a pull and returns the connection at once (`status: syncing`). Send no `items` or `watch` to repeat the last sync's selection. 409 `sync_in_progress` while one runs. Live keys only; needs the editor role. A `connection` object: `id`, `livemode`, `created_at`, `provider` (its key, e.g. `hubspot`), `provider_name`, `account_label`, `status` (`active` | `syncing` | `expired` | `revoked`), `error_message`, `last_sync_at`, `stale` (a sync that stopped reporting).

**Request body**

| Field | Type | Required | Description |
|---|---|---|---|
| `items` | `string[]` | No | Item ids to pull (from /items). Default: what the last sync pulled. Up to 1,000 items. |
| `fields` | `string[]` | No | Up to 1,000 items. |
| `options` | `object` | No |  |
| `watch` | `object` | No | A stream provider's standing scope. |
| `audience_id` | `string` | No | The from-data audience the synced files feed. Default: the one the last sync fed. Up to 36 characters. |

**Example**

```bash
curl https://api.imario.ai/v1/connections/CONNECTION_ID/sync \
  -H "Authorization: Bearer $IMARIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```
