Search conversations

POST/v2/agents/{agentId}/conversations/search

Find the conversations of an agent that mention a word or phrase, then narrow the results by status, channel and creation date.

Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.

Finds conversations by the words in their messages and returns each hit with a snippet. Call it to see which conversations mention a product, a promo code or a complaint. To list conversations without a text query, use List conversations.

Request

POST /v2/agents/{agentId}/conversations/search

Path parameters:

Name Type Required Description
agentId string Yes The ID of the agent, starting with agt_.

Body fields:

Name Type Required Description
query string Yes The word or phrase to look for.
filters object No Narrows the search.
filters.status array of strings No One or more of open, resolved and handoff.
filters.channel array of strings No One or more channels, for example widget or whatsapp.
filters.from string No Only conversations created at or after this ISO 8601 UTC time.
filters.to string No Only conversations created before this ISO 8601 UTC time.
limit integer No Items per page, from 1 to 100. Defaults to 20.
cursor string No The nextCursor value from the previous page.

A short, specific query works better than a whole sentence. The concept page Conversation search has tips for using the results to find gaps in your sources.

Example request

curl -X POST https://api.askocto.co/v2/agents/agt_8f3k2m/conversations/search \
  -H "Authorization: Bearer $OCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "refund",
    "filters": { "status": ["handoff"], "channel": ["widget"] },
    "limit": 20
  }'
const response = await fetch(
  "https://api.askocto.co/v2/agents/agt_8f3k2m/conversations/search",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.OCTO_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      query: "refund",
      filters: { status: ["handoff"], channel: ["widget"] },
      limit: 20,
    }),
  },
)

const { data, nextCursor } = await response.json()
for (const item of data) console.log(item.id, item.matches[0].snippet)

Example response

A successful call returns 200 OK.

{
  "data": [
    {
      "id": "conv_5n2p8w",
      "agentId": "agt_8f3k2m",
      "userId": "usr_3b6t0z",
      "channel": "widget",
      "status": "handoff",
      "messageCount": 6,
      "createdAt": "2026-03-20T13:58:00Z",
      "updatedAt": "2026-03-20T14:05:00Z",
      "matches": [
        {
          "messageId": "msg_4w7e1b",
          "snippet": "I would like a refund for the jacket, it arrived damaged."
        }
      ]
    }
  ],
  "nextCursor": null
}

Response fields

Each item is a conversation object, with the fields described in List conversations, plus one more field.

Name Type Description
data[].matches array The messages that matched. Each entry has messageId and a snippet with the text around the hit.
nextCursor string or null Pass it as cursor for the next page. null on the last page.

Errors

Status Code When
400 invalid_request query is missing or empty, limit is outside 1 to 100, or a filter has an unknown value.
401 unauthorized The API key is missing, malformed or deleted.
404 not_found No agent has this ID in your workspace.
429 rate_limited Too many requests. Wait for the number of seconds in the Retry-After header.

Something unclear or missing? Tell us and we will fix the page.