> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/api/ja/api-reference/zhi-shi-ku-xin-ban.md).

# ナレッジベース（新版）

### ナレッジベースを作成 <a href="#knowledge-bases-create" id="knowledge-bases-create"></a>

POST `/api/v1/knowledge-bases/`

#### リクエストボディ

**リクエストパラメータ**

| フィールド                   | 型               | 必須  | 説明                                                                                                                                                                                                          |
| ----------------------- | --------------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| embeddingModel          | string (uuid)   | はい  |                                                                                                                                                                                                             |
| rerankerModel           | string (uuid)   | はい  |                                                                                                                                                                                                             |
| name                    | string          | はい  |                                                                                                                                                                                                             |
| description             | string          | いいえ |                                                                                                                                                                                                             |
| numberOfRetrievedChunks | integer         | いいえ | 取得する参考チャンクの数です。デフォルトは 12、最小値は 1 です                                                                                                                                                                          |
| enableHyde              | boolean         | いいえ | HyDE を有効にします。デフォルトは False です                                                                                                                                                                                |
| similarityCutoff        | number (double) | いいえ | 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です                                                                                                                                                                        |
| enableRerank            | boolean         | いいえ | リランキングを有効にするかどうかを指定します。デフォルトは True です                                                                                                                                                                       |
| enableRrf               | boolean         | いいえ | Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. If not provided, uses system default.                                             |
| vectorDatabaseType      | object          | いいえ | Type of vector database: elasticsearch, opensearch, oracle or synxdb. Defaults to the platform-managed engine. `elasticsearch`: Elasticsearch ; `opensearch`: OpenSearch ; `oracle`: Oracle AI Database ... |
| vectorDatabaseUrl       | string          | いいえ | Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "<https://host:9200>"). For Oracle: DSN format (e.g., "host:1521/service\_name").                        |
| vectorDatabaseApiKey    | string          | いいえ | API Key for Elasticsearch. Not used for OpenSearch.                                                                                                                                                         |
| opensearchUsername      | string          | いいえ | Username for OpenSearch Basic Auth.                                                                                                                                                                         |
| opensearchPassword      | string          | いいえ | Password for OpenSearch Basic Auth.                                                                                                                                                                         |
| oracleUser              | string          | いいえ | Oracle database username.                                                                                                                                                                                   |
| oraclePassword          | string          | いいえ | Oracle database password.                                                                                                                                                                                   |
| synxdbUser              | string          | いいえ | SynxDB database username.                                                                                                                                                                                   |
| synxdbPassword          | string          | いいえ | SynxDB database password.                                                                                                                                                                                   |
| chatbots                | array\[IdName]  | いいえ |                                                                                                                                                                                                             |
| groups                  | array\[IdName]  | いいえ |                                                                                                                                                                                                             |

**リクエストスキーマの例**

```typescript
{
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参考チャンクの数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // リランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. If not provided, uses system default. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch, opensearch, oracle or synxdb. Defaults to the platform-managed engine.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "groups"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
}
```

**リクエスト値の例**

```json
{
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "サンプル名",
  "description": "サンプル文字列",
  "numberOfRetrievedChunks": 123,
  "enableHyde": true,
  "similarityCutoff": 123,
  "enableRerank": true,
  "enableRrf": true,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "サンプル文字列",
  "vectorDatabaseApiKey": "サンプル文字列",
  "opensearchUsername": "サンプル文字列",
  "opensearchPassword": "サンプル文字列",
  "oracleUser": "サンプル文字列",
  "oraclePassword": "サンプル文字列",
  "synxdbUser": "サンプル文字列",
  "synxdbPassword": "サンプル文字列",
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ]
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": true,
    "similarityCutoff": 123,
    "enableRerank": true,
    "enableRrf": true,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": true,
    "similarityCutoff": 123,
    "enableRerank": true,
    "enableRrf": true,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": True,
    "similarityCutoff": 123,
    "enableRerank": True,
    "enableRrf": True,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "groups": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'embeddingModel' => '550e8400-e29b-41d4-a716-446655440000',
            'rerankerModel' => '550e8400-e29b-41d4-a716-446655440000',
            'name' => 'サンプル名',
            'description' => 'サンプル文字列',
            'numberOfRetrievedChunks' => 123,
            'enableHyde' => true,
            'similarityCutoff' => 123,
            'enableRerank' => true,
            'enableRrf' => true,
            'vectorDatabaseType' => new \stdClass(),
            'vectorDatabaseUrl' => 'サンプル文字列',
            'vectorDatabaseApiKey' => 'サンプル文字列',
            'opensearchUsername' => 'サンプル文字列',
            'opensearchPassword' => 'サンプル文字列',
            'oracleUser' => 'サンプル文字列',
            'oraclePassword' => 'サンプル文字列',
            'synxdbUser' => 'サンプル文字列',
            'synxdbPassword' => 'サンプル文字列',
            'chatbots' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'groups' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "organization"?: string (uuid) // 任意
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参考チャンクの数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // リランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "labels": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups"?: [ // ナレッジベースがアクセスできるグループの一覧です (任意)
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
  "vectorStorageSize": integer
  "chunksCount": integer
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "numberOfRetrievedChunks": 456,
  "enableHyde": false,
  "similarityCutoff": 456,
  "enableRerank": false,
  "enableRrf": false,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "レスポンス文字列",
  "vectorDatabaseApiKey": "レスポンス文字列",
  "opensearchUsername": "レスポンス文字列",
  "opensearchPassword": "レスポンス文字列",
  "oracleUser": "レスポンス文字列",
  "oraclePassword": "レスポンス文字列",
  "synxdbUser": "レスポンス文字列",
  "synxdbPassword": "レスポンス文字列",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "filesCount": 456,
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### すべてのナレッジベースを一覧表示 <a href="#knowledge-bases-list" id="knowledge-bases-list"></a>

GET `/api/v1/knowledge-bases/`

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                             |
| ---------------- | -- | ------- | ---------------------------------------------- |
| `embeddingModel` | ❌  | string  |                                                |
| `page`           | ❌  | integer | A page number within the paginated result set. |
| `pageSize`       | ❌  | integer | Number of results to return per page.          |
| `query`          | ❌  | string  |                                                |
| `rerankerModel`  | ❌  | string  |                                                |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "createdBy": 
      {
        "id": string (uuid)
        "name": string
      }
      "organization"?: string (uuid) // 任意
      "embeddingModel": string (uuid)
      "rerankerModel": string (uuid)
      "name": string
      "description"?: string // 任意
      "numberOfRetrievedChunks"?: integer // 取得する参考チャンクの数です。デフォルトは 12、最小値は 1 です (任意)
      "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
      "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
      "enableRerank"?: boolean // リランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
      "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
      "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
      {
      }
      "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
      "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
      "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
      "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
      "oracleUser"?: string // Oracle database username. (任意)
      "oraclePassword"?: string // Oracle database password. (任意)
      "synxdbUser"?: string // SynxDB database username. (任意)
      "synxdbPassword"?: string // SynxDB database password. (任意)
      "labels": [
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "chatbots"?: [ // 任意
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "groups"?: [ // ナレッジベースがアクセスできるグループの一覧です (任意)
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
      "vectorStorageSize": integer
      "chunksCount": integer
      "canUpdate": boolean // Return whether the current user can update this resource.
      "canDelete": boolean // Return whether the current user can delete this resource.
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "createdBy": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      },
      "organization": "550e8400-e29b-41d4-a716-446655440000",
      "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
      "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "description": "レスポンス文字列",
      "numberOfRetrievedChunks": 456,
      "enableHyde": false,
      "similarityCutoff": 456,
      "enableRerank": false,
      "enableRrf": false,
      "vectorDatabaseType": {},
      "vectorDatabaseUrl": "レスポンス文字列",
      "vectorDatabaseApiKey": "レスポンス文字列",
      "opensearchUsername": "レスポンス文字列",
      "opensearchPassword": "レスポンス文字列",
      "oracleUser": "レスポンス文字列",
      "oraclePassword": "レスポンス文字列",
      "synxdbUser": "レスポンス文字列",
      "synxdbPassword": "レスポンス文字列",
      "labels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "chatbots": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "groups": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "filesCount": 456,
      "vectorStorageSize": 456,
      "chunksCount": 456,
      "canUpdate": false,
      "canDelete": false,
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### 特定のナレッジベースの詳細を取得 <a href="#knowledge-bases-retrieve" id="knowledge-bases-retrieve"></a>

GET `/api/v1/knowledge-bases/{id}/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "organization"?: string (uuid) // 省略可
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 省略可
  "numberOfRetrievedChunks"?: integer // 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です (省略可)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (省略可)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (省略可)
  "enableRerank"?: boolean // リランキングを有効にするかどうかを指定します。デフォルトは True です (省略可)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (省略可)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (省略可)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (省略可)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (省略可)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (省略可)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (省略可)
  "oracleUser"?: string // Oracle database username. (省略可)
  "oraclePassword"?: string // Oracle database password. (省略可)
  "synxdbUser"?: string // SynxDB database username. (省略可)
  "synxdbPassword"?: string // SynxDB database password. (省略可)
  "labels": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "chatbots"?: [ // 省略可
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧です (省略可)
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
  "vectorStorageSize": integer
  "chunksCount": integer
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "numberOfRetrievedChunks": 456,
  "enableHyde": false,
  "similarityCutoff": 456,
  "enableRerank": false,
  "enableRrf": false,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "レスポンス文字列",
  "vectorDatabaseApiKey": "レスポンス文字列",
  "opensearchUsername": "レスポンス文字列",
  "opensearchPassword": "レスポンス文字列",
  "oracleUser": "レスポンス文字列",
  "oraclePassword": "レスポンス文字列",
  "synxdbUser": "レスポンス文字列",
  "synxdbPassword": "レスポンス文字列",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "filesCount": 456,
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### 特定のナレッジベースの内容を検索 <a href="#knowledge-bases-search-create" id="knowledge-bases-search-create"></a>

POST `/api/v1/knowledge-bases/{id}/search/`

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                             |
| ---------------- | -- | ------- | ---------------------------------------------- |
| `id`             | ✅  | string  | A UUID string identifying this Knowledge Base. |
| `embeddingModel` | ❌  | string  |                                                |
| `page`           | ❌  | integer | A page number within the paginated result set. |
| `pageSize`       | ❌  | integer | Number of results to return per page.          |
| `query`          | ❌  | string  |                                                |
| `rerankerModel`  | ❌  | string  |                                                |

#### リクエストボディ

**リクエストパラメータ**

| フィールド         | 型      | 必須  | 説明                                                                                                                                                                                                |
| ------------- | ------ | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| searchMode    | object | いいえ | Search mode: hybrid (default, vector + BM25), semantic (vector only), keyword (BM25 only) `hybrid`: Hybrid (vector + BM25) ; `semantic`: Semantic (vector only) ; `keyword`: Keyword (BM25 only); |
| queryMetadata | object | いいえ | 検索範囲と検索方法を制御するクエリメタデータです                                                                                                                                                                          |

**リクエストスキーマの例**

```typescript
{
  "searchMode"?:  // Search mode: hybrid (default, vector + BM25), semantic (vector only), keyword (BM25 only)

* `hybrid` - Hybrid (vector + BM25)
* `semantic` - Semantic (vector only)
* `keyword` - Keyword (BM25 only) (省略可)
  {
  }
  "queryMetadata"?: object // 検索範囲と検索方法を制御するクエリメタデータです (省略可)
}
```

**リクエストの値の例**

```json
{
  "query": "API の使い方"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/search/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "API の使い方"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "query": "API の使い方"
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/search/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/search/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "query": "API の使い方"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/search/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'query' => 'API の使い方'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 省略可
  "previous"?: string (uri) // 省略可
  "results": [
    {
      "id": string (uuid)
      "charactersCount": integer
      "hitsCount": integer
      "text": string
      "updatedAt": string (timestamp)
      "filename": string
      "chatbotFile": object // フロントエンドで画像をプレビューできるように、ファイルの URL と型を含む ChatbotFile の完全な情報を返します
      "knowledgeBaseFile": object // get_chatbot_file と同じ情報を返し、後方互換性を提供します
      "pageNumber": integer // Backward-compatible alias of ``page_start``.
      "pageStart": integer
      "pageEnd": integer
      "citationTitle": string // Source title shown on the inline citation hover card.
      "citationDescription": string // Source description shown on the inline citation hover card.
      "citationQuote": string // Quoted text snippet shown on the inline citation hover card.
      "hasImage": boolean // 画像が含まれているかどうかを判定します（ファイルの型または text 内の Markdown 画像を確認します）
      "imageUrl": string // 画像の URL を抽出します（ファイルの URL を優先し、なければ Markdown から抽出します）
      "displayText": string // 画像の Markdown マークアップを除いた全文を返します
      "displayTitle": string // 表示タイトルを返します（fallback: citation_title -> filename）
      "highlightedText": string // Return text with matched terms wrapped in ``<mark>`` tags.

Priority:
1. ES/OpenSearch native highlight (set by retrieve_api via ``_es_highlighted_text``)
2. Python regex fallback (keyword-based, works for all backends)
      "labels": [
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "rawUserDefineMetadata"?: object // Metadata keys and values defined by the user. (省略可)
      "metadataEnabledForSearch": object // Map each user-defined metadata key on this node to whether it was sent into the LLM.

A key reaches the LLM only when its ``MetadataKey.enabled_for_search`` is True *and*
the node carries a value for it. Since this maps over ``raw_user_define_metadata``
(the keys the cited-documents block displays, all of which have a value),
``enabled_for_search`` alone decides the flag. The source of truth is the node's
knowledge base ``MetadataKey`` current setting, matching the AI Search indicator.
      "startCharIdx": integer
      "endCharIdx": integer
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "charactersCount": 456,
      "hitsCount": 456,
      "text": "レスポンス文字列",
      "updatedAt": "レスポンス文字列",
      "filename": "レスポンス文字列",
      "chatbotFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "knowledgeBaseFile": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスの名前の例",
        "description": "レスポンスの説明の例"
      },
      "pageNumber": 456,
      "pageStart": 456,
      "pageEnd": 456,
      "citationTitle": "レスポンス文字列",
      "citationDescription": "レスポンス文字列",
      "citationQuote": "レスポンス文字列",
      "hasImage": false,
      "imageUrl": "レスポンス文字列",
      "displayText": "レスポンス文字列",
      "displayTitle": "レスポンス文字列",
      "highlightedText": "レスポンス文字列",
      "labels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "rawUserDefineMetadata": null,
      "metadataEnabledForSearch": {
        "key1": "value1",
        "key2": "value2",
        "createdAt": "2025-01-01T00:00:00.000Z"
      },
      "startCharIdx": 456,
      "endCharIdx": 456
    }
  ]
}
```

***

### ナレッジベースを更新 <a href="#knowledge-bases-update" id="knowledge-bases-update"></a>

PUT `/api/v1/knowledge-bases/{id}/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### リクエストボディ

**リクエストパラメータ**

| フィールド                   | 型               | 必須  | 説明                                                                                                                                                                                   |
| ----------------------- | --------------- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| organization            | string (uuid)   | いいえ |                                                                                                                                                                                      |
| embeddingModel          | string (uuid)   | はい  |                                                                                                                                                                                      |
| rerankerModel           | string (uuid)   | はい  |                                                                                                                                                                                      |
| name                    | string          | はい  |                                                                                                                                                                                      |
| description             | string          | いいえ |                                                                                                                                                                                      |
| numberOfRetrievedChunks | integer         | いいえ | 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です                                                                                                                                                   |
| enableHyde              | boolean         | いいえ | HyDE を有効にします。デフォルトは False です                                                                                                                                                         |
| similarityCutoff        | number (double) | いいえ | 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です                                                                                                                                                 |
| enableRerank            | boolean         | いいえ | リランキングを有効にするかどうかを指定します。デフォルトは True です                                                                                                                                                |
| enableRrf               | boolean         | いいえ | Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license.                                                            |
| vectorDatabaseType      | object          | いいえ | Type of vector database: elasticsearch or opensearch. `elasticsearch`: Elasticsearch ; `opensearch`: OpenSearch ; `oracle`: Oracle AI Database 26ai ; `synxdb`: SynxDB;              |
| vectorDatabaseUrl       | string          | いいえ | Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "<https://host:9200>"). For Oracle: DSN format (e.g., "host:1521/service\_name"). |
| vectorDatabaseApiKey    | string          | いいえ | API Key for Elasticsearch. Not used for OpenSearch.                                                                                                                                  |
| opensearchUsername      | string          | いいえ | Username for OpenSearch Basic Auth.                                                                                                                                                  |
| opensearchPassword      | string          | いいえ | Password for OpenSearch Basic Auth.                                                                                                                                                  |
| oracleUser              | string          | いいえ | Oracle database username.                                                                                                                                                            |
| oraclePassword          | string          | いいえ | Oracle database password.                                                                                                                                                            |
| synxdbUser              | string          | いいえ | SynxDB database username.                                                                                                                                                            |
| synxdbPassword          | string          | いいえ | SynxDB database password.                                                                                                                                                            |
| chatbots                | array\[IdName]  | いいえ |                                                                                                                                                                                      |
| groups                  | array\[IdName]  | いいえ | ナレッジベースにアクセスできるグループの一覧です                                                                                                                                                             |

**リクエストスキーマの例**

```typescript
{
  "organization"?: string (uuid) // 省略可
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 省略可
  "numberOfRetrievedChunks"?: integer // 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です (省略可)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (省略可)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (省略可)
  "enableRerank"?: boolean // リランキングを有効にするかどうかを指定します。デフォルトは True です (省略可)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (省略可)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (省略可)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (省略可)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (省略可)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (省略可)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (省略可)
  "oracleUser"?: string // Oracle database username. (省略可)
  "oraclePassword"?: string // Oracle database password. (省略可)
  "synxdbUser"?: string // SynxDB database username. (省略可)
  "synxdbPassword"?: string // SynxDB database password. (省略可)
  "chatbots"?: [ // 省略可
    {
      "id": string (uuid)
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧です (省略可)
    {
      "id": string (uuid)
    }
  ]
}
```

**リクエストの値の例**

```json
{
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "名前の例",
  "description": "文字列の例",
  "numberOfRetrievedChunks": 123,
  "enableHyde": true,
  "similarityCutoff": 123,
  "enableRerank": true,
  "enableRrf": true,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "文字列の例",
  "vectorDatabaseApiKey": "文字列の例",
  "opensearchUsername": "文字列の例",
  "opensearchPassword": "文字列の例",
  "oracleUser": "文字列の例",
  "oraclePassword": "文字列の例",
  "synxdbUser": "文字列の例",
  "synxdbPassword": "文字列の例",
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ]
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "名前の例",
    "description": "文字列の例",
    "numberOfRetrievedChunks": 123,
    "enableHyde": true,
    "similarityCutoff": 123,
    "enableRerank": true,
    "enableRrf": true,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "文字列の例",
    "vectorDatabaseApiKey": "文字列の例",
    "opensearchUsername": "文字列の例",
    "opensearchPassword": "文字列の例",
    "oracleUser": "文字列の例",
    "oraclePassword": "文字列の例",
    "synxdbUser": "文字列の例",
    "synxdbPassword": "文字列の例",
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "名前の例",
    "description": "文字列の例",
    "numberOfRetrievedChunks": 123,
    "enableHyde": true,
    "similarityCutoff": 123,
    "enableRerank": true,
    "enableRrf": true,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "文字列の例",
    "vectorDatabaseApiKey": "文字列の例",
    "opensearchUsername": "文字列の例",
    "opensearchPassword": "文字列の例",
    "oracleUser": "文字列の例",
    "oraclePassword": "文字列の例",
    "synxdbUser": "文字列の例",
    "synxdbPassword": "文字列の例",
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  };

axios.put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": True,
    "similarityCutoff": 123,
    "enableRerank": True,
    "enableRrf": True,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "groups": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ]
}

