> 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/knowledge-base/search

ナレッジベースドキュメントのコンテンツに対するあいまいテキスト検索

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/knowledge-base/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

- `query` (string, required) — 検索クエリテキスト
- `page_size` (integer, optional, default: 30) — 返すドキュメントの最大数です。100を超えることはできず、デフォルトは30です。
- `types` (enum, optional) — 指定した場合、エンドポイントは指定された種類のドキュメントのみを返します。
  - Allowed values: `file`, `url`, `text`, `folder`
- `cursor` (string, optional) — 次のページを取得するために使用します。カーソルはレスポンスで返されます。

## Response

### 200

成功レスポンス。

- `results` (list of KnowledgeBaseContentSearchResult, required)
- `next_cursor` (string, optional)

## Errors

### 422 Knowledge Base Search Request Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### KnowledgeBaseContentSearchResult

- `document` (KnowledgeBaseContentSearchResultDocument, required)
- `score` (double, required)
- `search_snippet` (list of SearchHighlightSegment, optional)

### ValidationError

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

### KnowledgeBaseContentSearchResultDocument

- `type`: `file`
  - `access_info` (ResourceAccessInfo, required)
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `dependent_agents` (list of GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem, required, deprecated) — このフィールドは非推奨であり、今後削除されます。代わりに別のエンドポイントを使用して依存エージェントを取得してください。
  - `auto_sync_info` (AutoSyncInfo, optional)
  - `external_sync_info` (ExternalFileSyncInfo, optional) — 外部ソース内の元のファイルへのリンクを追跡します。
  - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
  - `is_frozen` (boolean, optional, default: false)
  - `refresh_status` (FileRefreshStatus, optional) — 外部同期KBファイルの進行中／直近の更新状態です。
- `type`: `folder`
  - `access_info` (ResourceAccessInfo, required)
  - `children_count` (integer, required)
  - `document_count` (integer, required) — このフォルダのサブツリー内にある非フォルダドキュメント数（再帰的）。カウントは1000を超えると停止します。
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `dependent_agents` (list of GetKnowledgeBaseSummaryFolderResponseModelDependentAgentsItem, required, deprecated) — このフィールドは非推奨であり、今後削除されます。代わりに別のエンドポイントを使用して依存エージェントを取得してください。
  - `auto_sync_info` (AutoSyncInfo, optional)
  - `external_sync_info` (ExternalFolderSyncInfo, optional) — 外部ソースフォルダをミラーリングするナレッジベースフォルダのメタデータ。
  - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
  - `is_frozen` (boolean, optional, default: false)
- `type`: `text`
  - `access_info` (ResourceAccessInfo, required)
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `dependent_agents` (list of GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem, required, deprecated) — このフィールドは非推奨であり、今後削除されます。代わりに別のエンドポイントを使用して依存エージェントを取得してください。
  - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
