> ## Documentation Index
> Fetch the complete documentation index at: https://ai-kb.automationanywhere.com/llms.txt
> Use this file to discover all available pages before exploring further.

# メモリAPIリファレンス

> EKB REST APIを使用してエージェントメモリと承認ワークフローをプログラムで管理します。

## 認証

すべてのエンドポイントには以下のヘッダーが必要です：

```http theme={null}
x-api-key: <your-api-key>
x-api-secret: <your-api-secret>
Content-Type: application/json
```

## エンドポイント

<AccordionGroup>
  <Accordion title="エージェントメモリ設定を取得">
    **`GET /agents/{agent_id}/memory-settings`**

    エージェントの現在のメモリ設定を返します。

    **レスポンス例：**

    ```json theme={null}
    {
      "memory_enabled": true,
      "max_memories": 50,
      "auto_approve": false,
      "memory_types": ["preference", "fact", "context"]
    }
    ```
  </Accordion>

  <Accordion title="エージェントメモリ設定を更新">
    **`PUT /agents/{agent_id}/memory-settings`**

    エージェントのメモリ設定を有効化、無効化、または更新します。

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

    ```json theme={null}
    {
      "memory_enabled": true,
      "max_memories": 50,
      "auto_approve": false,
      "memory_types": ["preference", "fact", "context"]
    }
    ```

    **レスポンス例：**

    ```json theme={null}
    {
      "success": true,
      "message": "Memory settings updated successfully",
      "settings": {
        "memory_enabled": true,
        "max_memories": 50,
        "auto_approve": false,
        "memory_types": ["preference", "fact", "context"]
      }
    }
    ```
  </Accordion>

  <Accordion title="エージェントの承認済みメモリを取得">
    **`GET /agents/{agent_id}/memories`**

    ユーザー別にグループ化された、エージェントのすべての承認済みメモリを返します。

    **レスポンス例：**

    ```json theme={null}
    {
      "memories_by_user": {
        "user_123": [
          {
            "id": "memory_abc",
            "agent_id": "agent_123",
            "user_id": "user_123",
            "memory_content": "User prefers concise technical answers.",
            "memory_type": "preference",
            "confidence_score": 0.92,
            "status": "approved",
            "created_at": 1710000000,
            "updated_at": 1710000100,
            "approved_at": 1710000100,
            "source_message_id": "msg_123"
          }
        ]
      },
      "total_users": 1,
      "total_memories": 1
    }
    ```
  </Accordion>

  <Accordion title="特定ユーザーの承認済みメモリを取得">
    **`GET /agents/{agent_id}/memories/user/{user_id}`**

    1人のユーザーと1つのエージェントの承認済みメモリレコードを返します。

    **レスポンス例：**

    ```json theme={null}
    [
      {
        "id": "memory_abc",
        "agent_id": "agent_123",
        "user_id": "user_123",
        "memory_content": "User prefers concise technical answers.",
        "memory_type": "preference",
        "confidence_score": 0.92,
        "status": "approved",
        "created_at": 1710000000,
        "updated_at": 1710000100,
        "approved_at": 1710000100,
        "source_message_id": "msg_123"
      }
    ]
    ```
  </Accordion>

  <Accordion title="保留中のメモリ承認を取得">
    **`GET /memory-approvals/pending`**

    認証済みユーザーの保留中のメモリ承認を返します。オプションで`?agent_id={agent_id}`を使用してエージェントでフィルタできます。

    **レスポンス例：**

    ```json theme={null}
    [
      {
        "id": "memory_abc",
        "agent_id": "agent_123",
        "user_id": "user_123",
        "memory_content": "User prefers concise technical answers.",
        "memory_type": "preference",
        "confidence_score": 0.92,
        "source_message": "Please keep answers short and technical.",
        "created_at": 1710000000,
        "expires_at": 1710604800
      }
    ]
    ```
  </Accordion>

  <Accordion title="メモリを承認または却下">
    **`POST /memory-approvals/{memory_id}/action`**

    保留中のメモリレコードを承認または却下します。

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

    ```json theme={null}
    {
      "action": "approve"
    }
    ```

    **レスポンス例：**

    ```json theme={null}
    {
      "success": true,
      "message": "Memory approved successfully",
      "memory_id": "memory_abc"
    }
    ```
  </Accordion>

  <Accordion title="メモリを削除">
    **`DELETE /memories/{memory_id}`**

    メモリレコードを却下としてマークして削除します。

    **レスポンス例：**

    ```json theme={null}
    {
      "success": true,
      "message": "Memory deleted successfully",
      "memory_id": "memory_abc"
    }
    ```
  </Accordion>
</AccordionGroup>
