Skip to main content
Api

Conversations

Read raw conversation messages

GET
/agents/{agentId}/conversations
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

agentId*string

Agent UUID or URL-encoded agent name

Query Parameters

user_id*string

End-user identifier

session_id*string

Runtime session identifier

page?integer

1-based page number

Formatint64
page_size?integer

Page size. Defaults to 100, capped at 200.

Formatint64

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/agents/string/conversations?user_id=string&session_id=string"
{
  "$schema": "/api/v1/schemas/GetAgentConversationOutputBody.json",
  "agent_id": "string",
  "has_more": true,
  "messages": [
    {
      "author": "string",
      "content": "string",
      "role": "string",
      "timestamp": "2019-08-24T14:15:22Z",
      "tool_call_id": "string",
      "tool_calls": [
        {
          "function": {
            "arguments": "string",
            "name": "string"
          },
          "id": "string",
          "type": "string"
        }
      ]
    }
  ],
  "page": 0,
  "page_size": 0,
  "session_id": "string",
  "total": 0,
  "user_id": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

List conversations

GET
/conversations
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Query Parameters

project_id?string

Project UUID; defaults to authenticated project/default project

channel?string

Filter by channel type

agent_id?string

Filter by agent id

user_id?string

Filter by user id

controller?string

Filter by controller: agent|human

status?string

Filter by status: open|snoozed|closed

q?string

Search user, agent, or preview text

search?string

Legacy alias for q

agent?string

Legacy alias for agent_id

tier?string

Legacy memory-timeline tier filter

limit?integer

Max items (default 50, max 100)

Formatint64
cursor?string

Pagination cursor

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/conversations"
{
  "$schema": "/api/v1/schemas/ListConversationsOutputBody.json",
  "conversations": [
    {
      "agent": "string",
      "agent_name": "string",
      "channel": "string",
      "controller": "string",
      "controller_operator_id": "string",
      "cost_usd": 0.1,
      "created_at": "2019-08-24T14:15:22Z",
      "crm_lead_id": "string",
      "crm_owner_id": "string",
      "handoffs": [
        {
          "from": "string",
          "to": "string",
          "when": "string"
        }
      ],
      "id": "string",
      "last_activity": "2019-08-24T14:15:22Z",
      "last_message": "string",
      "model": "string",
      "session_id": "string",
      "status": "string",
      "tags": [
        "string"
      ],
      "tier": "string",
      "title": "string"
    }
  ],
  "has_more": true,
  "items": [
    {
      "agent": "string",
      "agent_name": "string",
      "channel": "string",
      "controller": "string",
      "controller_operator_id": "string",
      "cost_usd": 0.1,
      "created_at": "2019-08-24T14:15:22Z",
      "crm_lead_id": "string",
      "crm_owner_id": "string",
      "handoffs": [
        {
          "from": "string",
          "to": "string",
          "when": "string"
        }
      ],
      "id": "string",
      "last_activity": "2019-08-24T14:15:22Z",
      "last_message": "string",
      "model": "string",
      "session_id": "string",
      "status": "string",
      "tags": [
        "string"
      ],
      "tier": "string",
      "title": "string"
    }
  ],
  "next_cursor": "string",
  "total": 0
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Push a proactive agent message to a user's connected channel

POST
/conversations/push
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/conversations/push" \  -H "Content-Type: application/json" \  -d '{    "agent_id": "string",    "content": "string",    "user_id": "string"  }'
{
  "$schema": "/api/v1/schemas/PushConversationMessageOutputBody.json",
  "channel_message_id": "string",
  "channel_type": "string",
  "conversation_id": "string",
  "delivery_status": "string",
  "external_id": "string",
  "session_id": "string",
  "used_template": true
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Stream conversation events

GET
/conversations/stream
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Query Parameters

project_id?string

Project UUID; defaults to authenticated project/default project

Response Body

text/event-stream

application/problem+json

curl -X GET "https://loading/api/v1/conversations/stream"
Empty
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Get conversation

GET
/conversations/{id}
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Conversation UUID

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/conversations/string"
{
  "$schema": "/api/v1/schemas/ConversationDetailBody.json",
  "conversation": {
    "$schema": "/api/v1/schemas/OmnichannelConversationDTO.json",
    "agent_id": "string",
    "channel_type": "string",
    "connection_id": "string",
    "controller": "string",
    "controller_operator_id": "string",
    "conversation_id": "string",
    "created_at": "2019-08-24T14:15:22Z",
    "handoffs": null,
    "last_direction": "string",
    "last_message_at": "2019-08-24T14:15:22Z",
    "last_message_preview": "string",
    "meta": null,
    "project_id": "string",
    "session_id": "string",
    "status": "string",
    "takeover_started_at": "2019-08-24T14:15:22Z",
    "unread_count": 0,
    "updated_at": "2019-08-24T14:15:22Z",
    "user_id": "string"
  },
  "source": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Update conversation

PATCH
/conversations/{id}
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Conversation UUID

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X PATCH "https://loading/api/v1/conversations/string" \  -H "Content-Type: application/json" \  -d '{}'
{
  "$schema": "/api/v1/schemas/OmnichannelConversationDTO.json",
  "agent_id": "string",
  "channel_type": "string",
  "connection_id": "string",
  "controller": "string",
  "controller_operator_id": "string",
  "conversation_id": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "handoffs": null,
  "last_direction": "string",
  "last_message_at": "2019-08-24T14:15:22Z",
  "last_message_preview": "string",
  "meta": null,
  "project_id": "string",
  "session_id": "string",
  "status": "string",
  "takeover_started_at": "2019-08-24T14:15:22Z",
  "unread_count": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Permanently delete a conversation and its transcript

DELETE
/conversations/{id}
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Conversation UUID

Response Body

application/json

application/problem+json

curl -X DELETE "https://loading/api/v1/conversations/string"
{
  "$schema": "/api/v1/schemas/DeleteConversationOutputBody.json",
  "conversation_id": "string",
  "deleted": true
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

List conversation messages

GET
/conversations/{id}/messages
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Conversation UUID

Query Parameters

limit?integer

Max messages (default 50, max 200)

Formatint64
cursor?string

Pagination cursor

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/conversations/string/messages"
{
  "$schema": "/api/v1/schemas/ListConversationMessagesOutputBody.json",
  "has_more": true,
  "items": [
    {
      "attachments": null,
      "author_id": "string",
      "author_type": "string",
      "channel_message_id": "string",
      "content": "string",
      "conversation_id": "string",
      "created_at": "2019-08-24T14:15:22Z",
      "delivery_detail": "string",
      "delivery_status": "string",
      "direction": "string",
      "message_id": "string",
      "role": "string",
      "session_id": "string"
    }
  ],
  "messages": [
    {
      "attachments": null,
      "author_id": "string",
      "author_type": "string",
      "channel_message_id": "string",
      "content": "string",
      "conversation_id": "string",
      "created_at": "2019-08-24T14:15:22Z",
      "delivery_detail": "string",
      "delivery_status": "string",
      "direction": "string",
      "message_id": "string",
      "role": "string",
      "session_id": "string"
    }
  ],
  "next_cursor": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Send operator message

POST
/conversations/{id}/messages
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/conversations/string/messages" \  -H "Content-Type: application/json" \  -d '{    "content": "string"  }'
{
  "$schema": "/api/v1/schemas/OmnichannelConversationDTO.json",
  "agent_id": "string",
  "channel_type": "string",
  "connection_id": "string",
  "controller": "string",
  "controller_operator_id": "string",
  "conversation_id": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "handoffs": null,
  "last_direction": "string",
  "last_message_at": "2019-08-24T14:15:22Z",
  "last_message_preview": "string",
  "meta": null,
  "project_id": "string",
  "session_id": "string",
  "status": "string",
  "takeover_started_at": "2019-08-24T14:15:22Z",
  "unread_count": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Mark conversation read

POST
/conversations/{id}/read
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Conversation UUID

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/conversations/string/read"
{
  "$schema": "/api/v1/schemas/OmnichannelConversationDTO.json",
  "agent_id": "string",
  "channel_type": "string",
  "connection_id": "string",
  "controller": "string",
  "controller_operator_id": "string",
  "conversation_id": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "handoffs": null,
  "last_direction": "string",
  "last_message_at": "2019-08-24T14:15:22Z",
  "last_message_preview": "string",
  "meta": null,
  "project_id": "string",
  "session_id": "string",
  "status": "string",
  "takeover_started_at": "2019-08-24T14:15:22Z",
  "unread_count": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Take over conversation

POST
/conversations/{id}/takeover
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Query Parameters

force?boolean
operator_id?string

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/conversations/string/takeover"
{
  "$schema": "/api/v1/schemas/OmnichannelConversationDTO.json",
  "agent_id": "string",
  "channel_type": "string",
  "connection_id": "string",
  "controller": "string",
  "controller_operator_id": "string",
  "conversation_id": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "handoffs": null,
  "last_direction": "string",
  "last_message_at": "2019-08-24T14:15:22Z",
  "last_message_preview": "string",
  "meta": null,
  "project_id": "string",
  "session_id": "string",
  "status": "string",
  "takeover_started_at": "2019-08-24T14:15:22Z",
  "unread_count": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Release conversation takeover

DELETE
/conversations/{id}/takeover
AuthorizationBearer <token>

API key issued to a Sonzai project. Format: Bearer sk_....

In: header

Path Parameters

id*string

Response Body

application/json

application/problem+json

curl -X DELETE "https://loading/api/v1/conversations/string/takeover"
{
  "$schema": "/api/v1/schemas/OmnichannelConversationDTO.json",
  "agent_id": "string",
  "channel_type": "string",
  "connection_id": "string",
  "controller": "string",
  "controller_operator_id": "string",
  "conversation_id": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "handoffs": null,
  "last_direction": "string",
  "last_message_at": "2019-08-24T14:15:22Z",
  "last_message_preview": "string",
  "meta": null,
  "project_id": "string",
  "session_id": "string",
  "status": "string",
  "takeover_started_at": "2019-08-24T14:15:22Z",
  "unread_count": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}