> 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/{documentation_id}

エージェントのナレッジベースを構成する特定のドキュメントの詳細を取得します。

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/knowledge-base/get-document

## 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

### Path parameters

- `documentation_id` (string, required) — ナレッジベース内のドキュメントのID。ドキュメント追加時に返されます。

### Query parameters

- `agent_id` (string, optional, default: )

## Response

### 200

成功レスポンス。

- `DocumentsGetResponse`
  - `type`: `url`
    - `access_info` (ResourceAccessInfo, required)
    - `extracted_inner_html` (string, required)
    - `id` (string, required)
    - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
    - `name` (string, required)
    - `supported_usages` (list of enum, required)
      - Allowed values: `prompt`, `auto`
    - `url` (string, required)
    - `auto_sync_info` (AutoSyncInfo, optional)
    - `content_format` (enum, optional, default: html) — ナレッジベースドキュメントに保存されたコンテンツの正規表現です。 HTMLはレガシーのデフォルトであり、このフィールドが存在する前に作成されたドキュメントは HTMLとして解釈されます。
      - Allowed values: `html`, `markdown`
    - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
    - `folder_path` (list of KnowledgeBaseFolderPathSegmentResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
  - `type`: `file`
    - `access_info` (ResourceAccessInfo, required)
    - `extracted_inner_html` (string, required)
    - `filename` (string, required)
    - `id` (string, required)
    - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
    - `name` (string, required)
    - `supported_usages` (list of enum, required)
      - Allowed values: `prompt`, `auto`
    - `auto_sync_info` (AutoSyncInfo, optional)
    - `content_format` (enum, optional, default: html) — ナレッジベースドキュメントに保存されたコンテンツの正規表現です。 HTMLはレガシーのデフォルトであり、このフィールドが存在する前に作成されたドキュメントは HTMLとして解釈されます。
      - Allowed values: `html`, `markdown`
    - `external_sync_info` (ExternalFileSyncInfo, optional) — 外部ソース内の元のファイルへのリンクを追跡します。
    - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
    - `folder_path` (list of KnowledgeBaseFolderPathSegmentResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
    - `is_frozen` (boolean, optional, default: false)
    - `refresh_status` (FileRefreshStatus, optional) — 外部同期ファイルの進行中または直近の更新状態です。クライアントが同期の進行状況を表示し、更新がキューに入っている間または処理中に再同期を無効にするために使用します。
  - `type`: `text`
    - `access_info` (ResourceAccessInfo, required)
    - `extracted_inner_html` (string, required)
    - `id` (string, required)
    - `metadata` (KnowledgeBaseDocumentMetadataResponseModel, required)
    - `name` (string, required)
    - `supported_usages` (list of enum, required)
      - Allowed values: `prompt`, `auto`
    - `content_format` (enum, optional, default: html) — ナレッジベースドキュメントに保存されたコンテンツの正規表現です。 HTMLはレガシーのデフォルトであり、このフィールドが存在する前に作成されたドキュメントは HTMLとして解釈されます。
      - Allowed values: `html`, `markdown`
    - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
    - `folder_path` (list of KnowledgeBaseFolderPathSegmentResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
  - `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`
    - `active_sync_job` (KbExternalSyncJob, optional) — このフォルダの最新の外部同期ジョブ（実行中または完了済み）。存在する場合に表示されます。クライアントが同期の進行状況を表示するために使用します。
    - `auto_sync_info` (AutoSyncInfo, optional)
    - `external_sync_info` (ExternalFolderSyncInfo, optional) — 外部ソースフォルダをミラーリングするナレッジベースフォルダのメタデータ。
    - `folder_parent_id` (string, optional) — 親フォルダのID。ドキュメントがルートレベルにある場合はnullです。
    - `folder_path` (list of KnowledgeBaseFolderPathSegmentResponseModel, optional) — ルートから親フォルダまでの、このエンティティにつながるフォルダパスセグメント。
    - `is_frozen` (boolean, optional, default: false)

## Errors

### 422 Documents Get Request Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### 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)

### 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) — 非推奨です。このフィールドは現在は効果がなく、今後のリリースで削除されます。

### KnowledgeBaseFolderPathSegmentResponseModel

- `id` (string, required)
- `name` (string, optional)

### 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

### 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)

### KbExternalSyncJob

- `type` ("google_drive", required)
- `folder_id` (string, required)
- `integration_connection_id` (string, required)
- `triggered_by` (enum, required)
  - Allowed values: `on_demand`, `on_connect`, `auto`
- `updated_at` (integer, required)
- `id` (string, required)
- `created_at` (integer, required)
- `status` (enum, optional, default: queued)
  - Allowed values: `queued`, `processing`, `succeeded`, `failed`, `skipped`, `cancelled`
- `sync_type` (enum, optional)
  - Allowed values: `full`, `incremental`
- `items_identified` (integer, optional, default: 0)
- `items_processed` (integer, optional, default: 0)
- `error_message` (string, optional)
- `started_at` (integer, optional)
- `completed_at` (integer, optional)

### 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タイムスタンプ

### ValidationError

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

### ValidationErrorLocItem

## Examples

**Response**

```json
{
  "type": "url",
  "access_info": {
    "is_creator": true,
    "creator_name": "John Doe",
    "creator_email": "john.doe@example.com",
    "role": "admin",
    "anonymous_access_level_override": "admin",
    "access_source": "creator"
  },
  "extracted_inner_html": "extracted_inner_html",
  "id": "id",
  "metadata": {
    "created_at_unix_secs": 1,
    "last_updated_at_unix_secs": 1,
    "size_bytes": 1
  },
  "name": "name",
  "supported_usages": [
    "prompt"
  ],
  "url": "url",
  "auto_sync_info": {
    "minimum_frequency_days": 1,
    "auto_remove": true,
    "consec_failures": 1,
    "next_refresh_by": 1
  },
  "content_format": "html",
  "folder_parent_id": "folder_parent_id",
  "folder_path": [
    {
      "id": "id",
      "name": "name"
    }
  ]
}
```

**SDK Code**

```python
import requests

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

querystring = {"agent_id":"agent_id"}

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

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/knowledge-base/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id';
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/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id"

	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/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id")

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/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/knowledge-base/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id');

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/knowledge-base/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id");
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/21m00Tcm4TlvDq8ikWAM?agent_id=agent_id")! 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()
```