Skip to content

Conversations

The Conversations API stores and retrieves agent conversation history. Messages are indexed for full-text search using FTS5. Longer conversation histories can be summarized and then drilled into on demand.

Base path: /api/conversations

All endpoints require Authorization: Bearer <token>.


Store Message

Persists a single conversation message.

POST /api/conversations/store

Request body:

json
{
  "agentId": "backend-coder",
  "role": "assistant",
  "content": "I've implemented the pagination utility in src/lib/paginate.ts",
  "sessionId": "sess_01J...",
  "taskId": "tk_01J...",
  "metadata": {
    "model": "claude-sonnet-4-6",
    "tokensUsed": 842
  }
}
FieldTypeRequiredDescription
agentIdstringYesAgent name or ID this message belongs to
rolestringYesuser, assistant, or system
contentstringYesMessage text
sessionIdstringNoSession grouping identifier
taskIdstringNoAssociated task ID
metadataobjectNoModel info, token counts, etc.

Response: 201 Created

json
{
  "success": true,
  "data": {
    "id": "msg_01J...",
    "agentId": "backend-coder",
    "role": "assistant",
    "sessionId": "sess_01J...",
    "createdAt": "2026-04-03T12:01:00Z"
  }
}

curl:

bash
curl -X POST "https://api.cortex.acrobi.com/api/conversations/store" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "agentId": "backend-coder",
    "role": "assistant",
    "content": "I have implemented the pagination utility",
    "sessionId": "sess_01J..."
  }'

Search Conversations

Full-text search over conversation content using FTS5.

GET /api/conversations/search

Query parameters:

ParameterTypeRequiredDescription
qstringYesSearch query
agentIdstringNoRestrict to a specific agent
rolestringNouser, assistant, or system
sessionIdstringNoRestrict to a session
sincestringNoISO 8601 timestamp — only messages after this
limitnumberNoDefault 20, max 100
offsetnumberNoDefault 0

Response:

json
{
  "success": true,
  "data": [
    {
      "id": "msg_01J...",
      "agentId": "backend-coder",
      "role": "assistant",
      "content": "I've implemented the pagination utility in src/lib/paginate.ts",
      "score": 0.92,
      "sessionId": "sess_01J...",
      "taskId": "tk_01J...",
      "createdAt": "2026-04-03T12:01:00Z"
    }
  ],
  "pagination": { "limit": 20, "offset": 0, "total": 3 }
}

curl:

bash
curl "https://api.cortex.acrobi.com/api/conversations/search?q=pagination+utility&agentId=backend-coder" \
  -H "Authorization: Bearer <token>"

List Conversations for Agent

Returns paginated message history for a specific agent, ordered by most recent first.

GET /api/conversations/:agentId

Query parameters:

ParameterTypeDescription
sessionIdstringFilter to a specific session
taskIdstringFilter to messages for a task
rolestringFilter by role
limitnumberDefault 50, max 200
offsetnumberDefault 0

Response:

json
{
  "success": true,
  "data": [
    {
      "id": "msg_01J...",
      "role": "user",
      "content": "Implement pagination for the agents list endpoint",
      "sessionId": "sess_01J...",
      "taskId": "tk_01J...",
      "metadata": null,
      "createdAt": "2026-04-03T12:00:00Z"
    },
    {
      "id": "msg_02J...",
      "role": "assistant",
      "content": "I've implemented the pagination utility...",
      "sessionId": "sess_01J...",
      "taskId": "tk_01J...",
      "metadata": { "model": "claude-sonnet-4-6", "tokensUsed": 842 },
      "createdAt": "2026-04-03T12:01:00Z"
    }
  ],
  "pagination": { "limit": 50, "offset": 0, "total": 284 }
}

curl:

bash
curl "https://api.cortex.acrobi.com/api/conversations/backend-coder?limit=20" \
  -H "Authorization: Bearer <token>"

Conversation Overview

Returns a summary of the agent's conversation activity — total messages, sessions, time range, and top topics.

GET /api/conversations/:agentId/overview

Response:

json
{
  "success": true,
  "data": {
    "agentId": "backend-coder",
    "totalMessages": 284,
    "totalSessions": 31,
    "firstMessageAt": "2026-01-15T09:00:00Z",
    "lastMessageAt": "2026-04-03T12:01:00Z",
    "roleBreakdown": {
      "user": 102,
      "assistant": 178,
      "system": 4
    },
    "recentSessions": [
      {
        "sessionId": "sess_01J...",
        "messageCount": 12,
        "startedAt": "2026-04-03T12:00:00Z",
        "summary": "Implemented pagination for agents list"
      }
    ]
  }
}

Expand Conversation Summary

When a session has been condensed into a summary (to save context window), this endpoint retrieves the full turn-by-turn expansion.

GET /api/conversations/:agentId/expand

Query parameters:

ParameterTypeRequiredDescription
sessionIdstringYesSession to expand
limitnumberNoMax turns to return (default 100)

Response:

json
{
  "success": true,
  "data": {
    "sessionId": "sess_01J...",
    "agentId": "backend-coder",
    "summary": "Implemented pagination for agents list",
    "messages": [
      {
        "id": "msg_01J...",
        "role": "user",
        "content": "Implement pagination for the agents list endpoint",
        "createdAt": "2026-04-03T12:00:00Z"
      },
      {
        "id": "msg_02J...",
        "role": "assistant",
        "content": "I've implemented the pagination utility...",
        "createdAt": "2026-04-03T12:01:00Z"
      }
    ]
  }
}

Built by Acrobi