response = requests.put(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'organization' => '550e8400-e29b-41d4-a716-446655440000',
            'embeddingModel' => '550e8400-e29b-41d4-a716-446655440000',
            'rerankerModel' => '550e8400-e29b-41d4-a716-446655440000',
            'name' => 'サンプル名',
            'description' => 'サンプル文字列',
            'numberOfRetrievedChunks' => 123,
            'enableHyde' => true,
            'similarityCutoff' => 123,
            'enableRerank' => true,
            'enableRrf' => true,
            'vectorDatabaseType' => new \stdClass(),
            'vectorDatabaseUrl' => 'サンプル文字列',
            'vectorDatabaseApiKey' => 'サンプル文字列',
            'opensearchUsername' => 'サンプル文字列',
            'opensearchPassword' => 'サンプル文字列',
            'oracleUser' => 'サンプル文字列',
            'oraclePassword' => 'サンプル文字列',
            'synxdbUser' => 'サンプル文字列',
            'synxdbPassword' => 'サンプル文字列',
            'chatbots' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'groups' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "organization"?: string (uuid) // 任意
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // 再ランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "labels": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧 (任意)
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
  "vectorStorageSize": integer
  "chunksCount": integer
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "numberOfRetrievedChunks": 456,
  "enableHyde": false,
  "similarityCutoff": 456,
  "enableRerank": false,
  "enableRrf": false,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "レスポンス文字列",
  "vectorDatabaseApiKey": "レスポンス文字列",
  "opensearchUsername": "レスポンス文字列",
  "opensearchPassword": "レスポンス文字列",
  "oracleUser": "レスポンス文字列",
  "oraclePassword": "レスポンス文字列",
  "synxdbUser": "レスポンス文字列",
  "synxdbPassword": "レスポンス文字列",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "filesCount": 456,
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ナレッジベースの部分更新 <a href="#knowledge-bases-partial-update" id="knowledge-bases-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{id}/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### リクエストボディ

**リクエストパラメータ**

| フィールド                   | 型               | 必須  | 説明                                                                                                                                                                                   |
| ----------------------- | --------------- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| organization            | string (uuid)   | いいえ |                                                                                                                                                                                      |
| embeddingModel          | string (uuid)   | いいえ |                                                                                                                                                                                      |
| rerankerModel           | string (uuid)   | いいえ |                                                                                                                                                                                      |
| name                    | string          | いいえ |                                                                                                                                                                                      |
| description             | string          | いいえ |                                                                                                                                                                                      |
| numberOfRetrievedChunks | integer         | いいえ | 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です                                                                                                                                                   |
| enableHyde              | boolean         | いいえ | HyDE を有効にします。デフォルトは False です                                                                                                                                                         |
| similarityCutoff        | number (double) | いいえ | 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です                                                                                                                                                 |
| enableRerank            | boolean         | いいえ | 再ランキングを有効にするかどうかを指定します。デフォルトは True です                                                                                                                                                |
| enableRrf               | boolean         | いいえ | Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license.                                                            |
| vectorDatabaseType      | object          | いいえ | Type of vector database: elasticsearch or opensearch. `elasticsearch`: Elasticsearch ; `opensearch`: OpenSearch ; `oracle`: Oracle AI Database 26ai ; `synxdb`: SynxDB;              |
| vectorDatabaseUrl       | string          | いいえ | Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "<https://host:9200>"). For Oracle: DSN format (e.g., "host:1521/service\_name"). |
| vectorDatabaseApiKey    | string          | いいえ | API Key for Elasticsearch. Not used for OpenSearch.                                                                                                                                  |
| opensearchUsername      | string          | いいえ | Username for OpenSearch Basic Auth.                                                                                                                                                  |
| opensearchPassword      | string          | いいえ | Password for OpenSearch Basic Auth.                                                                                                                                                  |
| oracleUser              | string          | いいえ | Oracle database username.                                                                                                                                                            |
| oraclePassword          | string          | いいえ | Oracle database password.                                                                                                                                                            |
| synxdbUser              | string          | いいえ | SynxDB database username.                                                                                                                                                            |
| synxdbPassword          | string          | いいえ | SynxDB database password.                                                                                                                                                            |
| chatbots                | array\[IdName]  | いいえ |                                                                                                                                                                                      |
| groups                  | array\[IdName]  | いいえ | ナレッジベースにアクセスできるグループの一覧                                                                                                                                                               |

**リクエストスキーマの例**

```typescript
{
  "organization"?: string (uuid) // 任意
  "embeddingModel"?: string (uuid) // 任意
  "rerankerModel"?: string (uuid) // 任意
  "name"?: string // 任意
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // 再ランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧 (任意)
    {
      "id": string (uuid)
    }
  ]
}
```

**リクエストのサンプル値**

```json
{
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "サンプル名",
  "description": "サンプル文字列",
  "numberOfRetrievedChunks": 123,
  "enableHyde": true,
  "similarityCutoff": 123,
  "enableRerank": true,
  "enableRrf": true,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "サンプル文字列",
  "vectorDatabaseApiKey": "サンプル文字列",
  "opensearchUsername": "サンプル文字列",
  "opensearchPassword": "サンプル文字列",
  "oracleUser": "サンプル文字列",
  "oraclePassword": "サンプル文字列",
  "synxdbUser": "サンプル文字列",
  "synxdbPassword": "サンプル文字列",
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ]
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": true,
    "similarityCutoff": 123,
    "enableRerank": true,
    "enableRrf": true,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": true,
    "similarityCutoff": 123,
    "enableRerank": true,
    "enableRrf": true,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "groups": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ]
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "organization": "550e8400-e29b-41d4-a716-446655440000",
    "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
    "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
    "name": "サンプル名",
    "description": "サンプル文字列",
    "numberOfRetrievedChunks": 123,
    "enableHyde": True,
    "similarityCutoff": 123,
    "enableRerank": True,
    "enableRrf": True,
    "vectorDatabaseType": {},
    "vectorDatabaseUrl": "サンプル文字列",
    "vectorDatabaseApiKey": "サンプル文字列",
    "opensearchUsername": "サンプル文字列",
    "opensearchPassword": "サンプル文字列",
    "oracleUser": "サンプル文字列",
    "oraclePassword": "サンプル文字列",
    "synxdbUser": "サンプル文字列",
    "synxdbPassword": "サンプル文字列",
    "chatbots": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "groups": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ]
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'organization' => '550e8400-e29b-41d4-a716-446655440000',
            'embeddingModel' => '550e8400-e29b-41d4-a716-446655440000',
            'rerankerModel' => '550e8400-e29b-41d4-a716-446655440000',
            'name' => 'サンプル名',
            'description' => 'サンプル文字列',
            'numberOfRetrievedChunks' => 123,
            'enableHyde' => true,
            'similarityCutoff' => 123,
            'enableRerank' => true,
            'enableRrf' => true,
            'vectorDatabaseType' => new \stdClass(),
            'vectorDatabaseUrl' => 'サンプル文字列',
            'vectorDatabaseApiKey' => 'サンプル文字列',
            'opensearchUsername' => 'サンプル文字列',
            'opensearchPassword' => 'サンプル文字列',
            'oracleUser' => 'サンプル文字列',
            'oraclePassword' => 'サンプル文字列',
            'synxdbUser' => 'サンプル文字列',
            'synxdbPassword' => 'サンプル文字列',
            'chatbots' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'groups' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "organization"?: string (uuid) // 任意
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参照チャンクの数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // 再ランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "labels": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧 (任意)
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
  "vectorStorageSize": integer
  "chunksCount": integer
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "numberOfRetrievedChunks": 456,
  "enableHyde": false,
  "similarityCutoff": 456,
  "enableRerank": false,
  "enableRrf": false,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "レスポンス文字列",
  "vectorDatabaseApiKey": "レスポンス文字列",
  "opensearchUsername": "レスポンス文字列",
  "opensearchPassword": "レスポンス文字列",
  "oracleUser": "レスポンス文字列",
  "oraclePassword": "レスポンス文字列",
  "synxdbUser": "レスポンス文字列",
  "synxdbPassword": "レスポンス文字列",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "filesCount": 456,
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ナレッジベースの削除 <a href="#knowledge-bases-destroy" id="knowledge-bases-destroy"></a>

DELETE `/api/v1/knowledge-bases/{id}/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエストボディ (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### RRF の利用可否を確認 <a href="#knowledge-bases-check-rrf-availability-retrieve" id="knowledge-bases-check-rrf-availability-retrieve"></a>

GET `/api/v1/knowledge-bases/{id}/check-rrf-availability/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/check-rrf-availability/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/check-rrf-availability/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/check-rrf-availability/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/check-rrf-availability/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
{
  "id": string (uuid)
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "organization"?: string (uuid) // 任意
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参考チャンク数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // リランキングを有効にするかどうかです。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "labels": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧 (任意)
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
  "vectorStorageSize": integer
  "chunksCount": integer
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "numberOfRetrievedChunks": 456,
  "enableHyde": false,
  "similarityCutoff": 456,
  "enableRerank": false,
  "enableRrf": false,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "レスポンス文字列",
  "vectorDatabaseApiKey": "レスポンス文字列",
  "opensearchUsername": "レスポンス文字列",
  "opensearchPassword": "レスポンス文字列",
  "oracleUser": "レスポンス文字列",
  "oraclePassword": "レスポンス文字列",
  "synxdbUser": "レスポンス文字列",
  "synxdbPassword": "レスポンス文字列",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "filesCount": 456,
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ラベルを Excel にエクスポート <a href="#knowledge-bases-export-labels-excel-retrieve" id="knowledge-bases-export-labels-excel-retrieve"></a>

GET `/api/v1/knowledge-bases/{id}/export-labels-excel/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-labels-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-labels-excel/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-labels-excel/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-labels-excel/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明                  |
| -------- | ------------------- |
| 200      | Excel file download |

***

### Excel からラベルをインポート <a href="#knowledge-bases-import-labels-excel-create" id="knowledge-bases-import-labels-excel-create"></a>

POST `/api/v1/knowledge-bases/{id}/import-labels-excel/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-labels-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -F "excelFile=@example_file.txt"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');

// FormData オブジェクトを作成します
const formData = new FormData();
// 実際のファイルに置き換えてください
formData.append('excelFile', /* 実際のファイルオブジェクト */, 'example_file.txt');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    ...formData.getHeaders()
  }
};

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-labels-excel/", formData, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-labels-excel/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}

# ファイルとフォームデータを用意します
files = {
    'excelFile': ('example_file.txt', open('example_file.txt', 'rb'), 'text/plain')
}

response = requests.post(url, files=files, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-labels-excel/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ],
        'multipart' => [
            [
                'name' => 'excelFile',
                'contents' => fopen('example_file.txt', 'r'),
                'filename' => 'example_file.txt'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
{
  "success"?: boolean // 任意
  "updated_count"?: integer // 任意
  "total_rows"?: integer // 任意
  "errors"?: [ // 任意
    {
      "row"?: integer // 任意
      "file_id"?: string // 任意
      "error"?: string // 任意
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "success": false,
  "updated_count": 456,
  "total_rows": 456,
  "errors": [
    {
      "row": 456,
      "file_id": "レスポンス文字列",
      "error": "レスポンス文字列"
    }
  ]
}
```

***

### メタデータを Excel にエクスポート <a href="#knowledge-bases-export-metadata-excel-retrieve" id="knowledge-bases-export-metadata-excel-retrieve"></a>

GET `/api/v1/knowledge-bases/{id}/export-metadata-excel/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-metadata-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-metadata-excel/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-metadata-excel/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-metadata-excel/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明                |
| -------- | ----------------- |
| 200      | Excel ファイルのダウンロード |

***

### Excel からメタデータをインポート <a href="#knowledge-bases-import-metadata-excel-create" id="knowledge-bases-import-metadata-excel-create"></a>

POST `/api/v1/knowledge-bases/{id}/import-metadata-excel/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-metadata-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -F "excelFile=@example_file.txt"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');

// FormData オブジェクトを作成します
const formData = new FormData();
// 実際のファイルに置き換えてください
formData.append('excelFile', /* 実際のファイルオブジェクト */, 'example_file.txt');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    ...formData.getHeaders()
  }
};

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-metadata-excel/", formData, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-metadata-excel/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}

# ファイルとフォームデータを用意します
files = {
    'excelFile': ('example_file.txt', open('example_file.txt', 'rb'), 'text/plain')
}

