---
title: "Knowledge API"
description: "ファイル、キーワード、またはリンクを通じてあなたのマインドに知識を追加します。"
---

# Knowledge API

この API は Minds 内のマインド知識を管理します。

**ファイル**、**キーワード**、または**リンク**の3つの方法でマインドに知識を追加します。知識は処理され、埋め込まれ、会話中に自動的に取得されます。

**注意:** リスト、追加、削除はv1 APIを通じて利用可能です。キーワード検索による知識の強化も同じ追加エンドポイントを通じてサポートされています。

---

## 知識アイテムのリスト

マインドのすべての知識アイテムを取得します。

**エンドポイント:** `GET /api/v1/minds/{mindId}/knowledge`

**ヘッダー:**

```text
Authorization: Bearer minds_your_api_key
```

**例:**

```bash
curl -X GET "https://getminds.ai/api/v1/minds/{mindId}/knowledge" \
  -H "Authorization: Bearer minds_your_api_key"
```

**レスポンス:**

```json
{
  "success": true,
  "data": {
    "items": [
      {
        "id": "660e8400-e29b-41d4-a716-446655440001",
        "description": "Company Employee Handbook 2025",
        "link": null,
        "filePath": "portfolio/user-id/1234567890_handbook.pdf",
        "isWatched": false,
        "createdAt": "2025-12-10T12:00:00.000Z",
        "updatedAt": "2025-12-10T12:00:00.000Z"
      }
    ],
    "total": 1
  }
}
```

<table>
<thead>
  <tr>
    <th>
      フィールド
    </th>
    
    <th>
      タイプ
    </th>
    
    <th>
      説明
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        data.items
      </code>
    </td>
    
    <td>
      array
    </td>
    
    <td>
      知識アイテムオブジェクトの配列
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        data.total
      </code>
    </td>
    
    <td>
      number
    </td>
    
    <td>
      このマインドの知識アイテムの総数
    </td>
  </tr>
</tbody>
</table>

---

## ファイルアップロード

ドキュメントや画像をマインドに直接アップロードします。

**エンドポイント:** `POST /api/v1/minds/{mindId}/knowledge`

**Content-Type:** `multipart/form-data`

<table>
<thead>
  <tr>
    <th>
      フィールド
    </th>
    
    <th>
      タイプ
    </th>
    
    <th>
      必須
    </th>
    
    <th>
      説明
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        file
      </code>
    </td>
    
    <td>
      file
    </td>
    
    <td>
      はい
    </td>
    
    <td>
      アップロードするファイル (最大50MB)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        description
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      はい
    </td>
    
    <td>
      コンテンツの説明
    </td>
  </tr>
</tbody>
</table>

**サポートされているフォーマット:**

- ドキュメント: PDF, DOCX, DOC, TXT, MD, RTF, CSV, JSON, XML
- 画像: JPG, JPEG, PNG, GIF, WEBP

**例:**

```bash
curl -X POST "https://getminds.ai/api/v1/minds/{mindId}/knowledge" \
  -H "Authorization: Bearer minds_your_api_key" \
  -F "file=@./handbook.pdf" \
  -F "description=Company Employee Handbook 2025"
```

**レスポンス:** `201 Created`

```json
{
  "success": true,
  "data": {
    "id": "660e8400-e29b-41d4-a716-446655440001",
    "description": "Company Employee Handbook 2025",
    "filePath": "portfolio/user-id/1234567890_handbook.pdf",
    "createdAt": "2025-12-10T12:00:00.000Z"
  }
}
```

---

## キーワード検索

ウェブでキーワードを検索して知識を追加します。ExaとYouTubeを検索し、コンテンツを抽出してマインドの知識ベースに追加します。

**エンドポイント:** `POST /api/v1/minds/{mindId}/knowledge`

**Content-Type:** `application/json`

`keywords` 配列を含むJSONボディを送信して、ウェブ検索の強化をトリガーします（`link`/`file`の代わりに）。

