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

# Memory API Reference

> Manage agent memories and approval workflows programmatically using the Odin AI Platform REST API.

## Authentication

All endpoints require the following headers:

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

## Endpoints

<AccordionGroup>
  <Accordion title="Get Agent Memory Settings">
    **`GET /agents/{agent_id}/memory-settings`**

    Returns the current memory configuration for an agent.

    **Response example:**

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

  <Accordion title="Update Agent Memory Settings">
    **`PUT /agents/{agent_id}/memory-settings`**

    Enables, disables, or updates memory configuration for an agent.

    **Request body:**

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

    **Response example:**

    ```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 Approved Memories For an Agent">
    **`GET /agents/{agent_id}/memories`**

    Returns all approved memories for an agent, grouped by user.

    **Response example:**

    ```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 Approved Memories For a Specific User">
    **`GET /agents/{agent_id}/memories/user/{user_id}`**

    Returns approved memory records for one user and one agent.

    **Response example:**

    ```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 Pending Memory Approvals">
    **`GET /memory-approvals/pending`**

    Returns pending memory approvals for the authenticated user. Optionally filter by agent using `?agent_id={agent_id}`.

    **Response example:**

    ```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="Approve or Reject a Memory">
    **`POST /memory-approvals/{memory_id}/action`**

    Approves or rejects a pending memory record.

    **Request body:**

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

    **Response example:**

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

  <Accordion title="Delete a Memory">
    **`DELETE /memories/{memory_id}`**

    Deletes a memory record by marking it as rejected.

    **Response example:**

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