> ## 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.

# Search

# Search API

Query memories semantically using natural language.

## Search Memories

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

**Request Body:**

```json theme={null}
{
  "space_id": "spc_a1b2c3d4",
  "query": "Where does Alice work?",
  "limit": 10,
  "filters": {
    "type": "fact"
  }
}
```

| Parameter  | Type    | Required | Description                         |
| ---------- | ------- | -------- | ----------------------------------- |
| `space_id` | string  | Yes      | Which space to search               |
| `query`    | string  | Yes      | Natural language query              |
| `limit`    | integer | No       | Max results, 1–100 (default: 10)    |
| `filters`  | object  | No       | Optional filters (e.g. memory type) |

**Response (200 OK):**

```json theme={null}
{
  "results": [
    {
      "memory_id": "mem_abc123def456",
      "content": "Alice works at Google and specializes in distributed systems",
      "relevance_score": 0.95,
      "memory_type": "fact",
      "metadata": {"user_id": "alice_123"},
      "created_at": "2026-07-14T12:34:56Z"
    }
  ],
  "usage": {
    "input_tokens": 8
  }
}
```

| Field             | Type   | Description                     |
| ----------------- | ------ | ------------------------------- |
| `relevance_score` | number | 0.0–1.0, higher = more relevant |

**Python SDK:**

```python theme={null}
results = client.search(
    space_id="spc_a1b2c3d4",
    query="Where does Alice work?",
    limit=10
)

for r in results:
    print(r["content"], r["relevance_score"])
```

`client.search()` returns the `results` list directly (empty list if no matches).

***

## How Semantic Search Works

Search understands meaning, not just keywords - "Where does Alice work?", "Alice's employer", and "What company is Alice at?" all surface the same memory. Your query is embedded and compared against stored memory embeddings; results are ranked by `relevance_score`.

***

## Error Responses

Same shape as other endpoints - see the [error reference](/api-reference/errors).

| Status | Code           | Cause                         |
| ------ | -------------- | ----------------------------- |
| 400    | `bad_request`  | Missing `query` or `space_id` |
| 401    | `unauthorized` | Missing/invalid API key       |
| 403    | `forbidden`    | Space not owned by your org   |
| 404    | `not_found`    | Space doesn't exist           |
| 429    | `rate_limited` | Quota or rate limit exceeded  |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Insights API" icon="lightbulb" href="/api-reference/insights">
    Synthesize learned patterns
  </Card>

  <Card title="Concepts" icon="book" href="/concepts">
    Learn how semantic search works
  </Card>
</CardGroup>
