> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 文本搜索对话消息

GET https://api.elevenlabs.io/v1/convai/conversations/messages/text-search

通过全文和模糊搜索查找对话转录消息

Reference: https://elevenlabs.io/docs/api-reference/conversations/messages/text-search

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Query parameters

- `text_query` (string, required) — 用于全文和模糊匹配的搜索查询文本
- `agent_id` (string, optional, nullable) — 智能体 id（agent_…）或语音引擎外部 id（seng_），均会解析为同一底层资源。
- `visited_agent_ids` (list of string, optional, nullable) — 筛选任一指定智能体参与过的对话。最多不超过 50 个值。
- `visited_agent_branch_ids` (list of string, optional, nullable) — 筛选任一指定智能体分支参与过的对话。最多不超过 50 个值。
- `triggered_procedure_ids` (list of string, optional, nullable) — 筛选触发过任一指定流程的对话。最多不超过 50 个值。
- `call_successful` (enum, optional, nullable) — 成功评估结果
  - Allowed values: `success`, `failure`, `unknown`, `error`
- `call_start_before_unix` (integer, optional, nullable) — 用于筛选截至此开始日期对话的 Unix 时间戳（秒）。
- `call_start_after_unix` (integer, optional, nullable) — 用于筛选此开始日期之后对话的 Unix 时间戳（秒）。
- `call_duration_min_secs` (integer, optional, nullable) — 最短通话时长，单位为秒。
- `call_duration_max_secs` (integer, optional, nullable) — 最长通话时长，单位为秒。
- `rating_max` (integer, optional, nullable) — 总体评分上限（1-5）。
- `rating_min` (integer, optional, nullable) — 总体评分下限（1-5）。
- `has_feedback_comment` (boolean, optional, nullable) — 筛选含有用户反馈评论的对话。
- `user_id` (string, optional, nullable) — 按发起对话的用户 ID 筛选对话。
- `evaluation_params` (list of string, optional, nullable) — 评估筛选条件。可重复传入此参数。格式：criteria_id:result，其中 result 为 success|failure|unknown 之一。示例：eval=value_framing:success
- `data_collection_params` (list of string, optional, nullable) — 数据收集筛选条件。可重复使用该参数。格式：id:op:value，其中 op 为 eq|neq|gt|gte|lt|lte|in 之一。对于 in，使用竖线分隔值。空值匹配未收集该字段的对话（id:eq:）；使用空值的 neq 匹配已收集该字段的对话（id:neq:）。eq 表示完全相等。gt|gte|lt|lte 需要数值。
- `dynamic_variable_params` (list of string, optional, nullable) — 动态变量筛选条件。可重复使用该参数。格式：name:op:value，其中 op 为 eq|neq|gt|gte|lt|lte|in 之一。对于 in，值以竖线分隔。空值匹配未设置该变量的对话（name:eq:），使用空值的 neq 则匹配已设置该变量的对话（name:neq:）。eq 表示完全相等。gt|gte|lt|lte 需要数值。名称中包含 ':' 时无法表示。
- `tool_names` (list of string, optional, nullable) — 按通话期间使用的工具名称筛选对话。
- `tool_names_successful` (list of string, optional, nullable) — 按调用成功的工具名称筛选对话。
- `tool_names_errored` (list of string, optional, nullable) — 按调用出错的工具名称筛选对话。
- `include_invalid_tool_calls` (boolean, optional, default: false) — 同时匹配从未运行的工具调用。
- `main_languages` (list of string, optional, nullable) — 按检测到的主要语言（语言代码）筛选对话。
- `exclude_statuses` (list of enum, optional, nullable) — 排除具有指定状态的对话。适用于在列表视图中隐藏进行中/处理中对话。
  - Allowed values: `initiated`, `in-progress`, `processing`, `done`, `failed`
