---
docId: doc_91bf359e7d964150bc325fa2d1ea5ffa
version: v1
versionGroup: conversations-search
title: Search conversations
description: Search conversations by words or meaning, choose response fields and export results to CSV.
api:
  group: conversaciones
  auth: bearer
  operations:
    - operationId: searchConversations
      method: POST
      path: /v1/search/conversations
      postmanName: Search Conversations
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Search conversations

Search conversations by words, meaning or both. Hybrid search combines the results without repeating conversations. Choose which fields to return; messages, phone and email are excluded by default.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/search/conversations \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "the customer wants to cancel because the charge was duplicated",
    "mode": "hybrid",
    "filters": { "start_date": "2030-01-01" },
    "page_size": 20
  }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
const page = await platic.search.conversations({
  query: "refund",
  filters: { startDate: "2030-01-01" },
  limit: 20,
});
// page.data, page.total, page.nextPageToken

for await (const result of platic.search.iterate({ query: "refund" })) {
  console.log(result.id);
}
```

Read results in `page.data` and the total in `page.total`. To continue, send `page.nextPageToken` as `pageToken`. `iterate` reads results up to `candidateLimit`.

</Ways.Way>
</Ways>

## Request body

```json
{
  "query": "the customer wants to cancel because the charge was duplicated",
  "mode": "hybrid",
  "filters": {
    "start_date": "2026-07-01",
    "tags": { "any": ["cancellation", "billing"], "none": ["test"] },
    "platforms": ["whatsapp", "instagram"],
    "is_finished": true
  },
  "page_size": 20,
  "response": {
    "fields": ["id", "contactName", "topic", "tags", "snippet", "score", "sources"]
  }
}
```

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `query` | string, max. 2000 | `"*"` | Text for the lexical search and, if there are no explicit variants, for the semantic one. You can omit it when exploring by filters. |
| `semantic_queries` | string or string[] | — | One semantic query or up to 5 variants; the best match per conversation is kept. |
| `mode` | `hybrid`, `lexical` or `semantic` | `hybrid` | Selects the engines. |
| `kind` | `chat`, `post` or `all` | `chat` | `chat` leaves out comment posts; `post` searches only them; `all` searches both. Each result carries `kind`. |
| `filters` | object | `{}` | Advanced filters; see the table below. |
| `page` | integer ≥ 1 | `1` | Requested page. |
| `page_size` | integer 1-100 | `10` | Results per page. |
| `candidate_limit` | integer 25-1000 | `250` | Fixed window of candidates retrieved and merged before paginating. Use the same value when you walk through pages. |
| `semantic_score_threshold` | number 0-2 | `0.8` | Maximum semantic distance. Results with a distance below the threshold are accepted; a lower value demands higher similarity. |
| `ranking` | object | weights `0.5`, `rrf_k: 60` | Engine weights and the RRF constant. |
| `response` | object | compact projection | Controls fields, results, analytics, diagnostics and text limits. |
| `export_csv` | boolean or object | `false` | Generates a CSV with a signed URL. |

### Search modes

| Mode | Engine | When to use it |
|------|--------|----------------|
| `hybrid` | Lexical + semantic | Recommended. Combines textual and conceptual matches with Reciprocal Rank Fusion (RRF). |
| `lexical` | Lexical | For words, names, phone numbers, emails or exact phrases. `query: "*"` lets you explore with filters and recency only. |
| `semantic` | Semantic | To find conversations with the same meaning even if they use other words. Requires a `query` other than `"*"`, or `semantic_queries`. |

In `hybrid` mode, `query` is also used as the semantic query when you do not send `semantic_queries`. If there is no semantic query at all, the search continues with the lexical branch only and says so in `warnings`. If you send `semantic_queries` without `query`, the lexical branch is skipped so semantic matches are not mixed with a general listing by recency.

### Filters

Each text filter accepts a string or an array of up to 50 strings. Filters are applied to the result of both engines.

| Field | Type | Description |
|-------|------|-------------|
| `start_date`, `end_date` | ISO 8601 date | Inclusive range. If omitted, it searches from the last 90 days up to now. A `YYYY-MM-DD` date covers the whole day. |
| `date_field` | `lastUpdate` or `creationDate` | Date used by the range. Default: `lastUpdate`. |
| `tags` | string, string[] or object | A string or list is the same as `any`. The object accepts `any`, `all` and `none` to include any tag, require all of them or exclude tags. |
| `platforms` | string or string[] | Platforms, for example `whatsapp`, `instagram` or `messenger`. |
| `exclude_platforms` | string or string[] | Platforms that must not appear. |
| `topics` | string or string[] | Conversation topics. |
| `statuses` | string or string[] | Searchable statuses: `active`, `finished` or `spam`. |
| `agents` | string or string[] | Agent IDs/paths. |
| `channel_ids` | string or string[] | Channel IDs. |
| `operations` | string or string[] | Operation modes. |
| `owner_ids` | string or string[] | Owner IDs. |
| `conversation_ids` | string or string[] | Thread IDs. |
| `client_ids` | string or string[] | Contact IDs. |
| `phone_numbers` | string or string[] | Exact phone numbers. |
| `has_phone` | boolean | Includes or excludes conversations with a phone number. |
| `is_finished` | boolean | Filters by finished conversation. |

### Hybrid ranking

```json
{
  "ranking": {
    "lexical_weight": 0.65,
    "semantic_weight": 0.35,
    "rrf_k": 60
  }
}
```

Each weight ranges from `0` to `1`. In hybrid mode, at least one must be greater than zero. RRF combines a conversation's position in the two result lists rather than comparing their relevance scales. Before sorting, duplicate semantic fragments are removed by conversation `id`.

The final `score` is normalized between `0` and `1`. Request `sources` to learn which engines found the result and `scores` to inspect `lexicalRank`, `lexicalTextMatch`, `semanticRank` and `semanticDistance`.

### Control the size of the response

By default, the response excludes messages, phone and email:

```json
{
  "response": {
    "fields": [
      "id", "contactName", "platform", "topic", "tags",
      "lastUpdate", "snippet", "conversationUrl", "score", "sources"
    ],
    "include_results": true,
    "include_analytics": false,
    "include_engine_metadata": false,
    "create_search_cache": false,
    "max_snippet_chars": 320,
    "max_content_chars": 2000
  }
}
```

`fields` accepts:

```text
id, conversationId, contactName, phoneNumber, email, platform, topic, tags,
status, agent, channelId, clientId, operation, owners, isFinished, creationDate,
lastUpdate, snippet, messages, conversationUrl, contactUrl, score, sources, scores
```

| Field | Range | Effect |
|-------|-------|--------|
| `include_results` | boolean | With `false`, omits `results`; useful to ask only for analytics, create a cache or export. |
| `include_analytics` | boolean | Adds counts by topic, tag, status, agent, platform and date. They are sampled counts over the merged window; check `analytics.scope`. |
| `include_engine_metadata` | boolean | Adds status, candidates, time and truncation of the lexical and semantic branches. |
| `create_search_cache` | boolean | Creates a temporary `searchId` for later flows and returns its expiry. |
| `max_snippet_chars` | integer 40-2000 | Maximum length of `snippet`. Default: `320`. |
| `max_content_chars` | integer 100-10000 | Maximum length of the matching passage in `messages`. It is not the full history. Default: `2000`. |

<Note type="tip">

For agents and automations, ask only for the fields you need. Use `snippet` to check relevance and request `messages` only when you need the matching passage. For the full history, use [Get a conversation](/api-reference/conversations/v1/get).

</Note>

### Export CSV

Send `"export_csv": true` to export the matches in the candidate window with the default column selection, or control both options:

```json
{
  "query": "cancellation request",
  "response": { "include_results": false },
  "export_csv": {
    "fields": ["id", "contactName", "phoneNumber", "topic", "lastUpdate", "conversationUrl"],
    "max_rows": 500
  }
}
```

`max_rows` limits the exported rows but does not widen `candidate_limit`. Exports that include `snippet` or `messages` are limited to 100 rows; without those fields they can include up to 1000.

The response includes `export.url`, `filename`, `rowCount`, `sizeBytes`, `truncated` and `expiresAt`. `downloadUrl` holds the same URL for compatibility. The file is private, the signed URL expires in 7 days and its cells are protected against spreadsheet formulas.

<Note type="warning">

The default export does include `phoneNumber` and `email`. Treat the signed URL as a temporary secret and use `export_csv.fields` to leave out personal data you do not need.

</Note>

## Response

Read the matches from `results` and use the fields below to check the search limits.

```json
{
  "success": true,
  "mode": "hybrid",
  "matchCount": 42,
  "candidateCount": 42,
  "totalFound": 42,
  "totalRelation": "lower_bound",
  "returnedCount": 2,
  "truncated": false,
  "fields": ["id", "contactName", "topic", "snippet", "score", "sources"],
  "results": [
    {
      "id": "conv_7a19",
      "contactName": "Ana",
      "topic": "Billing",
      "snippet": "...I'd like to cancel because there is a duplicate charge...",
      "score": 0.967213,
      "sources": ["lexical", "semantic"]
    }
  ],
  "pagination": {
    "currentPage": 1,
    "totalPages": 5,
    "pageSize": 10,
    "hasNextPage": true,
    "hasPreviousPage": false,
    "candidateWindow": 250
  },
  "tookMs": 183
}
```

| Field | Meaning |
|-------|---------|
| `candidateCount`, `matchCount`, `totalFound` | Unique conversations retrieved within the candidate window after deduplicating. |
| `totalRelation` | `exact` only for an untruncated lexical search; `lower_bound` for hybrid, semantic or truncated results. |
| `truncated` | `true` means an engine or the merge reached its limit; there may be more matches outside the window. |
| `returnedCount` | Items included in `results`; it is `0` when `include_results` is `false`. |
| `warnings` | Notices about degradation or result limits. |

The requested page must fit inside `candidate_limit`. The maximum window is 1000 conversations and it stays fixed so the order is preserved while paginating.

## Errors

| Status | When |
|--------|------|
| `400` | A field is invalid: a `page_size` or `candidate_limit` out of range, a page outside the candidate window, `semantic` mode without a query, or a weight outside `0`-`1` |
| `401` | Missing or invalid API key |

## Notes

### Engine availability

If you request both engines and only one is available, the search uses the available engine, adjusts the result order and reports this in `warnings`. Use `response.include_engine_metadata` to diagnose a problem; omit it when you do not need those details.