response = requests.post(url, files=files, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-metadata-excel/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ],
        'multipart' => [
            [
                'name' => 'excelFile',
                'contents' => fopen('example_file.txt', 'r'),
                'filename' => 'example_file.txt'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマ例**

```typescript
{
  "success"?: boolean // 任意
  "updated_count"?: integer // 任意
  "total_rows"?: integer // 任意
  "errors"?: [ // 任意
    {
      "row"?: integer // 任意
      "file_id"?: string // 任意
      "error"?: string // 任意
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "success": false,
  "updated_count": 456,
  "total_rows": 456,
  "errors": [
    {
      "row": 456,
      "file_id": "レスポンス文字列",
      "error": "レスポンス文字列"
    }
  ]
}
```

***

### 新しいラベルを作成 <a href="#knowledge-bases-labels-create" id="knowledge-bases-labels-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/labels/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明 |
| ----------------- | -- | ------ | -- |
| `knowledgeBasePk` | ✅  | string |    |

#### リクエストボディ

**リクエストパラメータ**

| フィールド | 型      | 必須 | 説明 |
| ----- | ------ | -- | -- |
| name  | string | はい |    |

**リクエストスキーマ例**

```typescript
{
  "name": string
}
```

**リクエストの値の例**

```json
{
  "name": "名前の例"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "名前の例"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "name": "サンプル名"
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/", data, config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "name": "サンプル名"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に受信しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'サンプル名'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に受信しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "name"?: string // 省略可能
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列"
}
```

***

### ナレッジベースのラベル一覧を取得します <a href="#knowledge-bases-labels-list" id="knowledge-bases-labels-list"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/labels/`

#### パラメータ

| パラメータ名            | 必須 | 型       | 説明                                             |
| ----------------- | -- | ------- | ---------------------------------------------- |
| `knowledgeBasePk` | ✅  | string  |                                                |
| `page`            | ❌  | integer | A page number within the paginated result set. |
| `pageSize`        | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に受信しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に受信しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 省略可能
  "previous"?: string (uri) // 省略可能
  "results": [
    {
      "id": string (uuid)
      "name"?: string // 省略可能
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ]
}
```

***

### 特定のラベルの詳細を取得します <a href="#knowledge-bases-labels-retrieve" id="knowledge-bases-labels-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/labels/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                   |
| ----------------- | -- | ------ | ---------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this knowledge base label. |
| `knowledgeBasePk` | ✅  | string |                                                      |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に受信しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に受信しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "name"?: string // 省略可能
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列"
}
```

***

### ラベルを更新します <a href="#knowledge-bases-labels-update" id="knowledge-bases-labels-update"></a>

PUT `/api/v1/knowledge-bases/{knowledgeBasePk}/labels/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                   |
| ----------------- | -- | ------ | ---------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this knowledge base label. |
| `knowledgeBasePk` | ✅  | string |                                                      |

#### リクエストボディ

**リクエストパラメータ**

| フィールド | 型      | 必須 | 説明 |
| ----- | ------ | -- | -- |
| name  | string | はい |    |

**リクエストスキーマの例**

```typescript
{
  "name": string
}
```

**リクエスト値の例**

```json
{
  "name": "サンプル名"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "サンプル名"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "name": "サンプル名"
  };

axios.put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "name": "サンプル名"
}

response = requests.put(url, json=data, headers=headers)
try:
    print("レスポンスを正常に受信しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'サンプル名'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に受信しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "name"?: string // 省略可能
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列"
}
```

***

### ラベルを部分更新します <a href="#knowledge-bases-labels-partial-update" id="knowledge-bases-labels-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/labels/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                   |
| ----------------- | -- | ------ | ---------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this knowledge base label. |
| `knowledgeBasePk` | ✅  | string |                                                      |

#### リクエストボディ

**リクエストパラメータ**

| フィールド | 型      | 必須  | 説明 |
| ----- | ------ | --- | -- |
| name  | string | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "name"?: string // 省略可能
}
```

**リクエスト値の例**

```json
{
  "name": "サンプル名"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "サンプル名"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "name": "サンプル名"
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "name": "サンプル名"
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に受信しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'name' => 'サンプル名'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に受信しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "name"?: string // 省略可能
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列"
}
```

***

### ラベルを削除します <a href="#knowledge-bases-labels-destroy" id="knowledge-bases-labels-destroy"></a>

DELETE `/api/v1/knowledge-bases/{knowledgeBasePk}/labels/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                   |
| ----------------- | -- | ------ | ---------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this knowledge base label. |
| `knowledgeBasePk` | ✅  | string |                                                      |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエストボディ (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを正常に受信しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/labels/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に受信しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### メタデータフィールドを作成します <a href="#knowledge-bases-metadata-keys-create" id="knowledge-bases-metadata-keys-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/metadata-keys/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明 |
| ----------------- | -- | ------ | -- |
| `knowledgeBasePk` | ✅  | string |    |

#### リクエストボディ

**リクエストパラメータ**

| フィールド            | 型       | 必須  | 説明                   |
| ---------------- | ------- | --- | -------------------- |
| keyName          | string  | はい  | Metadata のキー名        |
| description      | string  | いいえ | このフィールドの用途の説明        |
| isRequired       | boolean | いいえ | 必須フィールドかどうか          |
| defaultValue     | string  | いいえ | 新しいファイルのデフォルト値       |
| enabledForSearch | boolean | いいえ | 検索時にこのフィールドを使用するかどうか |

**リクエストスキーマの例**

```typescript
{
  "keyName": string // Metadata のキー名
  "description"?: string // このフィールドの用途の説明 (省略可能)
  "isRequired"?: boolean // 必須フィールドかどうか (省略可能)
  "defaultValue"?: string // 新しいファイルのデフォルト値 (省略可能)
  "enabledForSearch"?: boolean // 検索時にこのフィールドを使用するかどうか (省略可能)
}
```

**リクエスト値の例**

```json
{
  "keyName": "サンプル文字列",
  "description": "サンプル文字列",
  "isRequired": true,
  "defaultValue": "サンプル文字列",
  "enabledForSearch": true
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "keyName": "サンプル文字列",
    "description": "サンプル文字列",
    "isRequired": true,
    "defaultValue": "サンプル文字列",
    "enabledForSearch": true
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "keyName": "サンプル文字列",
    "description": "サンプル文字列",
    "isRequired": true,
    "defaultValue": "サンプル文字列",
    "enabledForSearch": true
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/", data, config)
  .then(response => {
    console.log('レスポンスを正常に受信しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {
    "keyName": "サンプル文字列",
    "description": "サンプル文字列",
    "isRequired": True,
    "defaultValue": "サンプル文字列",
    "enabledForSearch": True
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'keyName' => 'サンプル文字列',
            'description' => 'サンプル文字列',
            'isRequired' => true,
            'defaultValue' => 'サンプル文字列',
            'enabledForSearch' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "knowledgeBase": 
  {
    "id": string (uuid)
    "name": string
  }
  "keyName": string // Metadata のキー名
  "keyType": string // フィールド名に基づいて自動判定します（デフォルトフィールドまたはカスタムフィールド）
  "description"?: string // このフィールドの用途を説明します (任意)
  "isRequired"?: boolean // 必須フィールドかどうかを指定します (任意)
  "defaultValue"?: string // 新しいファイルのデフォルト値 (任意)
  "enabledForSearch"?: boolean // 検索時にこのフィールドを使用するかどうかを指定します (任意)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "keyName": "レスポンス文字列",
  "keyType": "レスポンス文字列",
  "description": "レスポンス文字列",
  "isRequired": false,
  "defaultValue": "レスポンス文字列",
  "enabledForSearch": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### メタデータフィールドの一覧取得 <a href="#knowledge-bases-metadata-keys-list" id="knowledge-bases-metadata-keys-list"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/metadata-keys/`

#### パラメータ

| パラメータ名            | 必須 | 型       | 説明                                                                     |
| ----------------- | -- | ------- | ---------------------------------------------------------------------- |
| `knowledgeBasePk` | ✅  | string  |                                                                        |
| `page`            | ❌  | integer | A page number within the paginated result set.                         |
| `pageSize`        | ❌  | integer | Number of results to return per page.                                  |
| `pagination`      | ❌  | boolean | Set to false to return all keys without pagination (defaults to true). |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/?page=1&pageSize=1&pagination=true" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/?page=1&pageSize=1&pagination=true", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/?page=1&pageSize=1&pagination=true"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/?page=1&pageSize=1&pagination=true", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "knowledgeBase": 
      {
        "id": string (uuid)
        "name": string
      }
      "keyName": string // Metadata のキー名
      "keyType": string // フィールド名に基づいて自動判定します（デフォルトフィールドまたはカスタムフィールド）
      "description"?: string // このフィールドの用途を説明します (任意)
      "isRequired"?: boolean // 必須フィールドかどうかを指定します (任意)
      "defaultValue"?: string // 新しいファイルのデフォルト値 (任意)
      "enabledForSearch"?: boolean // 検索時にこのフィールドを使用するかどうかを指定します (任意)
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンスのサンプル値**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "knowledgeBase": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      },
      "keyName": "レスポンス文字列",
      "keyType": "レスポンス文字列",
      "description": "レスポンス文字列",
      "isRequired": false,
      "defaultValue": "レスポンス文字列",
      "enabledForSearch": false,
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### 特定のメタデータフィールドの取得 <a href="#knowledge-bases-metadata-keys-retrieve" id="knowledge-bases-metadata-keys-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/metadata-keys/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                           |
| ----------------- | -- | ------ | -------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Metadata Key. |
| `knowledgeBasePk` | ✅  | string |                                              |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "knowledgeBase": 
  {
    "id": string (uuid)
    "name": string
  }
  "keyName": string // Metadata のキー名
  "keyType": string // フィールド名に基づいて自動判定します（デフォルトフィールドまたはカスタムフィールド）
  "description"?: string // このフィールドの用途を説明します (任意)
  "isRequired"?: boolean // 必須フィールドかどうかを指定します (任意)
  "defaultValue"?: string // 新しいファイルのデフォルト値 (任意)
  "enabledForSearch"?: boolean // 検索時にこのフィールドを使用するかどうかを指定します (任意)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "keyName": "レスポンス文字列",
  "keyType": "レスポンス文字列",
  "description": "レスポンス文字列",
  "isRequired": false,
  "defaultValue": "レスポンス文字列",
  "enabledForSearch": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### メタデータフィールドの更新 <a href="#knowledge-bases-metadata-keys-update" id="knowledge-bases-metadata-keys-update"></a>

PUT `/api/v1/knowledge-bases/{knowledgeBasePk}/metadata-keys/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                           |
| ----------------- | -- | ------ | -------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Metadata Key. |
| `knowledgeBasePk` | ✅  | string |                                              |

#### リクエスト内容

**リクエストパラメータ**

| フィールド            | 型       | 必須  | 説明                         |
| ---------------- | ------- | --- | -------------------------- |
| keyName          | string  | はい  | Metadata のキー名              |
| description      | string  | いいえ | このフィールドの用途を説明します           |
| isRequired       | boolean | いいえ | 必須フィールドかどうかを指定します          |
| defaultValue     | string  | いいえ | 新しいファイルのデフォルト値             |
| enabledForSearch | boolean | いいえ | 検索時にこのフィールドを使用するかどうかを指定します |

**リクエストスキーマの例**

```typescript
{
  "keyName": string // Metadata のキー名
  "description"?: string // このフィールドの用途を説明します (任意)
  "isRequired"?: boolean // 必須フィールドかどうかを指定します (任意)
  "defaultValue"?: string // 新しいファイルのデフォルト値 (任意)
  "enabledForSearch"?: boolean // 検索時にこのフィールドを使用するかどうかを指定します (任意)
}
```

**リクエストのサンプル値**

```json
{
  "keyName": "サンプル文字列",
  "description": "サンプル文字列",
  "isRequired": true,
  "defaultValue": "サンプル文字列",
  "enabledForSearch": true
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "keyName": "サンプル文字列",
    "description": "サンプル文字列",
    "isRequired": true,
    "defaultValue": "サンプル文字列",
    "enabledForSearch": true
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {
    "keyName": "サンプル文字列",
    "description": "サンプル文字列",
    "isRequired": true,
    "defaultValue": "サンプル文字列",
    "enabledForSearch": true
  };

axios.put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {
    "keyName": "サンプル文字列",
    "description": "サンプル文字列",
    "isRequired": True,
    "defaultValue": "サンプル文字列",
    "enabledForSearch": True
}

response = requests.put(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/metadata-keys/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'keyName' => 'サンプル文字列',
            'description' => 'サンプル文字列',
            'isRequired' => true,
            'defaultValue' => 'サンプル文字列',
            'enabledForSearch' => true
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "knowledgeBase": 
  {
    "id": string (uuid)
    "name": string
  }
  "keyName": string // Metadata のキー名
  "keyType": string // フィールド名に基づいて自動判定します（デフォルトフィールドまたはカスタムフィールド）
  "description"?: string // このフィールドの用途を説明します (任意)
  "isRequired"?: boolean // 必須フィールドかどうかを指定します (任意)
  "defaultValue"?: string // 新しいファイルのデフォルト値 (任意)
  "enabledForSearch"?: boolean // 検索時にこのフィールドを使用するかどうかを指定します (任意)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスのサンプル値**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "keyName": "レスポンス文字列",
  "keyType": "レスポンス文字列",
  "description": "レスポンス文字列",
  "isRequired": false,
  "defaultValue": "レスポンス文字列",
  "enabledForSearch": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ナレッジベースへのファイルのアップロード <a href="#knowledge-bases-files-create" id="knowledge-bases-files-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/files/`

#### パラメーター

| パラメーター名           | 必須 | 型       | 説明                                                                                                                                                                                                                                     |
| ----------------- | -- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeBasePk` | ✅  | string  |                                                                                                                                                                                                                                        |
| `fileType`        | ❌  | string  | ファイル形式で絞り込みます。例：pdf、docx、txt、xlsx など                                                                                                                                                                                                   |
| `knowledgeBase`   | ❌  | string  | ナレッジベース ID                                                                                                                                                                                                                             |
| `page`            | ❌  | integer | A page number within the paginated result set.                                                                                                                                                                                         |
| `pageSize`        | ❌  | integer | Number of results to return per page.                                                                                                                                                                                                  |
| `query`           | ❌  | string  | 検索キーワードです。スペース区切りで複数の条件を指定できます。検索対象：ファイル ID、ファイル名、ラベル名、Metadata value                                                                                                                                                                  |
| `status`          | ❌  | string  | ファイルのステータスで絞り込みます。指定可能な値：initial（初期状態）、processing（処理中）、done（完了）、deleting（削除中）、deleted（削除済み）、failed（失敗） \`initial\`: Initial ; \`processing\`: Processing ; \`done\`: Done ; \`deleting\`: Deleting ; \`deleted\`: Deleted ; \`faile... |

#### リクエストボディ

**リクエストパラメーター**

| フィールド | 型                               | 必須 | 説明                                              |
| ----- | ------------------------------- | -- | ----------------------------------------------- |
| files | array\[KnowledgeBaseFileCreate] | はい | Supports uploading multiple files in one batch. |

**リクエストスキーマの例**

```typescript
{
  "files": [ // Supports uploading multiple files in one batch.
    {
      "filename": string // ファイル名
      "file": string (uri) // アップロードするファイル
      "parser"?: string (uuid) // 任意
      "labels"?: [ // 任意
        {
          "id": string (uuid)
        }
      ]
      "rawUserDefineMetadata"?: object // 任意
      "asrOptions"?: object // Per-file canonical transcription options (languages, prompt, diarization). Empty means no per-file options: provider defaults apply. Completely decoupled from user-defined metadata; never indexed for search. (任意)
    }
  ]
}
```

**リクエスト値の例**

```json
{
  "files": [
    {
      "filename": "my-file.pdf",
      "file": "string",
      "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "labels": [
        {
          "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
          "name": "my-label"
        }
      ],
      "rawUserDefineMetadata": {
        "key1": "value1",
        "key2": "value2"
      }
    },
    {
      "filename": "you-can-upload-multiple-files.pdf",
      "file": "string",
      "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
    }
  ]
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "files": [
      {
        "filename": "my-file.pdf",
        "file": "string",
        "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "labels": [
          {
            "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
            "name": "my-label"
          }
        ],
        "rawUserDefineMetadata": {
          "key1": "value1",
          "key2": "value2"
        }
      },
      {
        "filename": "you-can-upload-multiple-files.pdf",
        "file": "string",
        "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      }
    ]
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "files": [
      {
        "filename": "my-file.pdf",
        "file": "string",
        "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "labels": [
          {
            "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
            "name": "my-label"
          }
        ],
        "rawUserDefineMetadata": {
          "key1": "value1",
          "key2": "value2"
        }
      },
      {
        "filename": "you-can-upload-multiple-files.pdf",
        "file": "string",
        "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
      }
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "files": [
        {
            "filename": "my-file.pdf",
            "file": "string",
            "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
            "labels": [
                {
                    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                    "name": "my-label"
                }
            ],
            "rawUserDefineMetadata": {
                "key1": "value1",
                "key2": "value2"
            }
        },
        {
            "filename": "you-can-upload-multiple-files.pdf",
            "file": "string",
            "parser": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
        }
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'files' => [
                [
                    'filename' => 'my-file.pdf',
                    'file' => 'string',
                    'parser' => '3fa85f64-5717-4562-b3fc-2c963f66afa6',
                    'labels' => [
                        [
                            'id' => '3fa85f64-5717-4562-b3fc-2c963f66afa6',
                            'name' => 'my-label'
                        ]
                    ],
                    'rawUserDefineMetadata' => [
                        'key1' => 'value1',
                        'key2' => 'value2'
                    ]
                ],
                [
                    'filename' => 'you-can-upload-multiple-files.pdf',
                    'file' => 'string',
                    'parser' => '3fa85f64-5717-4562-b3fc-2c963f66afa6'
                ]
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "filename": string // ファイル名
      "file": string (uri) // アップロードするファイル
      "fileType": string
      "knowledgeBase"?:  // 任意
      {
        "id": string (uuid)
        "name": string
      }
      "size": integer // File size in bytes
      "status": 
      {
      }
      "parser": 
      {
        "id": string (uuid)
        "name": string
        "provider": 
        {
        }
        "isTimestampSttProvider": boolean
      }
      "labels"?: [ // 任意
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "rawUserDefineMetadata"?: object // 任意
      "speakerLabels": [
        {
          "id": string (uuid)
          "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
          "customName"?: string // User-defined speaker name (e.g., John) (任意)
          "displayName": string
        }
      ]
      "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
      "chunksCount": integer // Number of chunks/nodes generated from this file
      "waitingTime": number (double)
      "processingTime": number (double)
      "processingTimeDetails": object
      "ocrStatus": string // スキャンページの OCR 結果です：done、skipped、partial、off。解析前または古いファイルでは null です
      "ocrSkippedReason": string // スキャンページで OCR が実行されなかった理由です：no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled。完了した場合は null です
      "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーがパーサーを選択したファイル、機能のリリース前にアップロードされたファイル、再判定待ちのファイルでは null です
      {
        "parser":  // 自動検出で選択されたパーサーです
        {
          "id": string (uuid)
          "name": string
          "provider": 
          {
          }
          "isTimestampSttProvider": boolean
        }
        "reason": string // 理由のカテゴリです：scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用のメッセージを表示してください
        "facts": object // 理由の根拠となる数値です（判定時に算出し、以降は再計算しません）。PDF：analyzed_pages（判定時に調べたページ数）、partial（先頭の数ページのみを調べたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての解釈が必要なページ）。Word：figures（本文中の大きな画像の数）、text_chars（本文の文字数）。その他の場合は空のオブジェクトです
        "detectedAt": string (timestamp) // 判定日時です
      }
      "previewUrl": string // プレゼンテーション（pptx/ppt）では、プレビュー可能な派生 pdf ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。それ以外は None です。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式を統一します（各
storage provider の presign/host ルールを含みます）。get_absolute_url() は不正な形式の URL を生成するため、使用しないでください。
      "createdAt": string (timestamp)
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "filename": "レスポンス文字列",
      "file": "https://example.com/file.jpg",
      "fileType": "レスポンス文字列",
      "knowledgeBase": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      },
      "size": 456,
      "status": {},
      "parser": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列",
        "provider": {},
        "isTimestampSttProvider": false
      },
      "labels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "rawUserDefineMetadata": null,
      "speakerLabels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "originalLabel": "レスポンス文字列",
          "customName": "レスポンス文字列",
          "displayName": "レスポンス文字列"
        }
      ],
      "vectorStorageSize": 456,
      "chunksCount": 456,
      "waitingTime": 456,
      "processingTime": 456,
      "processingTimeDetails": null,
      "ocrStatus": "レスポンス文字列",
      "ocrSkippedReason": "レスポンス文字列",
      "parserAutoDetection": {
        "parser": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列",
          "provider": {},
          "isTimestampSttProvider": false
        },
        "reason": "レスポンス文字列",
        "facts": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス名の例",
          "description": "レスポンスの説明の例"
        },
        "detectedAt": "レスポンス文字列"
      },
      "previewUrl": "レスポンス文字列",
      "createdAt": "レスポンス文字列"
    }
  ]
}
```

***

### ファイルのメタデータの更新 <a href="#knowledge-bases-files-update-metadata-partial-update" id="knowledge-bases-files-update-metadata-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/update-metadata/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### リクエストボディ

**リクエストパラメーター**

| フィールド                 | 型              | 必須  | 説明 |
| --------------------- | -------------- | --- | -- |
| labels                | array\[IdName] | いいえ |    |
| rawUserDefineMetadata | object         | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
}
```

