# Recall memory (/docs/memory/recall-memory)
`lynk.recall` takes a question in plain words and returns the memories that answer it, best first. You don't need to match the stored text or know which memories exist.

## Recall memories [#recall-memories]

This example asks one question and prints what comes back:

<CodeTabs>
  <Tab value="Python">
    ```python
    from docklee import Lynk

    lynk = Lynk()
    records = lynk.recall_sync("How does Maya like to be contacted?", top_k=5)
    for record in records:
        print(record.confidence, record.content)
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Lynk } from 'docklee';

    const lynk = new Lynk();
    const records = await lynk.recall('How does Maya like to be contacted?', { topK: 5 });
    for (const record of records) {
      console.log(record.confidence, record.content);
    }
    ```
  </Tab>
  <Tab value="cURL">
    ```bash
    curl https://api.docklee.com/v1/dum/search \
      -H "Authorization: Bearer $DOCKLEE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "memory_space_id": "your-memory-space-id",
        "query": "How does Maya like to be contacted?",
        "top_k": 5
      }'
    ```
  </Tab>
</CodeTabs>

The API returns a list, best match first:

```json
[
  {
    "id": "9b1e7c42-5d3a-4f08-b6e2-1a7c0d93e5f4",
    "content": "Maya now prefers phone calls.",
    "memory_type": "entity",
    "confidence_score": 0.91
  },
  {
    "id": "e47a03d9-2c18-4b6f-8e5a-7f1d9c2b0a36",
    "content": "Maya moved from Austin to Denver last month.",
    "memory_type": "entity",
    "confidence_score": 0.64
  }
]
```

The older email preference isn't in the list. It was replaced by the newer one, so recall returns only the current value.

## `recall` options [#recall-options]

| Option | Python | TypeScript | Default | Description |
| --- | --- | --- | --- | --- |
| Query | `query` | first argument | none | The question, in plain words. |
| Memory space | `memory_space_id` | `memorySpaceId` | `DOCKLEE_MEMORY_SPACE_ID` | The space to read for this call. |
| Result count | `top_k` | `topK` | `5` | How many memories to return, from 1 to 50. |
| End user | `end_user` | `endUser` | `DOCKLEE_END_USER` | Returns only that person's memories. Required in a multi-user space. |

## The memory record [#the-memory-record]

| Python | TypeScript | Description |
| --- | --- | --- |
| `memory_id` | `memoryId` | The memory's ID. |
| `content` | `content` | The remembered text. |
| `memory_type` | `memoryType` | The storage class of the memory. See [Memory types](/docs/memory/memory-types). |
| `confidence` | `confidence` | How strongly this memory answers the query, from 0 to 1. |

## Sync and async [#sync-and-async]

In Python, `recall` is async and `recall_sync` blocks. Use the one that matches your code:

<CodeTabs items={['Python', 'TypeScript']}>
  <Tab value="Python">
    ```python
    records = await lynk.recall("What plan is the customer on?")
    records = lynk.recall_sync("What plan is the customer on?")
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    const records = await lynk.recall('What plan is the customer on?');
    ```
  </Tab>
</CodeTabs>

## Use memories in a prompt [#use-memories-in-a-prompt]

Join the recalled memories into a short block above the user's message:

<CodeTabs items={['Python', 'TypeScript']}>
  <Tab value="Python">
    ```python
    records = lynk.recall_sync(user_message, end_user=user_id)
    known = "\n".join(f"- {record.content}" for record in records)
    prompt = f"What you know about this user:\n{known}\n\nUser: {user_message}"
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    const records = await lynk.recall(userMessage, { endUser: userId });
    const known = records.map((record) => `- ${record.content}`).join('\n');
    const prompt = `What you know about this user:\n${known}\n\nUser: ${userMessage}`;
    ```
  </Tab>
</CodeTabs>

<Callout type="idea">
Recall before your model replies, and capture after. Each turn then starts with what your app already knows and adds what it just learned.
</Callout>

## Next steps [#next-steps]

You can read memories back. Learn how Docklee picks which ones to return.

<Cards>
  <Card title="Ranking" href="/docs/memory/intelligence/ranking" description="The signals behind every recall." />
  <Card title="End users" href="/docs/docklee/end-users" description="Recall one person's memories only." />
  <Card title="Troubleshooting" href="/docs/memory/troubleshooting" description="When recall returns less than you expect." />
</Cards>
