# Usage

Usage endpoints let you inspect workspace allowances, review per-client consumption, and manage client-level AI caps. Usage metrics include identified recipients, anonymous recipients, narration characters, image generations, AI tokens, and API seats.

<a id="get-setup-status"></a>

## Get integration setup status

Read your workspace's setup progress and current allowances using your API key. The response includes the workspace, course and theme IDs, `keyMode` (`test` or `production`), completion status, and steps for `course`, `key`, `call`, `link`, `open` and `completion`. Each step has `done` and `at` fields. `lastFailure` includes a suggested `fix`, or is null when no failure is newer than the latest successful call. Calling this endpoint does not count as the first successful API call.

GET `/v1/headless/setup/status`

#### Examples

**cURL request**

```bash
curl --request GET \
  --url "https://api.coassemble.com/api/v1/headless/setup/status" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
{
  "workspaceId": 1234,
  "workspaceName": "example",
  "course": {
    "id": 1234,
    "title": "Workplace Safety",
    "published": "2026-01-01T00:00:00.000Z",
    "themeId": 1234
  },
  "demoCourseId": 1234,
  "themeId": 1234,
  "keyMode": "test",
  "complete": false,
  "completedAt": "2026-01-01T00:00:00.000Z",
  "steps": [
    {
      "id": "course",
      "done": false,
      "at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "lastFailure": {
    "id": 1234,
    "statusCode": 1,
    "path": "example",
    "errorMessage": "example",
    "fix": "example",
    "created": "2026-01-01T00:00:00.000Z"
  },
  "allowances": [
    {
      "field": "example",
      "metric": "ir",
      "unit": "example",
      "limit": 1,
      "setting": "plan_default",
      "state": "inherit",
      "amount": 1,
      "currentUsage": 1,
      "periodStart": "2026-01-01T00:00:00.000Z",
      "periodEnd": "2026-01-01T00:00:00.000Z",
      "resetDate": "2026-01-01T00:00:00.000Z",
      "cadence": "annual",
      "resets": "annual",
      "resetSource": "example",
      "whenReached": "stops"
    }
  ]
}
```

<a id="get-workspace-allowances"></a>

## Get workspace allowances

Use this endpoint to get the current billing-period allowances and usage totals for your workspace. The response includes `ir`, `ar`, `narrationUsage`, `imageUsage`, `aiTokens`, and `apiSeats` rows.

GET `/v1/headless/usage/allowances`

#### Examples

**cURL request**

```bash
curl --request GET \
  --url "https://api.coassemble.com/api/v1/headless/usage/allowances" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
[
  {
    "field": "example",
    "metric": "ir",
    "unit": "example",
    "limit": 1,
    "setting": "plan_default",
    "state": "inherit",
    "amount": 1,
    "currentUsage": 1,
    "periodStart": "2026-01-01T00:00:00.000Z",
    "periodEnd": "2026-01-01T00:00:00.000Z",
    "resetDate": "2026-01-01T00:00:00.000Z",
    "cadence": "annual",
    "resets": "annual",
    "resetSource": "example",
    "whenReached": "stops"
  }
]
```

<a id="get-client-ai-allowances"></a>

## Get client AI allowances

Use this endpoint to get the current monthly AI allowance rows for a client identifier. Client AI allowance rows include narration character usage and image generation usage.

GET `/v1/headless/usage/client/{identifier}`

#### Path parameters

| Field | Description | Options |
| --- | --- | --- |
| `identifier` | Your stable client identifier | — |

#### Examples

**cURL request**

```bash
curl --request GET \
  --url "https://api.coassemble.com/api/v1/headless/usage/client/client_123" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
[
  {
    "field": "example",
    "metric": "ir",
    "unit": "example",
    "limit": 1,
    "setting": "plan_default",
    "state": "inherit",
    "amount": 1,
    "currentUsage": 1,
    "periodStart": "2026-01-01T00:00:00.000Z",
    "periodEnd": "2026-01-01T00:00:00.000Z",
    "resetDate": "2026-01-01T00:00:00.000Z",
    "cadence": "annual",
    "resets": "annual",
    "resetSource": "example",
    "whenReached": "stops"
  }
]
```

<a id="update-client-ai-caps"></a>

## Update client AI caps

Use this endpoint to set client-level monthly caps for narration characters and image generations. Send `null` for a cap to make that client unlimited for the metric. `0` stops generation of that metric for the client while client caps are enabled (`clientCapsEnabled` on `PUT /v1/headless/usage/client-defaults`).

PUT `/v1/headless/usage/client/{identifier}`

#### Path parameters

| Field | Description | Options |
| --- | --- | --- |
| `identifier` | Your stable client identifier | — |

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `narrationUsageLimit` | `string \| integer \| null` | No | Characters per month; null = no cap. Zero stops narration generation. | — |
| `imageUsageLimit` | `string \| integer \| null` | No | Image generations per month; null = no cap. Zero stops image generation. | — |

#### Examples

**cURL request**