- `termination_reasons` (list of string, optional, nullable) — 按存储的 termination_reason（metadata.termination_reason）筛选对话。重复传入参数可匹配多个值中的任意一个。
- `page_size` (integer, optional, default: 20) — 每页结果数量。最大为 50。
- `summary_mode` (enum, optional, default: exclude) — 是否在响应中包含转录摘要。
  - Allowed values: `exclude`, `include`
- `conversation_initiation_source` (enum, optional, nullable, default: unknown) — 表示对话发起来源的枚举。
  - Allowed values: `unknown`, `android_sdk`, `node_js_sdk`, `react_native_sdk`, `react_sdk`, `js_sdk`, `python_sdk`, `widget`, `sip_trunk`, `twilio`, `exotel`, `genesys`, `avaya`, `audiocodes`, `swift_sdk`, `whatsapp`, `twilio_sms`, `flutter_sdk`, `zendesk_integration`, `slack_integration`, `telegram_integration`, `intercom_integration`, `freshdesk_integration`, `salesforce_integration`, `template_preview`, `genesys_bot_connector`, `subagent_tool`
- `text_only` (boolean, optional, nullable)
- `conversation_product_type` (enum, optional, nullable) — 将结果限制为单个对话产品界面。
  - Allowed values: `agents`, `speech_engine`
- `branch_id` (string, optional, nullable) — 按分支 ID 筛选对话。
- `version_id` (string, optional, nullable) — 按版本 ID 筛选对话。
- `topic_ids` (list of string, optional, nullable) — 按主题发现期间分配的主题 ID 筛选对话。
- `sort_by` (enum, optional) — 搜索结果排序方式。'search_score' 按搜索评分排序，'created_at' 按对话开始时间排序。
  - Allowed values: `search_score`, `created_at`
- `cursor` (string, optional, nullable) — 用于获取下一页。响应中会返回游标。

## Response

### 200

成功响应

- `results` (list of MessagesSearchResult, required)
- `has_more` (boolean, required) — 是否还有更多可用结果
- `meta` (ListResponseMeta, optional)
- `next_cursor` (string, optional, nullable) — 用于获取下一页结果的游标

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### MessagesSearchResult

transcript_index：消息在对话转录中的索引。 chunk_text：转录文本；如果转录消息很长，可能包含多个块。 chunk_highlights：拆分为匹配和不匹配片段以供高亮显示的 chunk_text。 仅在关键词/文本搜索时填充，不适用于语义搜索。 score：消息与搜索查询的相似度评分。

- `conversation_id` (string, required)
- `agent_id` (string, required)
- `transcript_index` (integer, required)
- `chunk_text` (string, required)
- `score` (double, required)
- `conversation_start_time_unix_secs` (integer, required)
- `agent_name` (string, optional, nullable)
- `chunk_highlights` (list of SearchHighlightSegment, optional, nullable)

### ListResponseMeta

- `total` (integer, optional, nullable)
- `page` (integer, optional, nullable)
- `page_size` (integer, optional, nullable)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### SearchHighlightSegment

- `value` (string, required)
- `is_hit` (boolean, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Response**

```json
{
  "results": [
    {
      "conversation_id": "string",
      "agent_id": "string",
      "transcript_index": 1,
      "chunk_text": "string",
      "score": 1.1,
      "conversation_start_time_unix_secs": 1,
      "agent_name": "string",
      "chunk_highlights": [
        {
          "value": "string",
          "is_hit": true
        }
      ]
    }
  ],
  "has_more": true,
  "meta": {
    "total": 1,
    "page": 1,
    "page_size": 1
  },
  "next_cursor": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/conversations/messages/text-search"

querystring = {"agent_id":"agent_3701k3ttaq12ewp8b7qv5rfyszkz","call_successful":"success","text_query":"refund policy"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/conversations/messages/text-search?agent_id=agent_3701k3ttaq12ewp8b7qv5rfyszkz&call_successful=success&text_query=refund+policy")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```