**リクエスト値の例**

```json
{
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/update-metadata/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/update-metadata/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/update-metadata/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/update-metadata/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "filename": string // ファイル名
  "file": string (uri) // アップロードするファイル
  "fileType": string
  "knowledgeBase"?:  // 任意
  {
    "id": string (uuid)
    "name": string
  }
  "size": integer // File size in bytes
  "status": 
  {
  }
  "parser": 
  {
    "id": string (uuid)
    "name": string
    "provider": 
    {
    }
    "isTimestampSttProvider": boolean
  }
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "speakerLabels": [
    {
      "id": string (uuid)
      "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
      "customName"?: string // User-defined speaker name (e.g., John) (任意)
      "displayName": string
    }
  ]
  "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
  "chunksCount": integer // Number of chunks/nodes generated from this file
  "waitingTime": number (double)
  "processingTime": number (double)
  "processingTimeDetails": object
  "ocrStatus": string // スキャンページの OCR 結果です：done、skipped、partial、off。解析前または古いファイルでは null です
  "ocrSkippedReason": string // スキャンページで OCR が実行されなかった理由です：no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled。完了した場合は null です
  "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーがパーサーを選択したファイル、機能のリリース前にアップロードされたファイル、再判定待ちのファイルでは null です
  {
    "parser":  // 自動検出で選択されたパーサーです
    {
      "id": string (uuid)
      "name": string
      "provider": 
      {
      }
      "isTimestampSttProvider": boolean
    }
    "reason": string // 理由のカテゴリです：scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用のメッセージを表示してください
    "facts": object // 理由の根拠となる数値です（判定時に算出し、以降は再計算しません）。PDF：analyzed_pages（判定時に調べたページ数）、partial（先頭の数ページのみを調べたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての解釈が必要なページ）。Word：figures（本文中の大きな画像の数）、text_chars（本文の文字数）。その他の場合は空のオブジェクトです
    "detectedAt": string (timestamp) // 判定日時です
  }
  "previewUrl": string // プレゼンテーション（pptx/ppt）では、プレビュー可能な派生 pdf ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。それ以外は None です。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式を統一します（各
storage provider の presign/host ルールを含みます）。get_absolute_url() は不正な形式の URL を生成するため、使用しないでください。
  "createdAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "filename": "レスポンス文字列",
  "file": "https://example.com/file.jpg",
  "fileType": "レスポンス文字列",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "size": 456,
  "status": {},
  "parser": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列",
    "provider": {},
    "isTimestampSttProvider": false
  },
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "speakerLabels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "originalLabel": "レスポンス文字列",
      "customName": "レスポンス文字列",
      "displayName": "レスポンス文字列"
    }
  ],
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "waitingTime": 456,
  "processingTime": 456,
  "processingTimeDetails": null,
  "ocrStatus": "レスポンス文字列",
  "ocrSkippedReason": "レスポンス文字列",
  "parserAutoDetection": {
    "parser": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "provider": {},
      "isTimestampSttProvider": false
    },
    "reason": "レスポンス文字列",
    "facts": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス名の例",
      "description": "レスポンスの説明の例"
    },
    "detectedAt": "レスポンス文字列"
  },
  "previewUrl": "レスポンス文字列",
  "createdAt": "レスポンス文字列"
}
```

***

### ファイルの一括削除 <a href="#knowledge-bases-files-batch-delete-create" id="knowledge-bases-files-batch-delete-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/files/batch-delete/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明 |
| ----------------- | -- | ------ | -- |
| `knowledgeBasePk` | ✅  | string |    |

#### リクエストボディ

**リクエストパラメータ**

| フィールド | 型              | 必須 | 説明 |
| ----- | -------------- | -- | -- |
| ids   | array\[string] | はい |    |

**リクエスト構造の例**

```typescript
{
  "ids": [
    string (uuid)
  ]
}
```

**リクエスト値の例**

```json
{
  "ids": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-delete/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-delete/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-delete/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "ids": [
        "550e8400-e29b-41d4-a716-446655440000"
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-delete/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'ids' => [
                '550e8400-e29b-41d4-a716-446655440000'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンス構造の例**

```typescript
{
  "queued": [
    string (uuid)
  ]
  "skipped": [
    {
      "id": string (uuid)
      "reason": string (enum: deleting) // * `deleting` - deleting
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "queued": [
    "550e8400-e29b-41d4-a716-446655440000"
  ],
  "skipped": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "reason": "deleting"
    }
  ]
}
```

***

### ファイルの一括再解析 <a href="#knowledge-bases-files-batch-reparse-partial-update" id="knowledge-bases-files-batch-reparse-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/files/batch-reparse/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                                                                                                                                                                                                 |
| ----------------- | -- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeBasePk` | ✅  | string |                                                                                                                                                                                                                                    |
| `fileType`        | ❌  | string | ファイル形式で絞り込みます。例：pdf、docx、txt、xlsx など                                                                                                                                                                                               |
| `knowledgeBase`   | ❌  | string | ナレッジベース ID                                                                                                                                                                                                                         |
| `query`           | ❌  | string | 検索キーワードです。スペースで区切った複数条件の検索に対応しています。検索対象：ファイル ID、ファイル名、ラベル名、メタデータの値                                                                                                                                                                 |
| `status`          | ❌  | string | ファイルの状態で絞り込みます。指定可能な値：initial（初期化）、processing（処理中）、done（完了）、deleting（削除中）、deleted（削除済み）、failed（失敗） \`initial\`: Initial ; \`processing\`: Processing ; \`done\`: Done ; \`deleting\`: Deleting ; \`deleted\`: Deleted ; \`faile... |

#### コード例

{% tabs %} {% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-reparse/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&query=example&status=delete_failed" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[]'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = [];

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-reparse/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&query=example&status=delete_failed", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-reparse/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&query=example&status=delete_failed"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = []

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/batch-reparse/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&query=example&status=delete_failed", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => []
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
[
  {
    "id": string (uuid)
    "filename": string // ファイル名
    "file": string (uri) // アップロードするファイル
    "fileType": string
    "knowledgeBase"?:  // 任意
    {
      "id": string (uuid)
      "name": string
    }
    "size": integer // File size in bytes
    "status": 
    {
    }
    "parser": 
    {
      "id": string (uuid)
      "name": string
      "provider": 
      {
      }
      "isTimestampSttProvider": boolean
    }
    "labels"?: [ // 任意
      {
        "id": string (uuid)
        "name": string
      }
    ]
    "rawUserDefineMetadata"?: object // 任意
    "speakerLabels": [
      {
        "id": string (uuid)
        "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
        "customName"?: string // User-defined speaker name (e.g., John) (任意)
        "displayName": string
      }
    ]
    "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
    "chunksCount": integer // Number of chunks/nodes generated from this file
    "waitingTime": number (double)
    "processingTime": number (double)
    "processingTimeDetails": object
    "ocrStatus": string // スキャンページの OCR 結果です。値は done、skipped、partial、off です。解析前や古いファイルの場合は null です
    "ocrSkippedReason": string // スキャンページで OCR が実行されなかった理由です。値は no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled です。完了した場合は null です
    "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーが手動で選択したファイル、機能公開前にアップロードされたファイル、再判定の待機中のファイルでは null です
    {
      "parser":  // 自動検出で選択されたパーサーです
      {
        "id": string (uuid)
        "name": string
        "provider": 
        {
        }
        "isTimestampSttProvider": boolean
      }
      "reason": string // 理由のカテゴリです。値は scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable です。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用メッセージを表示してください
      "facts": object // 理由の根拠となる数値です（判定時に計算し、その後は再計算しません）。PDF：analyzed_pages（判定で調べたページ数）、partial（冒頭の数ページのみを調べたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての解釈が必要なページ）。Word：figures（本文中の大きな画像の数）、text_chars（本文の文字数）。その他の場合は空のオブジェクトです
      "detectedAt": string (timestamp) // 判定日時です
    }
    "previewUrl": string // プレゼンテーション（pptx/ppt）の場合は、プレビュー用に生成された PDF ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。その他の場合は None です。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式を統一します（各
storage provider の presign/host ルールを含みます）。get_absolute_url() は不正な形式の URL を生成するため、使用しないでください。
    "createdAt": string (timestamp)
    "reparseSkippedReason": string
  }
]
```

**レスポンス値の例**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "filename": "レスポンス文字列",
    "file": "https://example.com/file.jpg",
    "fileType": "レスポンス文字列",
    "knowledgeBase": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    },
    "size": 456,
    "status": {},
    "parser": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "provider": {},
      "isTimestampSttProvider": false
    },
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      }
    ],
    "rawUserDefineMetadata": null,
    "speakerLabels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "originalLabel": "レスポンス文字列",
        "customName": "レスポンス文字列",
        "displayName": "レスポンス文字列"
      }
    ],
    "vectorStorageSize": 456,
    "chunksCount": 456,
    "waitingTime": 456,
    "processingTime": 456,
    "processingTimeDetails": null,
    "ocrStatus": "レスポンス文字列",
    "ocrSkippedReason": "レスポンス文字列",
    "parserAutoDetection": {
      "parser": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列",
        "provider": {},
        "isTimestampSttProvider": false
      },
      "reason": "レスポンス文字列",
      "facts": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンスのサンプル名",
        "description": "レスポンスのサンプル説明"
      },
      "detectedAt": "レスポンス文字列"
    },
    "previewUrl": "レスポンス文字列",
    "createdAt": "レスポンス文字列",
    "reparseSkippedReason": "レスポンス文字列"
  }
]
```

***

### ナレッジベース内のファイル一覧を取得 <a href="#knowledge-bases-files-list" id="knowledge-bases-files-list"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/`

{% hint style="info" %}
システムがパーサーを自動検出するファイルでは、レスポンスの `parserAutoDetection` に、選択されたパーサー、理由のカテゴリ（`reason`）、判定に使用した数値（`facts`）、判定時刻が含まれます。ユーザーがパーサーを選択したファイルでは `null` になります。各フィールド、`null` になる条件、理由のカテゴリと数値の対応については、[パーサーの自動検出結果](/api/ja/preparation/parser-auto-detection.md)を参照してください。
{% endhint %}

#### パラメーター

| パラメーター名           | 必須 | 型       | 説明                                                                                                                                                                                                                                 |
| ----------------- | -- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeBasePk` | ✅  | string  |                                                                                                                                                                                                                                    |
| `fileType`        | ❌  | string  | ファイル形式で絞り込みます。例：pdf、docx、txt、xlsx など                                                                                                                                                                                               |
| `knowledgeBase`   | ❌  | string  | ナレッジベース ID                                                                                                                                                                                                                         |
| `page`            | ❌  | integer | A page number within the paginated result set.                                                                                                                                                                                     |
| `pageSize`        | ❌  | integer | Number of results to return per page.                                                                                                                                                                                              |
| `query`           | ❌  | string  | 検索キーワードです。スペースで区切った複数条件の検索に対応しています。検索対象：ファイル ID、ファイル名、ラベル名、Metadata value                                                                                                                                                          |
| `status`          | ❌  | string  | ファイルの状態で絞り込みます。選択可能な値：initial（初期化）、processing（処理中）、done（完了）、deleting（削除中）、deleted（削除済み）、failed（失敗） \`initial\`: Initial ; \`processing\`: Processing ; \`done\`: Done ; \`deleting\`: Deleting ; \`deleted\`: Deleted ; \`faile... |

#### コード例

{% tabs %} {% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/?fileType=example&knowledgeBase=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&query=example&status=delete_failed", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "filename": string // ファイル名
      "file": string (uri) // アップロードするファイル
      "fileType": string
      "knowledgeBase"?:  // 任意
      {
        "id": string (uuid)
        "name": string
      }
      "size": integer // File size in bytes
      "status": 
      {
      }
      "parser": 
      {
        "id": string (uuid)
        "name": string
        "provider": 
        {
        }
        "isTimestampSttProvider": boolean
      }
      "labels"?: [ // 任意
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "rawUserDefineMetadata"?: object // 任意
      "speakerLabels": [
        {
          "id": string (uuid)
          "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
          "customName"?: string // User-defined speaker name (e.g., John) (任意)
          "displayName": string
        }
      ]
      "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
      "chunksCount": integer // Number of chunks/nodes generated from this file
      "waitingTime": number (double)
      "processingTime": number (double)
      "processingTimeDetails": object
      "ocrStatus": string // スキャンページの OCR 結果です。値：done、skipped、partial、off。解析前や古いファイルでは null になります
      "ocrSkippedReason": string // スキャンページに OCR を実行しなかった理由です。値：no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled。OCR が完了した場合は null になります
      "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーが選択したファイル、機能の提供開始前にアップロードされたファイル、再判定の待機中のファイルでは null になります
      {
        "parser":  // 自動検出で選択されたパーサーです
        {
          "id": string (uuid)
          "name": string
          "provider": 
          {
          }
          "isTimestampSttProvider": boolean
        }
        "reason": string // 理由のカテゴリです。値：scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用メッセージを表示してください
        "facts": object // 理由に関する数値です（判定時に算出され、その後は再計算されません）。PDF：analyzed_pages（判定対象のページ数）、partial（先頭の数ページのみを対象としたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての判読が必要なページ）。Word：figures（本文中の大きな画像の数）、text_chars（本文の文字数）。その他の場合は空のオブジェクトになります
        "detectedAt": string (timestamp) // 判定時刻
      }
      "previewUrl": string // プレゼンテーション（pptx/ppt）の場合、プレビュー可能な派生 PDF ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。その他の場合は None になります。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式を統一します（各
ストレージプロバイダーの presign/host ルールを含みます）。get_absolute_url() は誤った形式の URL を生成するため、使用しないでください。
      "createdAt": string (timestamp)
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "filename": "レスポンス文字列",
      "file": "https://example.com/file.jpg",
      "fileType": "レスポンス文字列",
      "knowledgeBase": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      },
      "size": 456,
      "status": {},
      "parser": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列",
        "provider": {},
        "isTimestampSttProvider": false
      },
      "labels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "rawUserDefineMetadata": null,
      "speakerLabels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "originalLabel": "レスポンス文字列",
          "customName": "レスポンス文字列",
          "displayName": "レスポンス文字列"
        }
      ],
      "vectorStorageSize": 456,
      "chunksCount": 456,
      "waitingTime": 456,
      "processingTime": 456,
      "processingTimeDetails": null,
      "ocrStatus": "レスポンス文字列",
      "ocrSkippedReason": "レスポンス文字列",
      "parserAutoDetection": {
        "parser": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列",
          "provider": {},
          "isTimestampSttProvider": false
        },
        "reason": "レスポンス文字列",
        "facts": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス名の例",
          "description": "レスポンス説明の例"
        },
        "detectedAt": "レスポンス文字列"
      },
      "previewUrl": "レスポンス文字列",
      "createdAt": "レスポンス文字列"
    }
  ]
}
```