<table>
<thead>
  <tr>
    <th>
      パラメータ
    </th>
    
    <th>
      タイプ
    </th>
    
    <th>
      必須
    </th>
    
    <th>
      説明
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        keywords
      </code>
    </td>
    
    <td>
      string<span>
        
      </span>
    </td>
    
    <td>
      はい
    </td>
    
    <td>
      検索するキーワード (最大35)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        regeneratePrompt
      </code>
    </td>
    
    <td>
      boolean
    </td>
    
    <td>
      いいえ
    </td>
    
    <td>
      システムプロンプトを再生成するか (デフォルト: true)
    </td>
  </tr>
</tbody>
</table>

**例:**

```bash
curl -X POST "https://getminds.ai/api/v1/minds/{mindId}/knowledge" \
  -H "Authorization: Bearer minds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"keywords": ["solar panel efficiency", "photovoltaic trends"]}'
```

**レスポンス:** `202 Accepted`

```json
{
  "success": true,
  "data": {
    "sparkId": "660e8400-e29b-41d4-a716-446655440000",
    "keywords": ["solar panel efficiency", "photovoltaic trends"],
    "queued": true,
    "regeneratePrompt": true,
    "message": "Knowledge enrichment queued with 2 keyword(s)."
  }
}
```

**注意:** これは非同期です。処理はバックグラウンドで実行され、数分かかる場合があります。

---

## リンク

URLから知識を追加します。ウェブページ、YouTube動画、研究論文をサポートします。

**エンドポイント:** `POST /api/v1/minds/{mindId}/knowledge`

**Content-Type:** `application/json`

<table>
<thead>
  <tr>
    <th>
      パラメータ
    </th>
    
    <th>
      タイプ
    </th>
    
    <th>
      必須
    </th>
    
    <th>
      説明
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        link
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      はい
    </td>
    
    <td>
      ウェブコンテンツのURL
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        description
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      はい
    </td>
    
    <td>
      コンテンツの説明
    </td>
  </tr>
</tbody>
</table>

**例:**

```bash
curl -X POST "https://getminds.ai/api/v1/minds/{mindId}/knowledge" \
  -H "Authorization: Bearer minds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"link": "https://example.com/article", "description": "Industry trends article"}'
```

**レスポンス:** `201 Created`

```json
{
  "success": true,
  "data": {
    "id": "660e8400-e29b-41d4-a716-446655440001",
    "link": "https://example.com/article",
    "description": "Industry trends article",
    "createdAt": "2025-12-10T12:00:00.000Z"
  }
}
```

**サポートされているリンクタイプ:**

- ウェブページ (スクレイピングによるコンテンツ抽出)
- YouTube動画 (自動的に抽出されたトランスクリプト)
- 研究論文 (arxivなど)

---

## ウォッチ (自動更新)

リンクベースの知識アイテムは「ウォッチ」され、自動的にコンテンツの更新を週単位でチェックできます。変更が検出されると、知識が再処理され、再埋め込まれます。

ウォッチは製品UIを通じて管理されます。ウォッチの状態はAPIを通じて知識アイテムをリストする際に表示されます（`isWatched`フィールド）。

**注意:** ウォッチはリンクベースの知識にのみ利用可能で、ファイルやキーワード検索には利用できません。

---

## 知識アイテムの更新

既存の知識アイテムの説明を更新します。

**エンドポイント:** `PUT /api/v1/minds/{mindId}/knowledge/{itemId}`

**ヘッダー:**

```text
Authorization: Bearer minds_your_api_key
Content-Type: application/json
```

**リクエストボディ:**

```json
{
  "description": "Updated description for this knowledge item"
}
```

<table>
<thead>
  <tr>
    <th>
      パラメータ
    </th>
    
    <th>
      タイプ
    </th>
    
    <th>
      必須
    </th>
    
    <th>
      説明
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        description
      </code>
    </td>
    
    <td>
      string
    </td>
    
    <td>
      はい
    </td>
    
    <td>
      更新された説明 (空であってはいけません)
    </td>
  </tr>
</tbody>
</table>

**例:**

```bash
curl -X PUT "https://getminds.ai/api/v1/minds/{mindId}/knowledge/{itemId}" \
  -H "Authorization: Bearer minds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"description": "Updated handbook description"}'
```

**レスポンス:**