```bash
curl --request PUT \
  --url "https://api.coassemble.com/api/v1/headless/usage/client/client_123" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "narrationUsageLimit": 1,
    "imageUsageLimit": 1
}'
```

#### Response

**JSON response**

```json
[
  {
    "field": "example",
    "metric": "ir",
    "unit": "example",
    "limit": 1,
    "setting": "plan_default",
    "state": "inherit",
    "amount": 1,
    "currentUsage": 1,
    "periodStart": "2026-01-01T00:00:00.000Z",
    "periodEnd": "2026-01-01T00:00:00.000Z",
    "resetDate": "2026-01-01T00:00:00.000Z",
    "cadence": "annual",
    "resets": "annual",
    "resetSource": "example",
    "whenReached": "stops"
  }
]
```

<a id="get-client-default-ai-caps"></a>

## Get default AI caps for new clients

Use this endpoint to read the workspace default narration and image caps that new clients pick up at create time. Limits serialize as a number or `unlimited` when there is no cap. Changing these defaults does not change existing clients. The response includes `mismatched`, a count of existing clients whose narration or image cap differs from these defaults.

GET `/v1/headless/usage/client-defaults`

#### Examples

**cURL request**

```bash
curl --request GET \
  --url "https://api.coassemble.com/api/v1/headless/usage/client-defaults" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
{
  "clientCapsEnabled": false,
  "narrationUsageLimit": 1,
  "imageUsageLimit": 1,
  "mismatched": 1
}
```

<a id="update-client-default-ai-caps"></a>

## Update default AI caps for new clients

Use this endpoint to set the workspace default narration and image caps for newly created clients. Send only the fields you want to change. Send `null` for no cap. `0` stops generation of that metric for new clients while client caps are enabled (`clientCapsEnabled`). Existing clients are not changed. The response includes the same `mismatched` count as GET, recomputed against the saved defaults.

PUT `/v1/headless/usage/client-defaults`

#### Body parameters

| Field | Type | Required | Desc | Options |
| --- | --- | --- | --- | --- |
| `clientCapsEnabled` | `boolean` | No | Optional boolean that enables or disables client cap enforcement, with omission retaining the current setting. | — |
| `narrationUsageLimit` | `string \| integer \| null` | No | Optional narration character cap per client usage period for new clients, with an integer from 0 to 2147483647, \`null\` for no cap, or omission to keep the current default. | — |
| `imageUsageLimit` | `string \| integer \| null` | No | Optional image generation cap per client usage period for new clients, with an integer from 0 to 2147483647, \`null\` for no cap, or omission to keep the current default. | — |

#### Examples

**cURL request**

```bash
curl --request PUT \
  --url "https://api.coassemble.com/api/v1/headless/usage/client-defaults" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "clientCapsEnabled": true,
    "narrationUsageLimit": 1,
    "imageUsageLimit": 1
}'
```

#### Response

**JSON response**

```json
{
  "clientCapsEnabled": false,
  "narrationUsageLimit": 1,
  "imageUsageLimit": 1,
  "mismatched": 1
}
```

<a id="apply-client-default-ai-caps"></a>

## Apply default AI caps to existing clients

Use this endpoint to overwrite every existing client's narration and image caps with the current workspace defaults, including caps the partner set on individual clients. The response is `updated` (clients whose caps actually changed) and `mismatched` (clients that still differ; 0 after a successful apply).

POST `/v1/headless/usage/client-defaults/apply`

#### Examples

**cURL request**

```bash
curl --request POST \
  --url "https://api.coassemble.com/api/v1/headless/usage/client-defaults/apply" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
{
  "updated": 1,
  "mismatched": 1
}
```

<a id="get-client-usage"></a>

## Get client usage

Use this endpoint to fetch paginated usage rows for each client identifier in your workspace. You can provide a usage window with `start` and `end`; date ranges can be up to 366 days.

GET `/v1/headless/usage/clients`

#### Query parameters

| Field | Type | Required | Default | Description | Options |
| --- | --- | --- | --- | --- | --- |
| `start` | `string` | No | — | ISO 8601 date — start of the usage window (defaults to 30 days ago) | — |
| `end` | `string` | No | — | ISO 8601 date — end of the usage window (defaults to now). Max window 366 days. | — |
| `page` | `string \| integer` | No | `0` | Zero-indexed page number | — |
| `length` | `string \| integer` | No | `50` | Maximum number of clients per page (max 50) | — |

#### Examples

**cURL request**

```bash
curl --request GET \
  --url "https://api.coassemble.com/api/v1/headless/usage/clients?start=example&end=example&page=0&length=50" \
  --header "Authorization: COASSEMBLE:YOUR_WORKSPACE_ID:YOUR_API_KEY"
```

#### Response

**JSON response**

```json
{
  "page": 0,
  "length": 50,
  "data": [
    {
      "clientIdentifier": "client_123",
      "metric": "ir",
      "currentUsage": 1,
      "periodStart": "2026-01-01T00:00:00.000Z",
      "periodEnd": "2026-01-01T00:00:00.000Z"
    }
  ]
}
```
