Search conversations

SDK platic.conversations.search()

Find conversations by words (lexical), by meaning (semantic) or both (hybrid, the default, which fuses the two rankings). Without a query, it explores by filters, newest first. Each result has the same shape as in List conversations, plus the search signals you ask for.

Without filters.from and filters.to, the search looks at the last 90 days. This request only reads, so read-only credentials can call it.

Example

const page = await platic.conversations.search({
  query: "refund",
  semanticQueries: ["customer asking for their money back"],
  filters: { platforms: ["whatsapp"], from: "2026-11-01" },
  fields: ["contactName", "topic", "snippet", "score", "sources"],
  limit: 10,
});
for (const hit of page.data) console.log(hit.id, hit.score, hit.snippet);
console.log(page.meta.search.totalRelation, page.meta.warnings);

// Every result, up to candidateLimit
for await (const hit of platic.conversations.iterateSearch({ query: "invoice", mode: "lexical", limit: 100 })) {
  console.log(hit.id);
}

iterateSearch follows nextPageToken and must finish within the 15-minute search session; after that it throws GoneError with code SEARCH_SESSION_EXPIRED. Use search when you need each page's included and meta.

Query parameters

ParameterTypeDescription
workspacestringThe workspace to read, for an API key that covers several. Other credentials always read their own workspace

Request body

Every field is optional. An empty body returns the most recent conversations of the last 90 days.

FieldTypeDefaultDescription
querystring, up to 2000—Words to search. Empty or "*" explores by filters, newest first, without the semantic search
semanticQueriesstring[], 1 to 5, each up to 500—Phrasings of what you mean, for the semantic search. Without them, query is used for meaning too
modestringhybridhybrid, lexical or semantic. See Search modes
kindstringchatchat: conversations. post: comment posts. all: both
filtersobject{}See Filters
rankingobjectsee belowHow hybrid fuses the two rankings. See Ranking
candidateLimitinteger, 25 to 1000250Candidates fused before paging. Pages never go past this window
limitinteger, 1 to 10010Results per page
pageTokenstring, up to 2048—The nextPageToken of the previous page. See Pagination
fieldsstring[]see belowFields to return. Replaces the defaults; id is always returned. See Fields and signals
includestring[][]Relations to resolve once per page in included: agents, channels, assignees. They work as in List conversations

Unknown body fields answer 400 INVALID_REQUEST.

Search modes

ModeWhat it doesNeeds
hybridRuns both searches and fuses their rankings with reciprocal rank fusion (RRF). A conversation found by both appears onceNothing. Without any query it explores by filters
lexicalMatches words: names, phone numbers, order numbers, exact phrasesNothing. query: "*" explores by filters, newest first
semanticMatches meaning, even when the conversation uses other wordsA query other than "*", or semanticQueries

In hybrid, query feeds both searches unless you send semanticQueries, which then drive the semantic one.

Filters

All filters are optional and apply to both searches. Lists take up to 50 values, each up to 500 characters; a conversation matches a list when it has any of its values. Different filters combine with AND.

FieldTypeDescription
contactIdsstring[]Only conversations of these contacts
channelIdsstring[]Only conversations on these channels
agentIdsstring[]Only conversations whose main agent is one of these
platformsstring[]Only these platforms: whatsapp, instagram, facebook, email, webchat…
excludePlatformsstring[]Leave out these platforms
statusesstring[]Only these visible states: initiated, active, finished, archived, spam
operationsstring[]Only these operations: automatic, supervised, assistance
topicsstring[]Only these topics
conversationIdsstring[]Only these conversation IDs
phoneNumbersstring[]Only conversations with these contact phone numbers
assigneeIdsstring[]Only conversations assigned to these team members (member ID or email) or to team
tagsobjectTag names: any (at least one), all (every one), none (none of them). Each is a list of up to 50
hasPhonebooleanOnly conversations whose contact has (true) or lacks (false) a phone number
isFinishedbooleanOnly closed (true) or open (false) conversation cycles
dateFieldstringThe date from and to apply to: lastActivityAt (default) or createdAt
fromstringEarliest date: a date (2026-11-01, the whole UTC day) or a date-time (2026-11-01T08:00:00Z)
tostringLatest date: a date (2026-11-30, the whole UTC day) or a date-time (2026-11-30T18:00:00Z)

A filter with an impossible value, such as from after to or an invalid date, answers 400 INVALID_FILTER.

Ranking

{
  "ranking": {
    "lexicalWeight": 0.65,
    "semanticWeight": 0.35,
    "rrfK": 60,
    "semanticThreshold": 0.8
  }
}
FieldRangeDefaultDescription
lexicalWeight0 to 10.5Weight of the lexical ranking in hybrid
semanticWeight0 to 10.5Weight of the semantic ranking in hybrid
rrfKinteger 1 to 20060Reciprocal rank fusion constant. A higher value flattens the advantage of the top positions
semanticThreshold0 to 20.8Largest cosine distance a semantic match may have. A lower value demands closer meaning

In hybrid, at least one weight must be above 0. With lexicalWeight: 0, send query or semanticQueries. RRF combines the position of each conversation in the two rankings; it does not compare their scales.

Fields and signals

