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

# Search Memories

> Search memories using natural language with optional reranking

```
POST /openapi/memorylake/api/v2/projects/{id}/memories/search
```

Searches memories in the project using natural language. Results can be filtered by user, limited by score threshold, and optionally reranked for higher relevance.

<Note>
  **Permission required:** [`project:mem_search`](/features/team-collaboration/permission-reference#search-memories) · `instance`
</Note>

### Path Parameters

<ParamField path="id" type="string" required>
  Project ID
</ParamField>

### Request Body

<ParamField body="query" type="string" required>
  The search query text
</ParamField>

<ParamField body="user_id" type="string" required>
  Filter by user ID
</ParamField>

<ParamField body="top_k" type="integer" default="10">
  Maximum number of results to return (1–1000)
</ParamField>

<ParamField body="threshold" type="number" default="0.3">
  Minimum similarity score threshold. Results below this score are filtered out.
</ParamField>

<ParamField body="rerank" type="boolean" default="false">
  Whether to apply reranking to improve result relevance
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST 'https://app.memorylake.ai/openapi/memorylake/api/v2/projects/proj-a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6/memories/search' \
    -H 'Authorization: Bearer sk_xxxxxx' \
    -H 'Content-Type: application/json' \
    -d '{
      "query": "What restaurants were recommended?",
      "user_id": "user-abc123",
      "top_k": 10,
      "threshold": 0.3,
      "rerank": false
    }'
  ```
</RequestExample>

### Response

<ResponseField name="data" type="object">
  <Expandable title="Search results">
    <ResponseField name="results" type="array">
      List of matching memories ordered by relevance

      <Expandable title="Memory result">
        <ResponseField name="id" type="string">Memory ID</ResponseField>
        <ResponseField name="content" type="string">Memory content</ResponseField>
        <ResponseField name="user_id" type="string">Associated user ID</ResponseField>
        <ResponseField name="created_at" type="string">Creation timestamp</ResponseField>
        <ResponseField name="updated_at" type="string">Last update timestamp</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```json Success (200) theme={null}
  {
    "success": true,
    "data": {
      "results": [
        {
          "id": "mem-123",
          "content": "User prefers Hangzhou cuisine restaurants",
          "user_id": "user-abc123",
          "created_at": "2024-01-15T10:00:00Z",
          "updated_at": "2024-01-15T10:00:00Z"
        }
      ]
    }
  }
  ```
</ResponseExample>
