# Memory spaces (/docs/docklee/memory-spaces)
Memories from different products and environments shouldn't mix. A memory space keeps them apart. `Dock` writes memories into a space, and `Lynk` recalls from one space at a time.

Memory spaces are separate from containers and engines. Knowledge never mixes into a memory space.

<Callout type="info" title="Create a new space when...">
- A product or environment needs its own memory, such as production and staging.
- You're adding per-user memory to an app that already uses space-level memory.
</Callout>

## Create a space [#create-a-space]

In the [Docklee dashboard](https://app.docklee.com), open **DUM** and create a memory space. Copy its ID. Memories never move between spaces on their own.

## Point the SDK at a space [#point-the-sdk-at-a-space]

Set the ID once so `Dock` and `Lynk` both use it:

```bash
export DOCKLEE_MEMORY_SPACE_ID="your-memory-space-id"
```

Or pass it in code:

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

    dock = Dock(memory_space_id="your-memory-space-id")
    lynk = Lynk(memory_space_id="your-memory-space-id")

    dock.capture("The customer renewed for another year.", type="event")
    dock.flush_sync()

    records = lynk.recall_sync("renewal history", top_k=5)
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Dock, Lynk } from 'docklee';

    const dock = new Dock({ memorySpaceId: 'your-memory-space-id' });
    const lynk = new Lynk({ memorySpaceId: 'your-memory-space-id' });

    dock.capture('The customer renewed for another year.', { type: 'event' });
    await dock.close();

    const records = await lynk.recall('renewal history', { topK: 5 });
    ```
  </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": "renewal history", "top_k": 5}'
    ```
  </Tab>
</CodeTabs>

To recall from a different space for one call, pass `memory_space_id` (Python) or `memorySpaceId` (TypeScript) to `recall`. Calling `recall` with no space ID raises an error that names the missing setting.

## Space-level and per-user memory [#space-level-and-per-user-memory]

| Kind | Who reads it | Suits |
| --- | --- | --- |
| Space-level | Everything that reads the space | An agent's working notes, a team's shared facts |
| Per-user | Only calls with the same `end_user` | Apps that serve many people |

A new space holds space-level memory. The first memory written with an `end_user` makes it a multi-user space for good. From then on, every write and every recall must name an end user, and a recall with no end user returns nothing.

<Callout type="warn">
Use separate spaces for space-level and per-user memory. The first end user write changes how a space works, and it can't be undone.
</Callout>

## Settings in the dashboard [#settings-in-the-dashboard]

| Setting | What it does |
| --- | --- |
| Retention | Keeps memories forever, or for 30 days, 90 days, or 1 year. See [Retention](/docs/memory/governance/retention). |
| Content Shield | Hides memory content from dashboard users. See [Content Shield](/docs/memory/governance/content-shield). |
| PIN | Locks the space in the dashboard until the PIN is entered. |

## Control access [#control-access]

A key reaches every memory space in your workspace until you narrow it to selected spaces. See [API keys](/docs/docklee/api-keys).

## Next steps [#next-steps]

Your space is ready. If your app serves many people, set up end users next.

<Cards>
  <Card title="End users" href="/docs/docklee/end-users" description="Keep each user's memories private." />
  <Card title="Capture memory" href="/docs/memory/capture-memory" description="Every option for writing memories." />
  <Card title="Recall memory" href="/docs/memory/recall-memory" description="Every option for reading them back." />
</Cards>