***

### 特定のファイルの詳細を取得 <a href="#knowledge-bases-files-retrieve" id="knowledge-bases-files-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/`

{% hint style="info" %}
システムがパーサーを自動検出するファイルでは、レスポンスの `parserAutoDetection` に、選択されたパーサー、理由のカテゴリ（`reason`）、判定に使用した数値（`facts`）、判定時刻が含まれます。ユーザーがパーサーを選択したファイルでは `null` になります。各フィールド、`null` になる条件、理由のカテゴリと数値の対応については、[パーサーの自動検出結果](/api/ja/preparation/parser-auto-detection.md)を参照してください。
{% endhint %}

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "filename": string // ファイル名
  "file": string (uri) // アップロードするファイル
  "fileType": string
  "knowledgeBase"?:  // 任意
  {
    "id": string (uuid)
    "name": string
  }
  "size": integer // File size in bytes
  "status": 
  {
  }
  "parser": 
  {
    "id": string (uuid)
    "name": string
    "provider": 
    {
    }
    "isTimestampSttProvider": boolean
  }
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "speakerLabels": [
    {
      "id": string (uuid)
      "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
      "customName"?: string // User-defined speaker name (e.g., John) (任意)
      "displayName": string
    }
  ]
  "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
  "chunksCount": integer // Number of chunks/nodes generated from this file
  "waitingTime": number (double)
  "processingTime": number (double)
  "processingTimeDetails": object
  "ocrStatus": string // スキャンページの OCR 結果です。値：done、skipped、partial、off。解析前や古いファイルでは null になります
  "ocrSkippedReason": string // スキャンページに OCR を実行しなかった理由です。値：no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled。OCR が完了した場合は null になります
  "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーが選択したファイル、機能の提供開始前にアップロードされたファイル、再判定の待機中のファイルでは null になります
  {
    "parser":  // 自動検出で選択されたパーサーです
    {
      "id": string (uuid)
      "name": string
      "provider": 
      {
      }
      "isTimestampSttProvider": boolean
    }
    "reason": string // 理由のカテゴリです。値：scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用メッセージを表示してください
    "facts": object // 理由に関する数値です（判定時に算出され、その後は再計算されません）。PDF：analyzed_pages（判定対象のページ数）、partial（先頭の数ページのみを対象としたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての判読が必要なページ）。Word：figures（本文中の大きな画像の数）、text_chars（本文の文字数）。その他の場合は空のオブジェクトになります
    "detectedAt": string (timestamp) // 判定時刻
  }
  "previewUrl": string // プレゼンテーション（pptx/ppt）の場合、プレビュー可能な派生 PDF ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。その他の場合は None になります。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式を統一します（各
ストレージプロバイダーの presign/host ルールを含みます）。get_absolute_url() は誤った形式の URL を生成するため、使用しないでください。
  "createdAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "filename": "レスポンス文字列",
  "file": "https://example.com/file.jpg",
  "fileType": "レスポンス文字列",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "size": 456,
  "status": {},
  "parser": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列",
    "provider": {},
    "isTimestampSttProvider": false
  },
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "speakerLabels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "originalLabel": "レスポンス文字列",
      "customName": "レスポンス文字列",
      "displayName": "レスポンス文字列"
    }
  ],
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "waitingTime": 456,
  "processingTime": 456,
  "processingTimeDetails": null,
  "ocrStatus": "レスポンス文字列",
  "ocrSkippedReason": "レスポンス文字列",
  "parserAutoDetection": {
    "parser": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "provider": {},
      "isTimestampSttProvider": false
    },
    "reason": "レスポンス文字列",
    "facts": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス名の例",
      "description": "レスポンス説明の例"
    },
    "detectedAt": "レスポンス文字列"
  },
  "previewUrl": "レスポンス文字列",
  "createdAt": "レスポンス文字列"
}
```

***

### ファイルの最新の失敗原因を取得 <a href="#knowledge-bases-files-latest-failed-reason-retrieve" id="knowledge-bases-files-latest-failed-reason-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/latest-failed-reason/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/latest-failed-reason/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/latest-failed-reason/", config)
  .then(response => {
    console.log('レスポンスを取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/latest-failed-reason/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/latest-failed-reason/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "errorMessage": string
  "errorCode"?: string // Machine-readable code of a known failure type (see FAILED_REASON_LOCALIZED_MESSAGES in whizchat/parsers/exceptions.py); the serializer translates it into the request language on read. An empty string means no translation, and error_message is shown as is. (任意)
  "createdAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "errorMessage": "レスポンス文字列",
  "errorCode": "レスポンス文字列",
  "createdAt": "レスポンス文字列"
}
```

***

### ファイルの文字起こし内容を取得 <a href="#knowledge-bases-files-transcription-retrieve" id="knowledge-bases-files-transcription-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/transcription/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/transcription/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/transcription/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/transcription/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/transcription/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "filename": string // ファイル名
  "file": string (uri) // アップロードするファイル
  "fileType": string
  "knowledgeBase"?:  // 任意
  {
    "id": string (uuid)
    "name": string
  }
  "size": integer // File size in bytes
  "status": 
  {
  }
  "parser": 
  {
    "id": string (uuid)
    "name": string
    "provider": 
    {
    }
    "isTimestampSttProvider": boolean
  }
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "speakerLabels": [
    {
      "id": string (uuid)
      "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
      "customName"?: string // User-defined speaker name (e.g., John) (任意)
      "displayName": string
    }
  ]
  "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
  "chunksCount": integer // Number of chunks/nodes generated from this file
  "waitingTime": number (double)
  "processingTime": number (double)
  "processingTimeDetails": object
  "ocrStatus": string // スキャンページの OCR 結果です。done、skipped、partial、off のいずれかです。解析前または既存の古いファイルでは null です
  "ocrSkippedReason": string // スキャンページで OCR を実行しなかった理由です。no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled のいずれかです。完了した場合は null です
  "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーがパーサーを選択したファイル、機能のリリース前にアップロードしたファイル、再検出の待機中のファイルでは null です
  {
    "parser":  // 自動検出で選択されたパーサーです
    {
      "id": string (uuid)
      "name": string
      "provider": 
      {
      }
      "isTimestampSttProvider": boolean
    }
    "reason": string // 理由のカテゴリです。scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable のいずれかです。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用メッセージを表示してください
    "facts": object // 理由に含まれる数値です（検出時に計算し、その後は再計算しません）。PDF：analyzed_pages（検出時に調べたページ数）、partial（最初の数ページのみを調べたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての解釈が必要なページ）です。Word：figures（本文中の大きな画像数）、text_chars（本文の文字数）です。それ以外の場合は空のオブジェクトです
    "detectedAt": string (timestamp) // 検出日時です
  }
  "previewUrl": string // プレゼンテーション（pptx/ppt）の場合、プレビュー可能な派生 PDF ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。それ以外は None です。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式の一貫性を確保します（各
ストレージプロバイダーの presign/host ルールを含みます）。get_absolute_url() は誤った形式の URL を生成するため、使用しないでください。
  "createdAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "filename": "レスポンス文字列",
  "file": "https://example.com/file.jpg",
  "fileType": "レスポンス文字列",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "size": 456,
  "status": {},
  "parser": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列",
    "provider": {},
    "isTimestampSttProvider": false
  },
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "speakerLabels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "originalLabel": "レスポンス文字列",
      "customName": "レスポンス文字列",
      "displayName": "レスポンス文字列"
    }
  ],
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "waitingTime": 456,
  "processingTime": 456,
  "processingTimeDetails": null,
  "ocrStatus": "レスポンス文字列",
  "ocrSkippedReason": "レスポンス文字列",
  "parserAutoDetection": {
    "parser": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "provider": {},
      "isTimestampSttProvider": false
    },
    "reason": "レスポンス文字列",
    "facts": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンスの名前の例",
      "description": "レスポンスの説明の例"
    },
    "detectedAt": "レスポンス文字列"
  },
  "previewUrl": "レスポンス文字列",
  "createdAt": "レスポンス文字列"
}
```

***

### ファイル情報を更新 <a href="#knowledge-bases-files-update" id="knowledge-bases-files-update"></a>

PUT `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### リクエストボディ

**リクエストパラメーター**

| フィールド                 | 型              | 必須  | 説明                                                                                                                                                                                                          |
| --------------------- | -------------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filename              | string         | はい  | ファイル名                                                                                                                                                                                                       |
| file                  | string (uri)   | はい  | アップロードするファイル                                                                                                                                                                                                |
| parser                | string (uuid)  | いいえ |                                                                                                                                                                                                             |
| labels                | array\[IdName] | いいえ |                                                                                                                                                                                                             |
| rawUserDefineMetadata | object         | いいえ |                                                                                                                                                                                                             |
| asrOptions            | object         | いいえ | Per-file canonical transcription options (languages, prompt, diarization). Empty means no per-file options: provider defaults apply. Completely decoupled from user-defined metadata; never indexed for ... |

**リクエストスキーマの例**

```typescript
{
  "filename": string // ファイル名
  "file": string (uri) // アップロードするファイル
  "parser"?: string (uuid) // 任意
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "asrOptions"?: object // Per-file canonical transcription options (languages, prompt, diarization). Empty means no per-file options: provider defaults apply. Completely decoupled from user-defined metadata; never indexed for search. (任意)
}
```

**リクエストの値の例**

```json
{
  "filename": "document.pdf",
  "file": "https://example.com/file.jpg",
  "parser": "550e8400-e29b-41d4-a716-446655440000",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null,
  "asrOptions": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "parser": "550e8400-e29b-41d4-a716-446655440000",
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null,
    "asrOptions": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "parser": "550e8400-e29b-41d4-a716-446655440000",
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null,
    "asrOptions": null
  };

axios.put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "parser": "550e8400-e29b-41d4-a716-446655440000",
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None,
    "asrOptions": None
}

response = requests.put(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'filename' => 'document.pdf',
            'file' => 'https://example.com/file.jpg',
            'parser' => '550e8400-e29b-41d4-a716-446655440000',
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null,
            'asrOptions' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "filename": string // ファイル名
  "file": string (uri) // アップロードするファイル
  "fileType": string
  "knowledgeBase"?:  // 任意
  {
    "id": string (uuid)
    "name": string
  }
  "size": integer // File size in bytes
  "status": 
  {
  }
  "parser": 
  {
    "id": string (uuid)
    "name": string
    "provider": 
    {
    }
    "isTimestampSttProvider": boolean
  }
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "speakerLabels": [
    {
      "id": string (uuid)
      "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
      "customName"?: string // User-defined speaker name (e.g., John) (任意)
      "displayName": string
    }
  ]
  "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
  "chunksCount": integer // Number of chunks/nodes generated from this file
  "waitingTime": number (double)
  "processingTime": number (double)
  "processingTimeDetails": object
  "ocrStatus": string // スキャンページの OCR 結果です。done、skipped、partial、off のいずれかです。解析前または既存の古いファイルでは null です
  "ocrSkippedReason": string // スキャンページで OCR を実行しなかった理由です。no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled のいずれかです。完了した場合は null です
  "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーがパーサーを選択したファイル、機能のリリース前にアップロードしたファイル、再検出の待機中のファイルでは null です
  {
    "parser":  // 自動検出で選択されたパーサーです
    {
      "id": string (uuid)
      "name": string
      "provider": 
      {
      }
      "isTimestampSttProvider": boolean
    }
    "reason": string // 理由のカテゴリです。scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable のいずれかです。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用メッセージを表示してください
    "facts": object // 理由に含まれる数値です（検出時に計算し、その後は再計算しません）。PDF：analyzed_pages（検出時に調べたページ数）、partial（最初の数ページのみを調べたかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての解釈が必要なページ）です。Word：figures（本文中の大きな画像数）、text_chars（本文の文字数）です。それ以外の場合は空のオブジェクトです
    "detectedAt": string (timestamp) // 検出日時です
  }
  "previewUrl": string // プレゼンテーション（pptx/ppt）の場合、プレビュー可能な派生 PDF ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。それ以外は None です。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式の一貫性を確保します（各
ストレージプロバイダーの presign/host ルールを含みます）。get_absolute_url() は誤った形式の URL を生成するため、使用しないでください。
  "createdAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "filename": "レスポンス文字列",
  "file": "https://example.com/file.jpg",
  "fileType": "レスポンス文字列",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "size": 456,
  "status": {},
  "parser": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列",
    "provider": {},
    "isTimestampSttProvider": false
  },
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "speakerLabels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "originalLabel": "レスポンス文字列",
      "customName": "レスポンス文字列",
      "displayName": "レスポンス文字列"
    }
  ],
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "waitingTime": 456,
  "processingTime": 456,
  "processingTimeDetails": null,
  "ocrStatus": "レスポンス文字列",
  "ocrSkippedReason": "レスポンス文字列",
  "parserAutoDetection": {
    "parser": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "provider": {},
      "isTimestampSttProvider": false
    },
    "reason": "レスポンス文字列",
    "facts": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンスの名前の例",
      "description": "レスポンスの説明の例"
    },
    "detectedAt": "レスポンス文字列"
  },
  "previewUrl": "レスポンス文字列",
  "createdAt": "レスポンス文字列"
}
```

***

### ファイルを部分更新 <a href="#knowledge-bases-files-partial-update" id="knowledge-bases-files-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### リクエストボディ

**リクエストパラメーター**

| フィールド                 | 型              | 必須  | 説明                                                                                                                                                                                                          |
| --------------------- | -------------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filename              | string         | いいえ | ファイル名                                                                                                                                                                                                       |
| file                  | string (uri)   | いいえ | アップロードするファイル                                                                                                                                                                                                |
| parser                | string (uuid)  | いいえ |                                                                                                                                                                                                             |
| labels                | array\[IdName] | いいえ |                                                                                                                                                                                                             |
| rawUserDefineMetadata | object         | いいえ |                                                                                                                                                                                                             |
| asrOptions            | object         | いいえ | Per-file canonical transcription options (languages, prompt, diarization). Empty means no per-file options: provider defaults apply. Completely decoupled from user-defined metadata; never indexed for ... |

**リクエストスキーマの例**

```typescript
{
  "filename"?: string // ファイル名 (任意)
  "file"?: string (uri) // アップロードするファイル (任意)
  "parser"?: string (uuid) // 任意
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "asrOptions"?: object // Per-file canonical transcription options (languages, prompt, diarization). Empty means no per-file options: provider defaults apply. Completely decoupled from user-defined metadata; never indexed for search. (任意)
}
```

**リクエストの値の例**

```json
{
  "filename": "document.pdf",
  "file": "https://example.com/file.jpg",
  "parser": "550e8400-e29b-41d4-a716-446655440000",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null,
  "asrOptions": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "parser": "550e8400-e29b-41d4-a716-446655440000",
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null,
    "asrOptions": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "parser": "550e8400-e29b-41d4-a716-446655440000",
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null,
    "asrOptions": null
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "filename": "document.pdf",
    "file": "https://example.com/file.jpg",
    "parser": "550e8400-e29b-41d4-a716-446655440000",
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None,
    "asrOptions": None
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'filename' => 'document.pdf',
            'file' => 'https://example.com/file.jpg',
            'parser' => '550e8400-e29b-41d4-a716-446655440000',
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null,
            'asrOptions' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "filename": string // ファイル名
  "file": string (uri) // アップロードするファイル
  "fileType": string
  "knowledgeBase"?:  // 任意
  {
    "id": string (uuid)
    "name": string
  }
  "size": integer // File size in bytes
  "status": 
  {
  }
  "parser": 
  {
    "id": string (uuid)
    "name": string
    "provider": 
    {
    }
    "isTimestampSttProvider": boolean
  }
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "speakerLabels": [
    {
      "id": string (uuid)
      "originalLabel": string // Original speaker label from diarization (e.g., SPEAKER_00)
      "customName"?: string // User-defined speaker name (e.g., John) (任意)
      "displayName": string
    }
  ]
  "vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
  "chunksCount": integer // Number of chunks/nodes generated from this file
  "waitingTime": number (double)
  "processingTime": number (double)
  "processingTimeDetails": object
  "ocrStatus": string // スキャンページの OCR 結果です。done、skipped、partial、off のいずれかです。解析前または古いファイルでは null です
  "ocrSkippedReason": string // スキャンページで OCR を実行しなかった理由です。no_azure_settings、azure_unavailable、insufficient_credits、transient_error、time_budget、disabled のいずれかです。OCR が完了した場合は null です
  "parserAutoDetection":  // このファイルのパーサーを自動検出で選択した結果と理由です。ユーザーがパーサーを選択したファイル、機能公開前にアップロードしたファイル、再判定待ちのファイルでは null です
  {
    "parser":  // 自動検出で選択されたパーサーです
    {
      "id": string (uuid)
      "name": string
      "provider": 
      {
      }
      "isTimestampSttProvider": boolean
    }
    "reason": string // 理由のカテゴリです。scanned、image_pages、large_images、unmeasurable_images、presentation、no_image_content、below_threshold、no_content、file_type_not_detected、detection_failed、vision_unavailable のいずれかです。今後カテゴリが追加される可能性があるため、対応する文言がない場合は汎用メッセージを表示してください
    "facts": object // 理由の根拠となる数値です（判定時に算出し、その後は再計算しません）。PDF：analyzed_pages（判定で確認したページ数）、partial（先頭の数ページのみを確認したかどうか）、non_blank_pages、scanned_pages、image_pages（画像としての判読が必要なページ）です。Word：figures（本文内の大きな画像数）、text_chars（本文の文字数）です。それ以外の場合は空のオブジェクトです
    "detectedAt": string (timestamp) // 判定時刻です
  }
  "previewUrl": string // プレゼンテーション（pptx/ppt）の場合は、プレビュー用に生成した PDF ファイルの URL を返します（フロントエンドの PDF ビューアーで表示します）。それ以外は None です。

`file` フィールドと同じ CustomizedFileFieldSerializer で URL を生成し、形式を統一します（各
storage provider の presign/host ルールを含みます）。get_absolute_url() は誤った形式の URL を生成するため、使用しないでください。
  "createdAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "filename": "レスポンス文字列",
  "file": "https://example.com/file.jpg",
  "fileType": "レスポンス文字列",
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "size": 456,
  "status": {},
  "parser": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列",
    "provider": {},
    "isTimestampSttProvider": false
  },
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "speakerLabels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "originalLabel": "レスポンス文字列",
      "customName": "レスポンス文字列",
      "displayName": "レスポンス文字列"
    }
  ],
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "waitingTime": 456,
  "processingTime": 456,
  "processingTimeDetails": null,
  "ocrStatus": "レスポンス文字列",
  "ocrSkippedReason": "レスポンス文字列",
  "parserAutoDetection": {
    "parser": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列",
      "provider": {},
      "isTimestampSttProvider": false
    },
    "reason": "レスポンス文字列",
    "facts": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス例の名前",
      "description": "レスポンス例の説明"
    },
    "detectedAt": "レスポンス文字列"
  },
  "previewUrl": "レスポンス文字列",
  "createdAt": "レスポンス文字列"
}
```