- `type`: `url`
  - `access_info` (ResourceAccessInfo, required)
  - `id` (string, required)
  - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
  - `name` (string, required)
  - `supported_usages` (list of enum, required)
    - Allowed values: `prompt`, `auto`
  - `url` (string, required)
  - `dependent_agents` (list of GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem, required, deprecated) — このフィールドは非推奨であり、今後削除されます。代わりに別のエンドポイントを使用して依存エージェントを取得してください。
  - `auto_sync_info` (AutoSyncInfo, optional)
  - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
  - `folder_path` (list of KnowledgeBaseFolderPathSegmentSummaryResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。

### SearchHighlightSegment

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

### ValidationErrorLocItem

### ResourceAccessInfo

- `is_creator` (boolean, required) — リクエストを行うユーザーがエージェントの作成者かどうか
- `creator_name` (string, required) — エージェント作成者の名前
- `creator_email` (string, required) — エージェント作成者のメールアドレス
- `role` (enum, required) — リクエストを行うユーザーのロール
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `anonymous_access_level_override` (enum, optional) — 匿名ユーザーのアクセスレベル。Noneの場合、このリソースは公開共有されません。
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `access_source` (enum, optional) — リクエストしたユーザーがこのリソースにアクセスできる理由。'creator'＝呼び出し元がオーナーです。'explicit'＝呼び出し元（またはそのワークスペースグループのいずれか）が、ワークスペース全体のeveryoneグループ以外としてrole_to_group_idsに記載されています。'workspace_default'＝ワークスペース全体のeveryoneグループがrole_to_group_idsに記載されています（管理者を含む、匿名ではないすべてのワークスペースメンバーがこのリソースを閲覧できます）。'workspace_admin'＝呼び出し元がワークスペース管理者であり、管理者シートがアクセスする*唯一*の経路です。これは他の誰も閲覧できないドキュメント用に予約されています。管理者バイパスの閲覧者が明示的に共有されていないドキュメントを閲覧できる理由をUIで表示できます。
  - Allowed values: `creator`, `explicit`, `workspace_admin`, `workspace_default`

### KnowledgeBaseDocumentMetadataResponseModel

- `created_at_unix_secs` (integer, required)
- `last_updated_at_unix_secs` (integer, required)
- `size_bytes` (integer, required)

### GetKnowledgeBaseSummaryFileResponseModelDependentAgentsItem

- `type`: `available`
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。
- `type`: `unknown`
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。

### AutoSyncInfo

- `minimum_frequency_days` (integer, optional, default: 7) — ドキュメントを更新する最小頻度（日数）。実際の間隔はこれより短くなる場合がありますが、長くなることはありません。
- `auto_remove` (boolean, optional, default: false) — URLが利用できなくなった場合にドキュメントを削除するかどうか
- `consec_failures` (integer, optional, default: 0) — 連続した同期失敗回数
- `next_refresh_by` (integer, optional) — 次回予定されている同期のUnixタイムスタンプ、またはNone（フォルダーの場合）
- `auto_discover` (boolean, optional, default: false, deprecated) — 非推奨です。このフィールドは現在は効果がなく、今後のリリースで削除されます。

### ExternalFileSyncInfo

外部ソース内の元のファイルへのリンクを追跡します。

- `type` ("google_drive", required) — プロバイダー識別子
- `source_entity_id` (string, required) — 外部システム内のエンティティID
- `integration_connection_id` (string, required) — インテグレーション接続インスタンスID
- `source_parent_entity_id` (string, required) — このファイルの同期元である外部システムのフォルダーID
- `source_mime_type` (string, required) — 外部システムでの元のMIMEタイプ
- `source_modified_time` (datetime, required) — 外部システムで最後に変更された日時
- `root_folder_id` (string, optional) — 同期ツリー配下のすべてのエンティティをクエリするために使用する、同期ルートのKBフォルダID

### KnowledgeBaseFolderPathSegmentSummaryResponseModel

- `id` (string, required)

### FileRefreshStatus

外部同期KBファイルの進行中／直近の更新状態です。

- `status` (enum, optional, default: queued)
  - Allowed values: `queued`, `processing`, `succeeded`, `failed`, `skipped`, `cancelled`
- `enqueued_at` (integer, optional)
- `started_at` (integer, optional)
- `completed_at` (integer, optional)
- `last_synced_at` (integer, optional)
- `error_message` (string, optional)

### GetKnowledgeBaseSummaryFolderResponseModelDependentAgentsItem

- `type`: `available`
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。
- `type`: `unknown`
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。

### ExternalFolderSyncInfo

外部ソースフォルダをミラーリングするナレッジベースフォルダのメタデータ。

- `type` ("google_drive", required) — プロバイダー識別子
- `source_entity_id` (string, required) — 外部システム内のエンティティID
- `integration_connection_id` (string, required) — インテグレーション接続インスタンスID
- `root_folder_id` (string, optional) — 同期ルートのKBフォルダIDです。Noneは、このフォルダがルートであることを意味します。
- `sync_cursor` (string, optional) — プロバイダーによって解釈される、増分同期用の不透明なカーソル
- `last_sync_at` (integer, optional) — 最後に完了した同期のUnixタイムスタンプ

### GetKnowledgeBaseSummaryTextResponseModelDependentAgentsItem

- `type`: `available`
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。
- `type`: `unknown`
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。

### GetKnowledgeBaseSummaryUrlResponseModelDependentAgentsItem

- `type`: `available`
  - `access_level` (enum, required)
    - Allowed values: `admin`, `editor`, `commenter`, `viewer`
  - `created_at_unix_secs` (integer, required)
  - `id` (string, required)
  - `name` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。
- `type`: `unknown`
  - `id` (string, required)
  - `referenced_resource_ids` (list of string, optional) — エージェントが推移的な依存先である場合、エージェントが直接依存するリソースのIDを含みます。

## Examples

**Response**

```json
{
  "results": [
    {
      "document": {
        "type": "file",
        "access_info": {
          "is_creator": true,
          "creator_name": "John Doe",
          "creator_email": "john.doe@example.com",
          "role": "admin",
          "access_source": "creator"
        },
        "id": "id",
        "metadata": {
          "created_at_unix_secs": 1,
          "last_updated_at_unix_secs": 1,
          "size_bytes": 1
        },
        "name": "name",
        "supported_usages": [
          "prompt"
        ],
        "dependent_agents": [
          {
            "type": "available",
            "access_level": "admin",
            "created_at_unix_secs": 1,
            "id": "id",
            "name": "name"
          }
        ]
      },
      "score": 1.1,
      "search_snippet": [
        {
          "value": "value",
          "is_hit": true
        }
      ]
    }
  ],
  "next_cursor": "next_cursor"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/knowledge-base/search"

querystring = {"cursor":"cursor","page_size":"1","query":"query","types":"[\"file\"]"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D';
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/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D"

	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/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D")

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/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D');

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D");
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/knowledge-base/search?cursor=cursor&page_size=1&query=query&types=%5B%22file%22%5D")! 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()
```