# Chats API

> Conversations between a user and an assistant. Add a message, then process the chat to get the assistant's reply.

Part of the AGNT API reference. AGNT (https://agnt.ai) is the developer platform behind OpenAssistant (https://openassistant.us). Docs index: https://agnt.ai/llms.txt. Web page: https://agnt.ai/reference/api/chats

Base URL: `https://api.agnt.ai`. Auth: `Authorization: Bearer ak_live_...`.

## GET /chats

List chats

Returns the user's chats, most recent first.

Acts as one user: send `X-User-Email`.

**Query parameters**

- `page` (integer)
- `perPage` (integer)
- `status` (enum) One of: `active`, `archived`.
- `assistantId` (string)
- `q` (string): Search
- `platform` (string): Channel, one value or comma-separated: chat, email, slack, teams, sms, whatsapp, imessage, phone
- `userEmail` (string): With an account key and no X-User-Email: only chats of the user with this email

**Responses**

- `200`: Chats
  - `ok` (boolean)
  - `chats` (object[])
    - `id` (string, required): Chat id
    - `title` (string | null)
    - `status` (enum, required) One of: `active`, `archived`.
    - `platform` (enum): Channel of the conversation; chat is an in-app chat One of: `chat`, `email`, `slack`, `teams`, `sms`, `whatsapp`, `imessage`, `rcs`, `phone`, `discord`, `telegram`, `task_activity`.
    - `user` (string): User id
    - `owner` (object)
      - `id` (string)
      - `email` (string)
      - `firstName` (string | null)
      - `lastName` (string | null)
      - `avatar` (string | null)
    - `assistant` (string): Assistant id
    - `assistantInfo` (object)
      - `id` (string)
      - `name` (string)
      - `email` (string)
    - `participants` (object[])
      - `type` (enum) One of: `phone`, `email`.
      - `value` (string)
    - `messageCount` (number)
    - `lastMessageAt` (string | null)
    - `createdForTaskId` (string | null): Set when the chat was opened for a task
    - `tags` (string[])
    - `metadata` (object)
    - `modelTier` (enum) One of: `low`, `medium`, `high`, `ultra`.
    - `effort` (enum): Reasoning effort: how much thinking the assistant applies on each run, independent of modelTier. low, medium, high, xhigh (extra high) or max. One of: `low`, `medium`, `high`, `xhigh`, `max`.
    - `createdAt` (string)
    - `updatedAt` (string)
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/chats' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "chats": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "status": "active"
    }
  ],
  "page": 1,
  "perPage": 20
}
```

## POST /chats

Create a chat

Creates a chat between the user and one of their assistants.

Acts as one user: send `X-User-Email`.

**Request body** (JSON)

- `assistantId` (string, required): Assistant id
- `title` (string)
- `metadata` (object): Your own key-value data
- `modelTier` (enum): Defaults to the organization's chat tier, then the account's, then medium. One of: `low`, `medium`, `high`, `ultra`.

**Responses**

- `201`: Chat
  - `ok` (boolean)
  - `chat` (object)
    - `id` (string, required): Chat id
    - `title` (string | null)
    - `status` (enum, required) One of: `active`, `archived`.
    - `platform` (enum): Channel of the conversation; chat is an in-app chat One of: `chat`, `email`, `slack`, `teams`, `sms`, `whatsapp`, `imessage`, `rcs`, `phone`, `discord`, `telegram`, `task_activity`.
    - `user` (string): User id
    - `owner` (object)
      - `id` (string)
      - `email` (string)
      - `firstName` (string | null)
      - `lastName` (string | null)
      - `avatar` (string | null)
    - `assistant` (string): Assistant id
    - `assistantInfo` (object)
      - `id` (string)
      - `name` (string)
      - `email` (string)
    - `participants` (object[])
      - `type` (enum) One of: `phone`, `email`.
      - `value` (string)
    - `messageCount` (number)
    - `lastMessageAt` (string | null)
    - `createdForTaskId` (string | null): Set when the chat was opened for a task
    - `tags` (string[])
    - `metadata` (object)
    - `modelTier` (enum) One of: `low`, `medium`, `high`, `ultra`.
    - `effort` (enum): Reasoning effort: how much thinking the assistant applies on each run, independent of modelTier. low, medium, high, xhigh (extra high) or max. One of: `low`, `medium`, `high`, `xhigh`, `max`.
    - `createdAt` (string)
    - `updatedAt` (string)
- `400`: assistantId or user missing

```bash
curl 'https://api.agnt.ai/chats' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "assistantId": "6702b1e8f9a0b1c2d3e4f5a6"
}'
```

Example response:

```json
{
  "ok": true,
  "chat": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "status": "active"
  }
}
```

## GET /chats/{chatId}

Retrieve a chat

Retrieves a chat's channel, user, assistant, participants and message count.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `chatId` (string, required)

**Responses**

- `200`: Chat
  - Same fields as the `201` response of `POST /chats`.
- `404`: Chat not found

```bash
curl 'https://api.agnt.ai/chats/<chatId>' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "chat": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "status": "active"
  }
}
```

## DELETE /chats/{chatId}

Delete a chat

Deletes a chat.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `chatId` (string, required)

**Responses**

- `200`: Deleted
  - `ok` (enum, required) One of: `true`.
  - `chat` (object, required)
    - `id` (string, required)
    - `deleted` (boolean)
    - `message` (string)

```bash
curl 'https://api.agnt.ai/chats/<chatId>' \
  -X DELETE \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "chat": {
    "id": "6660c4a1f2e3b7d8a9c01234"
  }
}
```

## POST /chats/{chatId}/messages

Create a message

Adds a message to a chat without running the assistant. To get a reply, process the chat.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `chatId` (string, required)

**Request body** (JSON)

- `content` (string, required): Message text.
- `role` (string)
- `from` (string)
- `to` (string | array)
- `cc` (string | array)
- `subject` (string)
- `platform` (string)
- `referenceId` (string): Your own correlation id.
- `files` (object[])
- `metadata` (object)

**Responses**

- `200`: Saved message
  - `ok` (boolean)
  - `message` (object)
    - `id` (string)
    - `role` (string)
    - `from` (string)
    - `to` (string[])
    - `cc` (string[])
    - `subject` (string)
    - `platform` (string)
    - `content` (string)
    - `timestamp` (string)
    - `metadata` (object)
- `400`: content is required.
- `404`: Chat not found for this user.

```bash
curl 'https://api.agnt.ai/chats/<chatId>/messages' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "content": "Prefers morning meetings."
}'
```

Example response:

```json
{
  "ok": true,
  "message": {
    "id": "6660c4a1f2e3b7d8a9c01234",
    "role": "role",
    "from": "from",
    "to": [
      "to"
    ]
  }
}
```

## GET /chats/{chatId}/messages

List messages

Returns a chat's messages, paginated.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `chatId` (string, required)

**Query parameters**

- `page` (integer)
- `perPage` (integer)

**Responses**

- `200`: Messages
  - `ok` (enum, required) One of: `true`.
  - `messages` (object[], required)
    - `id` (string, required)
    - `referenceId` (string)
    - `role` (string, required)
    - `from` (string)
    - `to` (string[])
    - `cc` (string[])
    - `subject` (string)
    - `platform` (string)
    - `content` (string, required)
    - `files` (any[])
    - `timestamp` (string, required)
    - `metadata` (object)
    - `delivery` (object): Delivery state of an outbound assistant message. Read-only.
      - `state` (enum): staged: waiting in an approval (cart) and not sent yet. held: held back and not sent. provider_accepted: sent; the delivery service accepted it. unknown: AGNT has no confirmed delivery record, so do not assume it was or was not delivered. Other values describe messages that stayed inside AGNT, such as a reply shown only in the hosted app or a report between the assistant's own runs. One of: `staged`, `held`, `provider_accepted`, `unknown`.
      - `taskId` (string): Task that sent it
      - `cartId` (string): Approval it went through, if any
  - `page` (integer)
  - `perPage` (integer)
  - `total` (integer)

```bash
curl 'https://api.agnt.ai/chats/<chatId>/messages' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "ok": true,
  "messages": [
    {
      "id": "6660c4a1f2e3b7d8a9c01234",
      "role": "role",
      "content": "Prefers morning meetings.",
      "timestamp": "2026-10-15T14:30:00Z"
    }
  ]
}
```

## POST /chats/{chatId}/process

Process a chat

Runs the assistant on the chat and streams the result as `text/event-stream`: `status_update` and `interim_message` events during the run, then a `message` event with the reply or an `error` event. The HTTP status is `200` even when an `error` event is sent. Events can arrive together when the run ends.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `chatId` (string, required)

**Request body** (JSON)

- `message` (object): Saves this as a user message, then runs. Must be an object with content; a bare string is ignored.
  - `content` (string, required)
  - `from` (string)
  - `to` (string | array)
  - `cc` (string | array)
  - `subject` (string)
  - `platform` (string)
  - `referenceId` (string)
  - `files` (object[]): Attachments: files already in the user's drive
    - `fileId` (string, required): Drive file id (24 hex characters)
    - `filename` (string)
    - `mimeType` (string)
  - `metadata` (object)
- `triggeringActivityId` (string): Id of an already-saved message to respond to.

**Responses**

- `200`: text/event-stream of status_update, interim_message, message and error events.

```bash
curl 'https://api.agnt.ai/chats/<chatId>/process' \
  -X POST \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com" \
  -H "Content-Type: application/json" \
  -d '{
  "message": {
    "content": "What is still open on the Brightline renewal?"
  }
}'
```

## GET /chats/{chatId}/usage

Retrieve a chat's usage

Returns the tokens the chat used, per run and in total, and the credits charged for each run.

Acts as one user: send `X-User-Email`.

**Path parameters**

- `chatId` (string, required)

**Responses**

- `200`: Usage
  - `total` (object)
    - `inputTokens` (number)
    - `outputTokens` (number)
    - `cacheReadTokens` (number)
    - `cacheCreationTokens` (number)
    - `totalTokens` (number)
    - `runs` (integer)
    - `turns` (integer)
  - `rows` (object[]): One row per run and model, oldest first
    - `runId` (string | null)
    - `seq` (integer)
    - `modelTier` (string | null)
    - `inputTokens` (number)
    - `outputTokens` (number)
    - `cacheReadTokens` (number)
    - `cacheCreationTokens` (number)
    - `totalTokens` (number)
    - `turns` (integer)
    - `startedAt` (string | null)
  - `credits` (object): Credits charged, one entry per run
    - `total` (number)
    - `runs` (object[])
      - `chargedCredits` (number)
      - `isBillable` (boolean)
      - `createdAt` (string)
- `404`: Chat not found

```bash
curl 'https://api.agnt.ai/chats/<chatId>/usage' \
  -H "Authorization: Bearer ak_live_..." \
  -H "X-User-Email: user@example.com"
```

Example response:

```json
{
  "total": {
    "inputTokens": 1840,
    "outputTokens": 1840,
    "cacheReadTokens": 1840,
    "cacheCreationTokens": 1840
  },
  "rows": [
    {
      "runId": "6660c4a1f2e3b7d8a9c01234",
      "seq": 1,
      "modelTier": "modeltier",
      "inputTokens": 1840
    }
  ],
  "credits": {
    "total": 42,
    "runs": [
      {
        "chargedCredits": 5,
        "isBillable": true,
        "createdAt": "2026-10-15T14:30:00Z"
      }
    ]
  }
}
```