Without fields, each result has:

id, contactId, contactName, platform, topic, lastActivityAt, snippet

fields accepts every conversation field and these search signals:

FieldTypeDescription
snippetstring | nullThe matching fragment, as plain text. null when the result matched by filters only
scorenumber | nullFused rank score (RRF). Higher is better. Compare it only within the same search
sourcesstring[]Which searches found the conversation: lexical, semantic or both
scoresobjectPer-search scores: scores.lexical (0 to 1, relative to the best lexical match among the candidates; higher is better) and scores.semanticDistance (cosine distance, 0 to 2; lower is better). A search that did not find the conversation is absent

An unknown field answers 400 INVALID_FIELD with the accepted names in details.allowed.

Response

{
  "status": "success",
  "data": [
    {
      "id": "8Yc2kQ1mZ0rTq4Lp7WvX",
      "contactId": "cl_3h7Jt9Q2",
      "contactName": "Ana López",
      "platform": "whatsapp",
      "topic": "Refund",
      "lastActivityAt": "2026-11-30T18:00:00.000Z",
      "snippet": "…I still have not received the refund for order 1042…",
      "score": 0.031,
      "sources": ["lexical", "semantic"],
      "scores": { "lexical": 0.92, "semanticDistance": 0.41 }
    }
  ],
  "nextPageToken": "c2Vzc2lvbjpleGFtcGxl",
  "pagination": { "limit": 10, "returnedCount": 1, "hasMore": true },
  "meta": {
    "fields": ["id", "contactId", "contactName", "platform", "topic", "lastActivityAt", "snippet", "score", "sources", "scores"],
    "include": [],
    "requestId": "req_7f3a",
    "search": {
      "mode": "hybrid",
      "totalRelation": "lower_bound",
      "candidateWindow": 250,
      "engines": {
        "lexical": { "status": "ok", "candidates": 120, "found": 1340 },
        "semantic": { "status": "ok", "candidates": 180 }
      }
    },
    "warnings": []
  }
}
FieldDescription
dataResults of this page, in rank order
includedRelated records, only when you sent include
nextPageTokenToken of the next page; null on the last one
paginationlimit, returnedCount and hasMore (always the same as nextPageToken !== null)
meta.search.modeThe mode that ran
meta.search.totalRelationHow complete the results are: exact (every match), lower_bound (there may be more matches) or candidate_window (cut at candidateWindow)
meta.search.candidateWindowCandidates fused before paging
meta.search.engines.lexicalstatus (ok, skipped when the request did not need it, failed), candidates it contributed and, when known, found: the total matches it reported
meta.search.engines.semanticstatus and candidates, as above
meta.warningsNotices about this answer. See below

Warnings

A warning does not fail the request. Each one has code and message, and some add id or engine.

codeMeaning
SEARCH_ENGINE_FAILEDIn hybrid, one search failed and the results come from the other one. engine says which failed (lexical or semantic)
UNKNOWN_STATUSThe conversation in id has a stored state the API does not know; its status is null

Pagination

  • Send nextPageToken as pageToken with the same query and filters. You can change limit, fields and include.
  • The ranked results are kept for 15 minutes from the first page. After that, pageToken answers 410 SEARCH_SESSION_EXPIRED: repeat the search without it.
  • A token with another query, filter set, workspace or credential answers 400 INVALID_CURSOR.
  • Pages never go past candidateLimit. To reach more results, raise it (up to 1000) or narrow the filters.
  • Every page is checked again against the credential: a conversation deleted or out of reach since the search started is left out, so a page can be shorter than limit. Keep going until nextPageToken is null.

Who sees what

The search returns only conversations the credential may read, in every mode. An OAuth connection acts as the person who authorized it: if their role only reaches assigned conversations, the results, found and the other totals cover only those assigned to them or to team. A permission revoked between pages applies to the next page.

Errors

Statusdetails.codeWhen it happens
400INVALID_REQUESTThe body is invalid: a value out of range, an unknown field, semantic mode without a query, both weights at 0, or lexicalWeight: 0 without a query. details.issues says which
400INVALID_REQUESTThe workspace in ?workspace= is not covered by the credential. details.available lists the ones it covers
400INVALID_FIELDA name in fields does not exist. details.allowed lists the accepted ones
400INVALID_INCLUDEA name in include does not exist. details.allowed lists the accepted ones
400INVALID_FILTERA filter has an impossible value, for example from after to or an invalid date
400INVALID_CURSORThe pageToken belongs to another query, filter set, workspace or credential. Repeat the search without it
401UNAUTHENTICATEDThe credential is missing or invalid
403FORBIDDENThe credential has no access to conversations in this workspace
410SEARCH_SESSION_EXPIREDMore than 15 minutes passed since the first page. Repeat the search without pageToken
503SEARCH_UNAVAILABLEThe search this request needs is temporarily unavailable. details.retryable is true; details.engine names the search when only one was needed. Try again

The general error format is in Errors.

Notes

  • With kind: "post" or "all", results can be comment posts. Read those in Posts: Get a conversation answers 404 NOT_A_CONVERSATION for them.
  • score and scores describe the order of one search. Do not compare them across searches or store them as a quality measure.