***

### ファイルの削除 <a href="#knowledge-bases-files-destroy" id="knowledge-bases-files-destroy"></a>

DELETE `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                                  |
| ----------------- | -- | ------ | --------------------------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this Knowledge Base File. |
| `knowledgeBasePk` | ✅  | string |                                                     |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーの設定
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエストボディ (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスの取得に成功しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスの取得に成功しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/files/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスの取得に成功しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 202**

**レスポンススキーマの例**

```typescript
{
  "detail": string
}
```

**レスポンス値の例**

```json
{
  "detail": "レスポンス文字列"
}
```

**ステータスコード: 204 - No response body**

***

### ファイル翻訳の作成 <a href="#knowledge-bases-files-translations-create" id="knowledge-bases-files-translations-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/`

#### パラメータ

| パラメーター名               | 必須 | 型      | 説明 |
| --------------------- | -- | ------ | -- |
| `knowledgeBaseFilePk` | ✅  | string |    |
| `knowledgeBasePk`     | ✅  | string |    |

#### リクエストボディ

**リクエストパラメーター**

| フィールド                | 型             | 必須  | 説明 |
| -------------------- | ------------- | --- | -- |
| sourceLanguage       | string        | いいえ |    |
| targetLanguage       | string        | はい  |    |
| customPrompt         | string        | いいえ |    |
| largeLanguageModelId | string (uuid) | はい  |    |

**リクエストスキーマの例**

```typescript
{
  "sourceLanguage"?: string // 任意
  "targetLanguage": string
  "customPrompt"?: string // 任意
  "largeLanguageModelId": string (uuid)
}
```

**リクエストの値の例**

```json
{
  "sourceLanguage": "サンプル文字列",
  "targetLanguage": "サンプル文字列",
  "customPrompt": "サンプル文字列",
  "largeLanguageModelId": "550e8400-e29b-41d4-a716-446655440000"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "sourceLanguage": "サンプル文字列",
    "targetLanguage": "サンプル文字列",
    "customPrompt": "サンプル文字列",
    "largeLanguageModelId": "550e8400-e29b-41d4-a716-446655440000"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "sourceLanguage": "サンプル文字列",
    "targetLanguage": "サンプル文字列",
    "customPrompt": "サンプル文字列",
    "largeLanguageModelId": "550e8400-e29b-41d4-a716-446655440000"
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "sourceLanguage": "サンプル文字列",
    "targetLanguage": "サンプル文字列",
    "customPrompt": "サンプル文字列",
    "largeLanguageModelId": "550e8400-e29b-41d4-a716-446655440000"
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'sourceLanguage' => 'サンプル文字列',
            'targetLanguage' => 'サンプル文字列',
            'customPrompt' => 'サンプル文字列',
            'largeLanguageModelId' => '550e8400-e29b-41d4-a716-446655440000'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "sourceLanguage"?: string // 任意
  "targetLanguage": string
  "customPrompt"?: string // 任意
  "largeLanguageModelId": string (uuid)
}
```

**レスポンスの値の例**

```json
{
  "sourceLanguage": "レスポンス文字列",
  "targetLanguage": "レスポンス文字列",
  "customPrompt": "レスポンス文字列",
  "largeLanguageModelId": "550e8400-e29b-41d4-a716-446655440000"
}
```

***

### ファイル翻訳の一覧を取得 <a href="#knowledge-bases-files-translations-list" id="knowledge-bases-files-translations-list"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/`

#### パラメーター

| パラメーター名               | 必須 | 型       | 説明                                             |
| --------------------- | -- | ------- | ---------------------------------------------- |
| `knowledgeBaseFilePk` | ✅  | string  |                                                |
| `knowledgeBasePk`     | ✅  | string  |                                                |
| `page`                | ❌  | integer | A page number within the paginated result set. |
| `pageSize`            | ❌  | integer | Number of results to return per page.          |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/?page=1&pageSize=1" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/?page=1&pageSize=1", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/?page=1&pageSize=1"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/?page=1&pageSize=1", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "chatbotFileId": string (uuid)
      "chatbotFileFilename": string
      "organization": string (uuid)
      "largeLanguageModel": 
      {
        "id": string (uuid)
        "name": string
      }
      "sourceLanguage": string
      "targetLanguage": string
      "customPrompt": string // User-provided terminology/glossary rules
      "status": 
      {
      }
      "errorMessage": string
      "translatedFileUrl": string
      "bilingualFileUrl": string
      "processDuration": string
      "processingDurationSeconds": number (double)
      "pageCount": integer
      "originalWordCount": integer
      "translatedWordCount": integer
      "inputTokensUsed": integer
      "outputTokensUsed": integer
      "totalTokensUsed": integer
      "originalFileSize": integer
      "translatedFileSize": integer
      "bilingualFileSize": integer
      "llmTranslationDuration": string // Total time spent on LLM API calls
      "llmTranslationDurationSeconds": number (double)
      "llmCallCount": integer // Number of LLM API calls made
      "avgLlmCallDuration": number (double) // Average time per LLM call in seconds
      "pdfParsingDuration": string // Time spent on PDF parsing and processing
      "pdfParsingDurationSeconds": number (double)
      "fileSavingDuration": string // Time spent on saving output files
      "fileSavingDurationSeconds": number (double)
      "startedAt": string (timestamp)
      "completedAt": string (timestamp)
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "chatbotFileId": "550e8400-e29b-41d4-a716-446655440000",
      "chatbotFileFilename": "レスポンス文字列",
      "organization": "550e8400-e29b-41d4-a716-446655440000",
      "largeLanguageModel": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      },
      "sourceLanguage": "レスポンス文字列",
      "targetLanguage": "レスポンス文字列",
      "customPrompt": "レスポンス文字列",
      "status": {},
      "errorMessage": "レスポンス文字列",
      "translatedFileUrl": "レスポンス文字列",
      "bilingualFileUrl": "レスポンス文字列",
      "processDuration": "レスポンス文字列",
      "processingDurationSeconds": 456,
      "pageCount": 456,
      "originalWordCount": 456,
      "translatedWordCount": 456,
      "inputTokensUsed": 456,
      "outputTokensUsed": 456,
      "totalTokensUsed": 456,
      "originalFileSize": 456,
      "translatedFileSize": 456,
      "bilingualFileSize": 456,
      "llmTranslationDuration": "レスポンス文字列",
      "llmTranslationDurationSeconds": 456,
      "llmCallCount": 456,
      "avgLlmCallDuration": 456,
      "pdfParsingDuration": "レスポンス文字列",
      "pdfParsingDurationSeconds": 456,
      "fileSavingDuration": "レスポンス文字列",
      "fileSavingDurationSeconds": 456,
      "startedAt": "レスポンス文字列",
      "completedAt": "レスポンス文字列",
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### 特定の翻訳を取得 <a href="#knowledge-bases-files-translations-retrieve" id="knowledge-bases-files-translations-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/{id}/`

#### パラメーター

| パラメーター名               | 必須 | 型      | 説明                                               |
| --------------------- | -- | ------ | ------------------------------------------------ |
| `id`                  | ✅  | string | A UUID string identifying this File Translation. |
| `knowledgeBaseFilePk` | ✅  | string |                                                  |
| `knowledgeBasePk`     | ✅  | string |                                                  |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "chatbotFileId": string (uuid)
  "chatbotFileFilename": string
  "organization": string (uuid)
  "largeLanguageModel": 
  {
    "id": string (uuid)
    "name": string
  }
  "sourceLanguage": string
  "targetLanguage": string
  "customPrompt": string // User-provided terminology/glossary rules
  "status": 
  {
  }
  "errorMessage": string
  "translatedFileUrl": string
  "bilingualFileUrl": string
  "processDuration": string
  "processingDurationSeconds": number (double)
  "pageCount": integer
  "originalWordCount": integer
  "translatedWordCount": integer
  "inputTokensUsed": integer
  "outputTokensUsed": integer
  "totalTokensUsed": integer
  "originalFileSize": integer
  "translatedFileSize": integer
  "bilingualFileSize": integer
  "llmTranslationDuration": string // Total time spent on LLM API calls
  "llmTranslationDurationSeconds": number (double)
  "llmCallCount": integer // Number of LLM API calls made
  "avgLlmCallDuration": number (double) // Average time per LLM call in seconds
  "pdfParsingDuration": string // Time spent on PDF parsing and processing
  "pdfParsingDurationSeconds": number (double)
  "fileSavingDuration": string // Time spent on saving output files
  "fileSavingDurationSeconds": number (double)
  "startedAt": string (timestamp)
  "completedAt": string (timestamp)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "chatbotFileId": "550e8400-e29b-41d4-a716-446655440000",
  "chatbotFileFilename": "レスポンス文字列",
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "largeLanguageModel": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "sourceLanguage": "レスポンス文字列",
  "targetLanguage": "レスポンス文字列",
  "customPrompt": "レスポンス文字列",
  "status": {},
  "errorMessage": "レスポンス文字列",
  "translatedFileUrl": "レスポンス文字列",
  "bilingualFileUrl": "レスポンス文字列",
  "processDuration": "レスポンス文字列",
  "processingDurationSeconds": 456,
  "pageCount": 456,
  "originalWordCount": 456,
  "translatedWordCount": 456,
  "inputTokensUsed": 456,
  "outputTokensUsed": 456,
  "totalTokensUsed": 456,
  "originalFileSize": 456,
  "translatedFileSize": 456,
  "bilingualFileSize": 456,
  "llmTranslationDuration": "レスポンス文字列",
  "llmTranslationDurationSeconds": 456,
  "llmCallCount": 456,
  "avgLlmCallDuration": 456,
  "pdfParsingDuration": "レスポンス文字列",
  "pdfParsingDurationSeconds": 456,
  "fileSavingDuration": "レスポンス文字列",
  "fileSavingDurationSeconds": 456,
  "startedAt": "レスポンス文字列",
  "completedAt": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### 翻訳を削除 <a href="#knowledge-bases-files-translations-destroy" id="knowledge-bases-files-translations-destroy"></a>

DELETE `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/{id}/`

#### パラメーター

| パラメーター名               | 必須 | 型      | 説明                                               |
| --------------------- | -- | ------ | ------------------------------------------------ |
| `id`                  | ✅  | string | A UUID string identifying this File Translation. |
| `knowledgeBaseFilePk` | ✅  | string |                                                  |
| `knowledgeBasePk`     | ✅  | string |                                                  |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエストボディ (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### 翻訳済みファイルをダウンロード <a href="#knowledge-bases-files-translations-download-retrieve" id="knowledge-bases-files-translations-download-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/{id}/download/`

#### パラメーター

| パラメーター名               | 必須 | 型      | 説明                                               |
| --------------------- | -- | ------ | ------------------------------------------------ |
| `id`                  | ✅  | string | A UUID string identifying this File Translation. |
| `knowledgeBaseFilePk` | ✅  | string |                                                  |
| `knowledgeBasePk`     | ✅  | string |                                                  |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/download/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/download/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/download/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/{knowledgeBasePk}/files/{knowledgeBaseFilePk}/translations/550e8400-e29b-41d4-a716-446655440000/download/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "chatbotFileId": string (uuid)
  "chatbotFileFilename": string
  "organization": string (uuid)
  "largeLanguageModel": 
  {
    "id": string (uuid)
    "name": string
  }
  "sourceLanguage": string
  "targetLanguage": string
  "customPrompt": string // User-provided terminology/glossary rules
  "status": 
  {
  }
  "errorMessage": string
  "translatedFileUrl": string
  "bilingualFileUrl": string
  "processDuration": string
  "processingDurationSeconds": number (double)
  "pageCount": integer
  "originalWordCount": integer
  "translatedWordCount": integer
  "inputTokensUsed": integer
  "outputTokensUsed": integer
  "totalTokensUsed": integer
  "originalFileSize": integer
  "translatedFileSize": integer
  "bilingualFileSize": integer
  "llmTranslationDuration": string // Total time spent on LLM API calls
  "llmTranslationDurationSeconds": number (double)
  "llmCallCount": integer // Number of LLM API calls made
  "avgLlmCallDuration": number (double) // Average time per LLM call in seconds
  "pdfParsingDuration": string // Time spent on PDF parsing and processing
  "pdfParsingDurationSeconds": number (double)
  "fileSavingDuration": string // Time spent on saving output files
  "fileSavingDurationSeconds": number (double)
  "startedAt": string (timestamp)
  "completedAt": string (timestamp)
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "chatbotFileId": "550e8400-e29b-41d4-a716-446655440000",
  "chatbotFileFilename": "レスポンス文字列",
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "largeLanguageModel": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "sourceLanguage": "レスポンス文字列",
  "targetLanguage": "レスポンス文字列",
  "customPrompt": "レスポンス文字列",
  "status": {},
  "errorMessage": "レスポンス文字列",
  "translatedFileUrl": "レスポンス文字列",
  "bilingualFileUrl": "レスポンス文字列",
  "processDuration": "レスポンス文字列",
  "processingDurationSeconds": 456,
  "pageCount": 456,
  "originalWordCount": 456,
  "translatedWordCount": 456,
  "inputTokensUsed": 456,
  "outputTokensUsed": 456,
  "totalTokensUsed": 456,
  "originalFileSize": 456,
  "translatedFileSize": 456,
  "bilingualFileSize": 456,
  "llmTranslationDuration": "レスポンス文字列",
  "llmTranslationDurationSeconds": 456,
  "llmCallCount": 456,
  "avgLlmCallDuration": 456,
  "pdfParsingDuration": "レスポンス文字列",
  "pdfParsingDurationSeconds": 456,
  "fileSavingDuration": "レスポンス文字列",
  "fileSavingDurationSeconds": 456,
  "startedAt": "レスポンス文字列",
  "completedAt": "レスポンス文字列",
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ナレッジベースのドキュメント一覧を取得 <a href="#knowledge-bases-documents-list" id="knowledge-bases-documents-list"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/documents/`

#### パラメーター

| パラメーター名               | 必須 | 型      | 説明                                                 |
| --------------------- | -- | ------ | -------------------------------------------------- |
| `knowledgeBasePk`     | ✅  | string |                                                    |
| `chatbotFileId`       | ❌  | string | 【廃止予定】ファイル ID（knowledge\_base\_file\_id を使用してください） |
| `knowledgeBaseFileId` | ❌  | string | ナレッジベースのファイル ID                                    |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/?chatbotFileId=example&knowledgeBaseFileId=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/?chatbotFileId=example&knowledgeBaseFileId=example", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/?chatbotFileId=example&knowledgeBaseFileId=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/?chatbotFileId=example&knowledgeBaseFileId=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
[
  {
    "id": string (uuid)
    "fileName": string
    "pageNumber"?: integer // 任意
    "chatbotFile": string (uuid)
    "excludedEmbedMetadataKeys"?: object // List[str]: metadata keys to exclude from the embedding. (任意)
    "excludedLlmMetadataKeys"?: object // List[str]: metadata keys to exclude from the LLM context. (任意)
    "llamaIndexObjectJson"?: object // 任意
    "metadata"?: object // 任意
    "text": string
    "updatedAt": string (timestamp)
  }
]
```

**レスポンス値の例**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "fileName": "レスポンス文字列",
    "pageNumber": 456,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": null,
    "excludedLlmMetadataKeys": null,
    "llamaIndexObjectJson": null,
    "metadata": null,
    "text": "レスポンス文字列",
    "updatedAt": "レスポンス文字列"
  }
]
```

**ステータスコード: 404 - ナレッジベースのファイルが存在しないか、現在の組織に属していません**

***

### ドキュメントを更新 <a href="#knowledge-bases-documents-update" id="knowledge-bases-documents-update"></a>

PUT `/api/v1/knowledge-bases/{knowledgeBasePk}/documents/{id}/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                               |
| ----------------- | -- | ------ | ------------------------------------------------ |
| `id`              | ✅  | string | A UUID string identifying this Chatbot Document. |
| `knowledgeBasePk` | ✅  | string |                                                  |

