Skip to content
QwryAI
Documentation
Pages

Endpoints

Search conversations

Find an agent's conversations whose messages contain a phrase, with the matching line

search_conversations looks through the messages of an agent's conversations for a phrase, across every channel, and returns each matching conversation with its first matching message. The match is literal and case-insensitive, not semantic. To filter by state, sentiment, channel, feedback or escalation instead, use List conversations. See Conversation Search for examples.

POSThttps://api.qwryai.com/public/v1/tools/search_conversations

Authentication

Send your API key as Authorization: Bearer <api-key>, or in an x-api-key header. The key needs Manage conversations and helpdesk. See Authentication.

Body parameters

NameTypeRequiredDescription
chatbotIdstringYesThe agent's id, from List agents.
querystringYesThe phrase to find, 2 to 200 characters, matched as written.
startDatestringYesConversations created from this day, YYYY-MM-DD in UTC.
endDatestringYesConversations created up to this day, included. At most 184 days after startDate.
senderstringNoOnly match messages from customer, ai or agent. Leave it out to match any.
topicstringNoOnly conversations tagged with this Analytics topic.
limitintegerNoResults to return, 1 to 50. Defaults to 20.

Request example

Bash
curl -X POST 'https://api.qwryai.com/public/v1/tools/search_conversations' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "chatbotId": "YOUR_AGENT_ID",
    "query": "refund",
    "sender": "customer",
    "startDate": "2026-11-01",
    "endDate": "2026-11-30"
  }'

Response

JSON
{
  "success": true,
  "data": {
    "items": [
      {
        "conversation": {
          "_id": "CONVERSATION_RECORD_ID",
          "conversationId": "3c3766ae-0119-4687-b992-a7f6219d9b29",
          "channel": "whatsapp",
          "lifecycle": "open",
          "metadata": { "aiSummary": "Customer asks when the refund for order 1042 will arrive." },
          "timestamps": { "created": "2026-11-09T18:29:40.658Z", "lastActivity": "2026-11-09T18:41:02.114Z" },
          "metrics": { "messageCount": 8, "aiMessageCount": 4, "agentMessageCount": 0 },
          "insights": { "sentiment": "negative" }
        },
        "match": {
          "sender": "customer",
          "timestamp": "2026-11-09T18:32:37.261Z",
          "excerpt": "I returned the jacket last week, when will my refund for order 1042 come through?",
          "matchingMessages": 2,
          "customerMatches": 2
        }
      }
    ],
    "searchedConversations": 391,
    "conversationsInRange": 391,
    "range": { "startDate": "2026-11-01", "endDate": "2026-11-30" },
    "timezone": "UTC",
    "sender": "customer",
    "coverage": "Case-insensitive literal match on customer message text in the 391 most recent conversations created in this range. Not semantic search."
  }
}
FieldDescription
items[].conversationThe conversation, with the same fields as List conversations. Pass its _id to Get a conversation.
items[].match.senderWho wrote the first matching message: customer, ai or agent.
items[].match.excerptUp to 300 characters of that message.
items[].match.matchingMessagesHow many messages in the conversation matched.
items[].match.customerMatchesHow many of those the customer wrote.
searchedConversationsHow many conversations were searched.
conversationsInRangeHow many conversations the range holds.
coverageWhat was searched, in words.

Errors

HTTP statusCodeWhen
400INVALID_ARGUMENTSquery is missing or under 2 characters, a date isn't YYYY-MM-DD, or limit is out of range. issues lists each one.
400CHATBOT_ID_REQUIREDThe body has no valid chatbotId.
401API_KEY_REQUIRED / INVALID_API_KEYNo credential, or an unknown, deleted or expired one.
403INSUFFICIENT_PERMISSIONThe key doesn't hold Manage conversations and helpdesk.
404CHATBOT_NOT_FOUNDNo agent with that chatbotId in your workspace.
409VALIDATION_INVALID_BODYendDate is before startDate, or the range is longer than 184 days.
413RESULT_TOO_LARGEThe answer is over 40,000 bytes. Lower limit.
429INTEGRATION_RATE_LIMIT_EXCEEDEDMore than 2,000 requests in 15 minutes.

See Error Handling for every code.

Explore the documentation