Chat API

API endpoints for managing chat sessions and messages with AI agents

Manage chat sessions and messages with AI agents.

Access: Publishable Key (pk_live_*) | Secret Key (sk_live_*)


Create Chat

Creates a new chat session.

POST /chat

Request Body:

{
  "agentId": "string",
  "userId": "string (optional)",
  "metadata": {}
}

Response 200 OK:

{
  "id": "string",
  "agentId": "string",
  "teamId": "string",
  "createdAt": "2024-01-15T10:30:00Z"
}

List Chats

Retrieves all chat sessions for the authenticated team.

GET /chat

Query Parameters:

ParameterTypeDescription
userIdstringFilter chats by user ID
agentTypestringFilter chats by agent type

Response 200 OK:

{
  "chats": [
    {
      "id": "string",
      "agentId": "string",
      "userId": "string",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ]
}

Get Chat by ID

Retrieves a specific chat session.

GET /chat/:chatId

Path Parameters:

ParameterTypeDescription
chatIdstringThe chat session ID

Response 200 OK:

{
  "id": "string",
  "agentId": "string",
  "teamId": "string",
  "messages": [],
  "createdAt": "2024-01-15T10:30:00Z"
}

Delete Chat

Deletes a chat session.

DELETE /chat/:chatId

Path Parameters:

ParameterTypeDescription
chatIdstringThe chat session ID

Response 204 No Content


Create Message

Sends a message to a chat session.

POST /chat/:chatId/message

Path Parameters:

ParameterTypeDescription
chatIdstringThe chat session ID

Request Body:

{
  "content": "string",
  "role": "user"
}

Response 200 OK:

{
  "id": "string",
  "chatId": "string",
  "content": "string",
  "role": "assistant",
  "createdAt": "2024-01-15T10:30:00Z"
}

List Messages

Retrieves all messages for a chat session.

GET /chat/:chatId/message

Path Parameters:

ParameterTypeDescription
chatIdstringThe chat session ID

Response 200 OK:

{
  "messages": [
    {
      "id": "string",
      "content": "string",
      "role": "user | assistant",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ]
}