#### リクエスト内容

**リクエストパラメーター**

| フィールド                     | 型             | 必須  | 説明                                                         |
| ------------------------- | ------------- | --- | ---------------------------------------------------------- |
| fileName                  | string        | はい  |                                                            |
| pageNumber                | integer       | いいえ |                                                            |
| chatbotFile               | string (uuid) | はい  |                                                            |
| excludedEmbedMetadataKeys | object        | いいえ | List\[str]: metadata keys to exclude from the embedding.   |
| excludedLlmMetadataKeys   | object        | いいえ | List\[str]: metadata keys to exclude from the LLM context. |
| llamaIndexObjectJson      | object        | いいえ |                                                            |
| metadata                  | object        | いいえ |                                                            |
| text                      | string        | はい  |                                                            |

**リクエストスキーマの例**

```typescript
{
  "fileName": string
  "pageNumber"?: integer // 任意
  "chatbotFile": string (uuid)
  "excludedEmbedMetadataKeys"?: object // List[str]: metadata keys to exclude from the embedding. (任意)
  "excludedLlmMetadataKeys"?: object // List[str]: metadata keys to exclude from the LLM context. (任意)
  "llamaIndexObjectJson"?: object // 任意
  "metadata"?: object // 任意
  "text": string
}
```

**リクエスト値の例**

```json
{
  "fileName": "サンプル文字列",
  "pageNumber": 123,
  "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
  "excludedEmbedMetadataKeys": null,
  "excludedLlmMetadataKeys": null,
  "llamaIndexObjectJson": null,
  "metadata": null,
  "text": "これはサンプルメッセージです"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fileName": "サンプル文字列",
    "pageNumber": 123,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": null,
    "excludedLlmMetadataKeys": null,
    "llamaIndexObjectJson": null,
    "metadata": null,
    "text": "これはサンプルメッセージです"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {
    "fileName": "サンプル文字列",
    "pageNumber": 123,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": null,
    "excludedLlmMetadataKeys": null,
    "llamaIndexObjectJson": null,
    "metadata": null,
    "text": "これはサンプルメッセージです"
  };

axios.put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {
    "fileName": "サンプル文字列",
    "pageNumber": 123,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": None,
    "excludedLlmMetadataKeys": None,
    "llamaIndexObjectJson": None,
    "metadata": None,
    "text": "これはサンプルメッセージです"
}

response = requests.put(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'fileName' => 'サンプル文字列',
            'pageNumber' => 123,
            'chatbotFile' => '550e8400-e29b-41d4-a716-446655440000',
            'excludedEmbedMetadataKeys' => null,
            'excludedLlmMetadataKeys' => null,
            'llamaIndexObjectJson' => null,
            'metadata' => null,
            'text' => 'これはサンプルメッセージです'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "fileName": string
  "pageNumber"?: integer // 任意
  "chatbotFile": string (uuid)
  "excludedEmbedMetadataKeys"?: object // List[str]: metadata keys to exclude from the embedding. (任意)
  "excludedLlmMetadataKeys"?: object // List[str]: metadata keys to exclude from the LLM context. (任意)
  "llamaIndexObjectJson"?: object // 任意
  "metadata"?: object // 任意
  "text": string
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "fileName": "レスポンス文字列",
  "pageNumber": 456,
  "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
  "excludedEmbedMetadataKeys": null,
  "excludedLlmMetadataKeys": null,
  "llamaIndexObjectJson": null,
  "metadata": null,
  "text": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ドキュメントを部分更新 <a href="#knowledge-bases-documents-partial-update" id="knowledge-bases-documents-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/documents/{id}/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                               |
| ----------------- | -- | ------ | ------------------------------------------------ |
| `id`              | ✅  | string | A UUID string identifying this Chatbot Document. |
| `knowledgeBasePk` | ✅  | string |                                                  |

#### リクエスト内容

**リクエストパラメーター**

| フィールド                     | 型             | 必須  | 説明                                                         |
| ------------------------- | ------------- | --- | ---------------------------------------------------------- |
| fileName                  | string        | いいえ |                                                            |
| pageNumber                | integer       | いいえ |                                                            |
| chatbotFile               | string (uuid) | いいえ |                                                            |
| excludedEmbedMetadataKeys | object        | いいえ | List\[str]: metadata keys to exclude from the embedding.   |
| excludedLlmMetadataKeys   | object        | いいえ | List\[str]: metadata keys to exclude from the LLM context. |
| llamaIndexObjectJson      | object        | いいえ |                                                            |
| metadata                  | object        | いいえ |                                                            |
| text                      | string        | いいえ |                                                            |

**リクエストスキーマの例**

```typescript
{
  "fileName"?: string // 任意
  "pageNumber"?: integer // 任意
  "chatbotFile"?: string (uuid) // 任意
  "excludedEmbedMetadataKeys"?: object // List[str]: metadata keys to exclude from the embedding. (任意)
  "excludedLlmMetadataKeys"?: object // List[str]: metadata keys to exclude from the LLM context. (任意)
  "llamaIndexObjectJson"?: object // 任意
  "metadata"?: object // 任意
  "text"?: string // 任意
}
```

**リクエスト値の例**

```json
{
  "fileName": "サンプル文字列",
  "pageNumber": 123,
  "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
  "excludedEmbedMetadataKeys": null,
  "excludedLlmMetadataKeys": null,
  "llamaIndexObjectJson": null,
  "metadata": null,
  "text": "これはサンプルメッセージです"
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fileName": "サンプル文字列",
    "pageNumber": 123,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": null,
    "excludedLlmMetadataKeys": null,
    "llamaIndexObjectJson": null,
    "metadata": null,
    "text": "これはサンプルメッセージです"
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエスト内容 (payload)
const data = {
    "fileName": "サンプル文字列",
    "pageNumber": 123,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": null,
    "excludedLlmMetadataKeys": null,
    "llamaIndexObjectJson": null,
    "metadata": null,
    "text": "これはサンプルメッセージです"
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエスト内容 (payload)
data = {
    "fileName": "サンプル文字列",
    "pageNumber": 123,
    "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
    "excludedEmbedMetadataKeys": None,
    "excludedLlmMetadataKeys": None,
    "llamaIndexObjectJson": None,
    "metadata": None,
    "text": "これはサンプルメッセージです"
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'fileName' => 'サンプル文字列',
            'pageNumber' => 123,
            'chatbotFile' => '550e8400-e29b-41d4-a716-446655440000',
            'excludedEmbedMetadataKeys' => null,
            'excludedLlmMetadataKeys' => null,
            'llamaIndexObjectJson' => null,
            'metadata' => null,
            'text' => 'これはサンプルメッセージです'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "fileName": string
  "pageNumber"?: integer // 任意
  "chatbotFile": string (uuid)
  "excludedEmbedMetadataKeys"?: object // List[str]: metadata keys to exclude from the embedding. (任意)
  "excludedLlmMetadataKeys"?: object // List[str]: metadata keys to exclude from the LLM context. (任意)
  "llamaIndexObjectJson"?: object // 任意
  "metadata"?: object // 任意
  "text": string
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "fileName": "レスポンス文字列",
  "pageNumber": 456,
  "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
  "excludedEmbedMetadataKeys": null,
  "excludedLlmMetadataKeys": null,
  "llamaIndexObjectJson": null,
  "metadata": null,
  "text": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### ドキュメントを削除 <a href="#knowledge-bases-documents-destroy" id="knowledge-bases-documents-destroy"></a>

DELETE `/api/v1/knowledge-bases/{knowledgeBasePk}/documents/{id}/`

#### パラメーター

| パラメーター名           | 必須 | 型      | 説明                                               |
| ----------------- | -- | ------ | ------------------------------------------------ |
| `id`              | ✅  | string | A UUID string identifying this Chatbot Document. |
| `knowledgeBasePk` | ✅  | string |                                                  |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエスト内容 (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/documents/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### 新しい FAQ を作成 <a href="#knowledge-bases-faqs-create" id="knowledge-bases-faqs-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明 |
| ----------------- | -- | ------ | -- |
| `knowledgeBasePk` | ✅  | string |    |

#### リクエストボディ

**リクエストパラメータ**

| フィールド                 | 型              | 必須  | 説明                                                             |
| --------------------- | -------------- | --- | -------------------------------------------------------------- |
| question              | string         | はい  |                                                                |
| answer                | string         | はい  |                                                                |
| answerMediaUrls       | object         | いいえ | URLs of media files, such as images and videos, in the answer. |
| labels                | array\[IdName] | いいえ |                                                                |
| rawUserDefineMetadata | object         | いいえ |                                                                |

**リクエストスキーマの例**

```typescript
{
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
}
```

**リクエストの値の例**

```json
{
  "question": "サンプル文字列",
  "answer": "サンプル文字列",
  "answerMediaUrls": null,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": null,
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": null,
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": None,
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'question' => 'サンプル文字列',
            'answer' => 'サンプル文字列',
            'answerMediaUrls' => null,
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 201**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "hitsCount": integer
  "embeddingTokensCount": integer // Number of embedding tokens used to create this FAQ.
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "knowledgeBase":  // Always taken from the knowledge base in the URL; a value in the request body is ignored.
  {
    "id": string (uuid)
    "name": string
  }
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "question": "レスポンス文字列",
  "answer": "レスポンス文字列",
  "answerMediaUrls": null,
  "hitsCount": 456,
  "embeddingTokensCount": 456,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  }
}
```

***

### FAQ のメタデータを更新 <a href="#knowledge-bases-faqs-update-metadata-partial-update" id="knowledge-bases-faqs-update-metadata-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/{id}/update-metadata/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                  |
| ----------------- | -- | ------ | ----------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this FAQ. |
| `knowledgeBasePk` | ✅  | string |                                     |

#### リクエストボディ

**リクエストパラメータ**

| フィールド                 | 型              | 必須  | 説明 |
| --------------------- | -------------- | --- | -- |
| labels                | array\[IdName] | いいえ |    |
| rawUserDefineMetadata | object         | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
}
```

**リクエストの値の例**

```json
{
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/update-metadata/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/update-metadata/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/update-metadata/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/update-metadata/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "hitsCount": integer
  "embeddingTokensCount": integer // Number of embedding tokens used to create this FAQ.
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "knowledgeBase":  // Always taken from the knowledge base in the URL; a value in the request body is ignored.
  {
    "id": string (uuid)
    "name": string
  }
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "question": "レスポンス文字列",
  "answer": "レスポンス文字列",
  "answerMediaUrls": null,
  "hitsCount": 456,
  "embeddingTokensCount": 456,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  }
}
```

***

### FAQ を一括削除 <a href="#knowledge-bases-faqs-batch-delete-create" id="knowledge-bases-faqs-batch-delete-create"></a>

POST `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/batch-delete/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明 |
| ----------------- | -- | ------ | -- |
| `knowledgeBasePk` | ✅  | string |    |

#### リクエストボディ

**リクエストパラメータ**

| フィールド | 型              | 必須  | 説明 |
| ----- | -------------- | --- | -- |
| ids   | array\[string] | いいえ |    |

**リクエストスキーマの例**

```typescript
{
  "ids"?: [ // 任意
    string (uuid)
  ]
}
```

**リクエストの値の例**

```json
{
  "ids": [
    "550e8400-e29b-41d4-a716-446655440000"
  ]
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/batch-delete/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "ids": [
      "550e8400-e29b-41d4-a716-446655440000"
    ]
  };

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/batch-delete/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/batch-delete/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "ids": [
        "550e8400-e29b-41d4-a716-446655440000"
    ]
}

response = requests.post(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/batch-delete/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'ids' => [
                '550e8400-e29b-41d4-a716-446655440000'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### 指定したナレッジベースのすべての FAQ を一覧表示 <a href="#knowledge-bases-faqs-list" id="knowledge-bases-faqs-list"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/`

#### パラメータ

| パラメータ名            | 必須 | 型       | 説明                                                                       |
| ----------------- | -- | ------- | ------------------------------------------------------------------------ |
| `knowledgeBasePk` | ✅  | string  |                                                                          |
| `page`            | ❌  | integer | A page number within the paginated result set.                           |
| `pageSize`        | ❌  | integer | Number of results to return per page.                                    |
| `query`           | ❌  | string  | 検索キーワードです。スペースで区切った複数条件の検索に対応しています。検索対象：FAQ ID、質問、回答、ラベル名、Metadata value |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/?page=1&pageSize=1&query=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/?page=1&pageSize=1&query=example", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/?page=1&pageSize=1&query=example"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/?page=1&pageSize=1&query=example", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "question": string
      "answer": string
      "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
      "hitsCount": integer
      "embeddingTokensCount": integer // Number of embedding tokens used to create this FAQ.
      "labels"?: [ // 任意
        {
          "id": string (uuid)
          "name": string
        }
      ]
      "rawUserDefineMetadata"?: object // 任意
      "knowledgeBase":  // Always taken from the knowledge base in the URL; a value in the request body is ignored.
      {
        "id": string (uuid)
        "name": string
      }
    }
  ]
}
```

**レスポンスの値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "question": "レスポンス文字列",
      "answer": "レスポンス文字列",
      "answerMediaUrls": null,
      "hitsCount": 456,
      "embeddingTokensCount": 456,
      "labels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "レスポンス文字列"
        }
      ],
      "rawUserDefineMetadata": null,
      "knowledgeBase": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "レスポンス文字列"
      }
    }
  ]
}
```

***

### 指定した FAQ の詳細を取得 <a href="#knowledge-bases-faqs-retrieve" id="knowledge-bases-faqs-retrieve"></a>

GET `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                  |
| ----------------- | -- | ------ | ----------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this FAQ. |
| `knowledgeBasePk` | ✅  | string |                                     |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "hitsCount": integer
  "embeddingTokensCount": integer // Number of embedding tokens used to create this FAQ.
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "knowledgeBase":  // Always taken from the knowledge base in the URL; a value in the request body is ignored.
  {
    "id": string (uuid)
    "name": string
  }
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "question": "レスポンス文字列",
  "answer": "レスポンス文字列",
  "answerMediaUrls": null,
  "hitsCount": 456,
  "embeddingTokensCount": 456,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  }
}
```

***

### FAQ を更新 <a href="#knowledge-bases-faqs-update" id="knowledge-bases-faqs-update"></a>

PUT `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                  |
| ----------------- | -- | ------ | ----------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this FAQ. |
| `knowledgeBasePk` | ✅  | string |                                     |

#### リクエストボディ

**リクエストパラメータ**

| フィールド                 | 型              | 必須  | 説明                                                             |
| --------------------- | -------------- | --- | -------------------------------------------------------------- |
| question              | string         | はい  |                                                                |
| answer                | string         | はい  |                                                                |
| answerMediaUrls       | object         | いいえ | URLs of media files, such as images and videos, in the answer. |
| labels                | array\[IdName] | いいえ |                                                                |
| rawUserDefineMetadata | object         | いいえ |                                                                |

**リクエストスキーマの例**

```typescript
{
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
}
```

**リクエスト値の例**

```json
{
  "question": "サンプル文字列",
  "answer": "サンプル文字列",
  "answerMediaUrls": null,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PUT "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": null,
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": null,
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  };

axios.put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": None,
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None
}

response = requests.put(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->put("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'question' => 'サンプル文字列',
            'answer' => 'サンプル文字列',
            'answerMediaUrls' => null,
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "hitsCount": integer
  "embeddingTokensCount": integer // Number of embedding tokens used to create this FAQ.
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "knowledgeBase":  // Always taken from the knowledge base in the URL; a value in the request body is ignored.
  {
    "id": string (uuid)
    "name": string
  }
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "question": "レスポンス文字列",
  "answer": "レスポンス文字列",
  "answerMediaUrls": null,
  "hitsCount": 456,
  "embeddingTokensCount": 456,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  }
}
```

***

### FAQ を部分更新 <a href="#knowledge-bases-faqs-partial-update" id="knowledge-bases-faqs-partial-update"></a>

PATCH `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                  |
| ----------------- | -- | ------ | ----------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this FAQ. |
| `knowledgeBasePk` | ✅  | string |                                     |

#### リクエストボディ

**リクエストパラメータ**

| フィールド                 | 型              | 必須  | 説明                                                             |
| --------------------- | -------------- | --- | -------------------------------------------------------------- |
| question              | string         | いいえ |                                                                |
| answer                | string         | いいえ |                                                                |
| answerMediaUrls       | object         | いいえ | URLs of media files, such as images and videos, in the answer. |
| labels                | array\[IdName] | いいえ |                                                                |
| rawUserDefineMetadata | object         | いいえ |                                                                |