```json
{
  "success": true,
  "data": {
    "id": "660e8400-e29b-41d4-a716-446655440001",
    "description": "Updated handbook description",
    "link": null,
    "filePath": "portfolio/user-id/1234567890_handbook.pdf",
    "isWatched": false,
    "createdAt": "2025-12-10T12:00:00.000Z",
    "updatedAt": "2025-12-15T08:30:00.000Z"
  }
}
```

### エラー応答

**400 Bad Request** - 更新する有効なフィールドがないか、説明が空です

**401 Unauthorized** - 無効または欠落したAPIキー

**404 Not Found** - 知識アイテムまたはマインドが見つかりません

---

## キーワードによる強化 (便利)

キーワードベースの知識強化の便利なエイリアスです。

**エンドポイント:** `POST /api/v1/minds/{mindId}/knowledge/enrich`

これは`POST /api/v1/minds/{mindId}/knowledge`と同等で、`keywords`ボディを持ちます。詳細は[キーワード検索](#keyword-search)を参照してください。

**例:**

```bash
curl -X POST "https://getminds.ai/api/v1/minds/{mindId}/knowledge/enrich" \
  -H "Authorization: Bearer minds_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"keywords": ["solar panel efficiency", "photovoltaic trends"]}'
```

---

## 知識アイテムの削除

知識アイテムとすべての関連データ（埋め込み、パターン、ファイル）を永久に削除します。

**エンドポイント:** `DELETE /api/v1/minds/{mindId}/knowledge/{itemId}`

**ヘッダー:**

```text
Authorization: Bearer minds_your_api_key
```

**例:**

```bash
curl -X DELETE "https://getminds.ai/api/v1/minds/{mindId}/knowledge/{itemId}" \
  -H "Authorization: Bearer minds_your_api_key"
```

**レスポンス:** `204 No Content` (成功時は空のボディ)

### 削除されるもの

- 知識アイテムのレコード
- すべての関連ベクトル埋め込み
- すべての関連パターン
- ストレージからのアップロードされたファイル（ファイルベースの場合）

**警告:** この操作は元に戻せません。

---

## 処理の流れ

1. **アップロード** - コンテンツが保存され、APIが成功を返します
2. **抽出** - バックグラウンド処理がテキストを抽出します（スクレイピング、トランスクリプト、OCR、ビジョン）
3. **埋め込み** - コンテンツがベクトル埋め込みに変換されます
4. **取得** - チャット中に関連する知識が自動的に意味検索によって取得されます

---

## エラー

<table>
<thead>
  <tr>
    <th>
      コード
    </th>
    
    <th>
      メッセージ
    </th>
    
    <th>
      原因
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      400
    </td>
    
    <td>
      <code>
        Link and description are required
      </code>
    </td>
    
    <td>
      必須フィールドが欠落
    </td>
  </tr>
  
  <tr>
    <td>
      400
    </td>
    
    <td>
      <code>
        keywords array is required and must not be empty
      </code>
    </td>
    
    <td>
      空または欠落したキーワード
    </td>
  </tr>
  
  <tr>
    <td>
      400
    </td>
    
    <td>
      <code>
        File too large
      </code>
    </td>
    
    <td>
      ファイルが50MBの制限を超えています
    </td>
  </tr>
  
  <tr>
    <td>
      400
    </td>
    
    <td>
      <code>
        Can only watch link-based knowledge
      </code>
    </td>
    
    <td>
      ファイルをウォッチしようとしました
    </td>
  </tr>
  
  <tr>
    <td>
      404
    </td>
    
    <td>
      <code>
        Mind not found or access denied
      </code>
    </td>
    
    <td>
      無効なスパークIDまたはアクセス権がありません
    </td>
  </tr>
  
  <tr>
    <td>
      415
    </td>
    
    <td>
      <code>
        Unsupported Content-Type
      </code>
    </td>
    
    <td>
      不正なContent-Typeヘッダー
    </td>
  </tr>
</tbody>
</table>

---

## 次のステップ

- [あなたのマインドとチャット](/docs/api/chat)
- [マインドを作成](/docs/api/minds)
- [APIエラーと制限](/docs/api/errors)
