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

# Memories

# Memories API

Store and manage memories within a space.

## Add a Memory

```http theme={null}
POST /v1/memories
Authorization: Bearer anona_live_YOUR_KEY
Content-Type: application/json
```

**Request Body:**

```json theme={null}
{
  "space_id": "spc_a1b2c3d4",
  "content": "Alice works at Google and specializes in distributed systems",
  "context": "onboarding call",
  "metadata": {
    "user_id": "alice_123",
    "tags": ["work", "expertise"]
  }
}
```

| Parameter   | Type   | Required | Description                          |
| ----------- | ------ | -------- | ------------------------------------ |
| `space_id`  | string | Yes      | Which space to store in              |
| `content`   | string | Yes      | The memory text                      |
| `context`   | string | No       | Freeform context for the memory      |
| `timestamp` | string | No       | ISO 8601 timestamp (defaults to now) |
| `metadata`  | object | No       | Custom key-value data                |

**Response (200 OK):**

```json theme={null}
{
  "memory_id": "mem_abc123def456",
  "status": "stored",
  "usage": {
    "input_tokens": 42,
    "output_tokens": 12
  }
}
```

**Python SDK:**

```python theme={null}
memory = client.add_memory(
    space_id="spc_a1b2c3d4",
    content="Alice works at Google and specializes in distributed systems",
    metadata={"user_id": "alice_123", "tags": ["work", "expertise"]}
)
print(memory["memory_id"])
```

***

## List Memories in a Space

```http theme={null}
GET /v1/spaces/{space_id}/memories?limit=10&offset=0&q=Alice&type=fact
Authorization: Bearer anona_live_YOUR_KEY
```

| Query Param | Type    | Description                 |
| ----------- | ------- | --------------------------- |
| `limit`     | integer | Max results                 |
| `offset`    | integer | Pagination offset           |
| `q`         | string  | Optional text filter        |
| `type`      | string  | Optional memory type filter |

**Response (200 OK):**

```json theme={null}
{
  "items": [
    {
      "id": "mem_abc123def456",
      "text": "Alice works at Google and specializes in distributed systems",
      "context": "onboarding call",
      "date": "2026-07-14T12:34:56Z",
      "type": "fact",
      "entities": ["Alice", "Google"],
      "metadata": {"user_id": "alice_123"}
    }
  ],
  "total": 42,
  "limit": 10,
  "offset": 0
}
```

Note: list results use `id`/`text`/`date` field names, distinct from the `memory_id`/`content` names used when adding or searching memories.

***

## Delete a Memory

```http theme={null}
DELETE /v1/spaces/{space_id}/memories/{memory_id}
Authorization: Bearer anona_live_YOUR_KEY
```

**Response:** `204 No Content` - permanently deleted, no body.

```python theme={null}
client.delete_memory(space_id="spc_a1b2c3d4", memory_id="mem_abc123def456")
```

There is no endpoint to fetch or update a single memory by ID - list, search, or delete are the available operations.

***

## Error Responses

All errors share this shape:

```json theme={null}
{
  "error": {
    "code": "...",
    "message": "...",
    "request_id": "req_..."
  }
}
```

| Status | Code               | Cause                         |
| ------ | ------------------ | ----------------------------- |
| 400    | `bad_request`      | Invalid request body          |
| 401    | `unauthorized`     | Missing/invalid API key       |
| 403    | `forbidden`        | Space not owned by your org   |
| 404    | `not_found`        | Memory or space doesn't exist |
| 422    | `validation_error` | Body fails schema validation  |
| 429    | `rate_limited`     | Quota or rate limit exceeded  |

See the full [error reference](/api-reference/errors).

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Search API" icon="magnifying-glass" href="/api-reference/search">
    Query memories semantically
  </Card>

  <Card title="Insights API" icon="lightbulb" href="/api-reference/insights">
    Synthesize insights
  </Card>
</CardGroup>