**リクエストスキーマの例**

```typescript
{
  "question"?: string // 任意
  "answer"?: string // 任意
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "labels"?: [ // 任意
    {
      "id": string (uuid)
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
}
```

**リクエスト値の例**

```json
{
  "question": "サンプル文字列",
  "answer": "サンプル文字列",
  "answerMediaUrls": null,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "rawUserDefineMetadata": null
}
```

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": null,
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  }'

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
};

// リクエストボディ (payload)
const data = {
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": null,
    "labels": [
      {
        "id": "550e8400-e29b-41d4-a716-446655440000"
      }
    ],
    "rawUserDefineMetadata": null
  };

axios.patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY",
    "Content-Type": "application/json"
}

# リクエストボディ (payload)
data = {
    "question": "サンプル文字列",
    "answer": "サンプル文字列",
    "answerMediaUrls": None,
    "labels": [
        {
            "id": "550e8400-e29b-41d4-a716-446655440000"
        }
    ],
    "rawUserDefineMetadata": None
}

response = requests.patch(url, json=data, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->patch("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY',
            'Content-Type' => 'application/json'
        ],
        'json' => [
            'question' => 'サンプル文字列',
            'answer' => 'サンプル文字列',
            'answerMediaUrls' => null,
            'labels' => [
                [
                    'id' => '550e8400-e29b-41d4-a716-446655440000'
                ]
            ],
            'rawUserDefineMetadata' => null
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "question": string
  "answer": string
  "answerMediaUrls"?: object // URLs of media files, such as images and videos, in the answer. (任意)
  "hitsCount": integer
  "embeddingTokensCount": integer // Number of embedding tokens used to create this FAQ.
  "labels"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "rawUserDefineMetadata"?: object // 任意
  "knowledgeBase":  // Always taken from the knowledge base in the URL; a value in the request body is ignored.
  {
    "id": string (uuid)
    "name": string
  }
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "question": "レスポンス文字列",
  "answer": "レスポンス文字列",
  "answerMediaUrls": null,
  "hitsCount": 456,
  "embeddingTokensCount": 456,
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "rawUserDefineMetadata": null,
  "knowledgeBase": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  }
}
```

***

### FAQ を削除 <a href="#knowledge-bases-faqs-destroy" id="knowledge-bases-faqs-destroy"></a>

DELETE `/api/v1/knowledge-bases/{knowledgeBasePk}/faqs/{id}/`

#### パラメータ

| パラメータ名            | 必須 | 型      | 説明                                  |
| ----------------- | -- | ------ | ----------------------------------- |
| `id`              | ✅  | string | A UUID string identifying this FAQ. |
| `knowledgeBasePk` | ✅  | string |                                     |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X DELETE "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

// リクエストボディ (payload)
const data = null;

axios.delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", data, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.delete(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->delete("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faqs/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

| ステータスコード | 説明               |
| -------- | ---------------- |
| 204      | No response body |

***

### FAQ の Excel ファイル（または空のテンプレート）をエクスポート <a href="#knowledge-bases-export-faq-excel-retrieve" id="knowledge-bases-export-faq-excel-retrieve"></a>

GET `/api/v1/knowledge-bases/{id}/export-faq-excel/`

#### パラメータ

| パラメータ名 | 必須 | 型      | 説明                                             |
| ------ | -- | ------ | ---------------------------------------------- |
| `id`   | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出しの例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-faq-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-faq-excel/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-faq-excel/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/export-faq-excel/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンスボディ

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "createdBy": 
  {
    "id": string (uuid)
    "name": string
  }
  "organization"?: string (uuid) // 任意
  "embeddingModel": string (uuid)
  "rerankerModel": string (uuid)
  "name": string
  "description"?: string // 任意
  "numberOfRetrievedChunks"?: integer // 取得する参考チャンク数です。デフォルトは 12、最小値は 1 です (任意)
  "enableHyde"?: boolean // HyDE を有効にします。デフォルトは False です (任意)
  "similarityCutoff"?: number (double) // 類似度のしきい値です。デフォルトは 0.0、範囲は 0.0-1.0 です (任意)
  "enableRerank"?: boolean // 再ランキングを有効にするかどうかを指定します。デフォルトは True です (任意)
  "enableRrf"?: boolean // Enable Reciprocal Rank Fusion for hybrid search. Disable this if using a custom Elasticsearch without enterprise license. (任意)
  "vectorDatabaseType"?:  // Type of vector database: elasticsearch or opensearch.

* `elasticsearch` - Elasticsearch
* `opensearch` - OpenSearch
* `oracle` - Oracle AI Database 26ai
* `synxdb` - SynxDB (任意)
  {
  }
  "vectorDatabaseUrl"?: string // Custom vector database endpoint URL or Oracle DSN. For Elasticsearch/OpenSearch: URL format (e.g., "https://host:9200"). For Oracle: DSN format (e.g., "host:1521/service_name"). (任意)
  "vectorDatabaseApiKey"?: string // API Key for Elasticsearch. Not used for OpenSearch. (任意)
  "opensearchUsername"?: string // Username for OpenSearch Basic Auth. (任意)
  "opensearchPassword"?: string // Password for OpenSearch Basic Auth. (任意)
  "oracleUser"?: string // Oracle database username. (任意)
  "oraclePassword"?: string // Oracle database password. (任意)
  "synxdbUser"?: string // SynxDB database username. (任意)
  "synxdbPassword"?: string // SynxDB database password. (任意)
  "labels": [
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "chatbots"?: [ // 任意
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "groups"?: [ // ナレッジベースにアクセスできるグループの一覧です (任意)
    {
      "id": string (uuid)
      "name": string
    }
  ]
  "filesCount": integer // Return count of KnowledgeBaseFile excluding processed files, conversation attachments, and soft-deleted.
  "vectorStorageSize": integer
  "chunksCount": integer
  "canUpdate": boolean // Return whether the current user can update this resource.
  "canDelete": boolean // Return whether the current user can delete this resource.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "createdBy": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列"
  },
  "organization": "550e8400-e29b-41d4-a716-446655440000",
  "embeddingModel": "550e8400-e29b-41d4-a716-446655440000",
  "rerankerModel": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "numberOfRetrievedChunks": 456,
  "enableHyde": false,
  "similarityCutoff": 456,
  "enableRerank": false,
  "enableRrf": false,
  "vectorDatabaseType": {},
  "vectorDatabaseUrl": "レスポンス文字列",
  "vectorDatabaseApiKey": "レスポンス文字列",
  "opensearchUsername": "レスポンス文字列",
  "opensearchPassword": "レスポンス文字列",
  "oracleUser": "レスポンス文字列",
  "oraclePassword": "レスポンス文字列",
  "synxdbUser": "レスポンス文字列",
  "synxdbPassword": "レスポンス文字列",
  "labels": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "chatbots": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "groups": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス文字列"
    }
  ],
  "filesCount": 456,
  "vectorStorageSize": 456,
  "chunksCount": 456,
  "canUpdate": false,
  "canDelete": false,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### FAQ Excel のインポート（非同期） <a href="#knowledge-bases-import-faq-excel-create" id="knowledge-bases-import-faq-excel-create"></a>

POST `/api/v1/knowledge-bases/{id}/import-faq-excel/`

{% hint style="info" %}
同じナレッジベースで同時に実行できるインポートジョブは1つだけです。ジョブの実行中に再度呼び出すと `409` が返されます。進行状況は、下記の「FAQ インポートジョブ」エンドポイントで確認してください。
{% endhint %}

#### パラメーター

| パラメーター名 | 必須 | 型      | 説明                                             |
| ------- | -- | ------ | ---------------------------------------------- |
| `id`    | ✅  | string | A UUID string identifying this Knowledge Base. |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-faq-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY" \
  -F "excelFile=@example_file.txt"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');
const FormData = require('form-data');

// FormData オブジェクトを作成します
const formData = new FormData();
// 実際のファイルに置き換えてください
formData.append('excelFile', /* 実際のファイルオブジェクト */, 'example_file.txt');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY',
    ...formData.getHeaders()
  }
};

axios.post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-faq-excel/", formData, config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-faq-excel/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}

# ファイルとフォームデータを作成します
files = {
    'excelFile': ('example_file.txt', open('example_file.txt', 'rb'), 'text/plain')
}

response = requests.post(url, files=files, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->post("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/import-faq-excel/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ],
        'multipart' => [
            [
                'name' => 'excelFile',
                'contents' => fopen('example_file.txt', 'r'),
                'filename' => 'example_file.txt'
            ]
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 202**

**レスポンススキーマの例**

```typescript
{
  "jobId": string (uuid)
  "status": string (enum: pending, processing, done, failed) // * `pending` - Pending
* `processing` - Processing
* `done` - Done
* `failed` - Failed
}
```

**レスポンスの値の例**

```json
{
  "jobId": "550e8400-e29b-41d4-a716-446655440000",
  "status": "pending"
}
```

**ステータスコード: 409**

**レスポンススキーマの例**

```typescript
{
  "detail": string
  "jobId": string (uuid)
}
```

**レスポンスの値の例**

```json
{
  "detail": "レスポンス文字列",
  "jobId": "550e8400-e29b-41d4-a716-446655440000"
}
```

***

### FAQ インポートジョブの一覧を取得 <a href="#knowledge-bases-faq-import-jobs-list" id="knowledge-bases-faq-import-jobs-list"></a>

GET `/api/v1/knowledge-bases/{id}/faq-import-jobs/`

#### パラメータ

| パラメータ名           | 必須 | 型       | 説明                                                                     |
| ---------------- | -- | ------- | ---------------------------------------------------------------------- |
| `id`             | ✅  | string  | A UUID string identifying this Knowledge Base.                         |
| `embeddingModel` | ❌  | string  |                                                                        |
| `page`           | ❌  | integer | A page number within the paginated result set.                         |
| `pageSize`       | ❌  | integer | Number of results to return per page.                                  |
| `pagination`     | ❌  | boolean | Set to false to return all jobs without pagination (defaults to true). |
| `query`          | ❌  | string  |                                                                        |
| `rerankerModel`  | ❌  | string  |                                                                        |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&pagination=true&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&pagination=true&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&pagination=true&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/?embeddingModel=550e8400-e29b-41d4-a716-446655440000&page=1&pageSize=1&pagination=true&query=example&rerankerModel=550e8400-e29b-41d4-a716-446655440000", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "count": integer
  "next"?: string (uri) // 任意
  "previous"?: string (uri) // 任意
  "results": [
    {
      "id": string (uuid)
      "status": 
      {
      }
      "totalRows": integer
      "processedRows": integer
      "createdCount": integer
      "skippedDuplicateCount": integer // Rows skipped because their whitespace-normalized question already exists in the knowledge base or appears earlier in the same file.
      "errors": object // Row-level parse errors and chunk-level import errors.
      "createdAt": string (timestamp)
      "updatedAt": string (timestamp)
    }
  ]
}
```

**レスポンス値の例**

```json
{
  "count": 123,
  "next": "http://api.example.org/accounts/?page=4",
  "previous": "http://api.example.org/accounts/?page=2",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "status": {},
      "totalRows": 456,
      "processedRows": 456,
      "createdCount": 456,
      "skippedDuplicateCount": 456,
      "errors": null,
      "createdAt": "レスポンス文字列",
      "updatedAt": "レスポンス文字列"
    }
  ]
}
```

***

### 特定の FAQ インポートジョブを取得 <a href="#knowledge-bases-faq-import-jobs-retrieve" id="knowledge-bases-faq-import-jobs-retrieve"></a>

GET `/api/v1/knowledge-bases/{id}/faq-import-jobs/{jobId}/`

#### パラメータ

| パラメータ名  | 必須 | 型      | 説明                                             |
| ------- | -- | ------ | ---------------------------------------------- |
| `id`    | ✅  | string | A UUID string identifying this Knowledge Base. |
| `jobId` | ✅  | string |                                                |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/{jobId}/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/{jobId}/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/{jobId}/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/knowledge-bases/550e8400-e29b-41d4-a716-446655440000/faq-import-jobs/{jobId}/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "status": 
  {
  }
  "totalRows": integer
  "processedRows": integer
  "createdCount": integer
  "skippedDuplicateCount": integer // Rows skipped because their whitespace-normalized question already exists in the knowledge base or appears earlier in the same file.
  "errors": object // Row-level parse errors and chunk-level import errors.
  "createdAt": string (timestamp)
  "updatedAt": string (timestamp)
}
```

**レスポンス値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "status": {},
  "totalRows": 456,
  "processedRows": 456,
  "createdCount": 456,
  "skippedDuplicateCount": 456,
  "errors": null,
  "createdAt": "レスポンス文字列",
  "updatedAt": "レスポンス文字列"
}
```

***

### パーサー一覧を取得 <a href="#parsers-list" id="parsers-list"></a>

GET `/api/v1/parsers/`

{% hint style="info" %}
ナレッジベースにファイルをアップロードする際は、このエンドポイントで取得したパーサーの `id` を `parser` フィールドに指定してください。
{% endhint %}

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/parsers/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/parsers/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/parsers/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/parsers/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
[
  {
    "id": string (uuid)
    "name": string
    "description": string
    "provider": 
    {
    }
    "order"?: integer // 任意
    "isTimestampSttProvider": boolean
    "asrProvider": object // The provider spec, built once per provider row per response.

The spec is platform-level, not per parser, and it is large — a
whisper-family row carries a 100-entry language catalog in its
``languages`` spec, as codes plus display names. This serializer is
nested per row in the knowledge-base file listing and in message
citations, so without memoizing, one response rebuilds the same
catalog for every row. ``self.context`` is the root serializer's shared
dict, which is also what keeps ``get_active_diarization_rows`` at one
query per response.
  }
]
```

**レスポンスの値の例**

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス文字列",
    "description": "レスポンス文字列",
    "provider": {},
    "order": 456,
    "isTimestampSttProvider": false,
    "asrProvider": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "レスポンス名の例",
      "description": "レスポンスの説明の例"
    }
  }
]
```

***

### 特定のパーサーを取得 <a href="#parsers-retrieve" id="parsers-retrieve"></a>

GET `/api/v1/parsers/{id}/`

#### パラメーター

| パラメーター名 | 必須 | 型      | 説明                      |
| ------- | -- | ------ | ----------------------- |
| `id`    | ✅  | string | このパーサーを識別する UUID 文字列です。 |

#### コード例

{% tabs %}
{% tab title="Shell/Bash" %}

```bash
# API 呼び出し例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/parsers/550e8400-e29b-41d4-a716-446655440000/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 実行前に YOUR_API_KEY を置き換え、リクエストデータを確認してください。
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const axios = require('axios');

// リクエストヘッダーを設定します
const config = {
  headers: {
    'Authorization': 'Api-Key YOUR_API_KEY'
  }
};

axios.get("https://api.maiagent.ai/api/v1/parsers/550e8400-e29b-41d4-a716-446655440000/", config)
  .then(response => {
    console.log('レスポンスを正常に取得しました:');
    console.log(response.data);
  })
  .catch(error => {
    console.error('リクエストでエラーが発生しました:');
    console.error(error.response?.data || error.message);
  });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.maiagent.ai/api/v1/parsers/550e8400-e29b-41d4-a716-446655440000/"
headers = {
    "Authorization": "Api-Key YOUR_API_KEY"
}


response = requests.get(url, headers=headers)
try:
    print("レスポンスを正常に取得しました:")
    print(response.json())
except Exception as e:
    print("リクエストでエラーが発生しました:", e)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();

try {
    $response = $client->get("https://api.maiagent.ai/api/v1/parsers/550e8400-e29b-41d4-a716-446655440000/", [
        'headers' => [
            'Authorization' => 'Api-Key YOUR_API_KEY'
        ]
    ]);
    
    $data = json_decode($response->getBody(), true);
    echo "レスポンスを正常に取得しました:\n";
    print_r($data);
} catch (Exception $e) {
    echo 'リクエストでエラーが発生しました: ' . $e->getMessage();
}
?>
```

{% endtab %}
{% endtabs %}

#### レスポンス内容

**ステータスコード: 200**

**レスポンススキーマの例**

```typescript
{
  "id": string (uuid)
  "name": string
  "description": string
  "provider": 
  {
  }
  "order"?: integer // 任意
  "isTimestampSttProvider": boolean
  "asrProvider": object // The provider spec, built once per provider row per response.

The spec is platform-level, not per parser, and it is large — a
whisper-family row carries a 100-entry language catalog in its
``languages`` spec, as codes plus display names. This serializer is
nested per row in the knowledge-base file listing and in message
citations, so without memoizing, one response rebuilds the same
catalog for every row. ``self.context`` is the root serializer's shared
dict, which is also what keeps ``get_active_diarization_rows`` at one
query per response.
}
```

**レスポンスの値の例**

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "レスポンス文字列",
  "description": "レスポンス文字列",
  "provider": {},
  "order": 456,
  "isTimestampSttProvider": false,
  "asrProvider": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "レスポンス名の例",
    "description": "レスポンスの説明の例"
  }
}
```

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/api/ja/api-reference/zhi-shi-ku-xin-ban.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
