# Capture memory (/docs/memory/capture-memory)
`dock.capture` is how your app tells Docklee something worth remembering. It takes plain text and returns at once. The memory is buffered and sent in the next batch.

## Capture a memory [#capture-a-memory]

This example writes one event and sends it straight away:

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

    dock = Dock()
    dock.capture("The customer renewed for another year.", type="event")
    result = dock.flush_sync()
    print(result.accepted, result.rejected)
    ```
  </Tab>
  <Tab value="TypeScript">
    ```ts
    import { Dock } from 'docklee';

    const dock = new Dock();
    dock.capture('The customer renewed for another year.', { type: 'event' });
    const result = await dock.flush();
    console.log(result?.accepted, result?.rejected);
    await dock.close();
    ```
  </Tab>
  <Tab value="cURL">
    ```bash
    curl https://api.docklee.com/v1/dock/ingest \
      -H "Authorization: Bearer $DOCKLEE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "memory_space_id": "your-memory-space-id",
        "events": [
          {"content": "The customer renewed for another year.", "type": "event"}
        ]
      }'
    ```
  </Tab>
</CodeTabs>

The response counts what was stored and explains anything that wasn't:

```json
{
  "batch_id": "8c2e4f1a-6b7d-4e93-a5c0-2d9f1b3e7a64",
  "accepted": 1,
  "rejected": 0,
  "errors": [],
  "usage": {
    "events_accepted": 1,
    "ke_events": 0,
    "dum_events": 1,
    "processing_time_ms": 388
  }
}
```

## `capture` options [#capture-options]

| Option | Python | TypeScript | Description |
| --- | --- | --- | --- |
| Content | `content` | first argument | The text to remember, up to 50,000 characters. Blank content is ignored. |
| Type | `type` | `type` | `conversation`, `event`, `preference`, or `entity` for memory. Defaults to `conversation`. See [Memory types](/docs/memory/memory-types). |
| Metadata | `metadata` | `metadata` | Your own key and value pairs, up to 10 KB. See [Metadata](/docs/memory/essentials/metadata). |
| Dedup key | `dedup_key` | `dedupKey` | Your own key for deciding when two captures are the same. See [Duplicates](/docs/memory/essentials/duplicates). |
| End user | `end_user` | `endUser` | The person this memory belongs to. See [End users](/docs/docklee/end-users). |

## `Dock` settings [#dock-settings]

| Setting | Python | TypeScript | Default |
| --- | --- | --- | --- |
| API key | `api_key` | `apiKey` | `DOCKLEE_API_KEY` |
| Memory space | `memory_space_id` | `memorySpaceId` | `DOCKLEE_MEMORY_SPACE_ID` |
| Default end user | `end_user` | `endUser` | `DOCKLEE_END_USER` |
| Events per batch | `buffer_size` | `bufferSize` | `10` |
| Retries per request | `max_retries` | `maxRetries` | `3` |
| Request timeout | `timeout` (seconds) | `timeout` (milliseconds) | 30 seconds |
| Base URL | `base_url` | `baseUrl` | `DOCKLEE_URL`, then `https://api.docklee.com` |

## Status codes [#status-codes]

| Status | Meaning |
| --- | --- |
| `200` | Every event was accepted. |
| `207` | Some events were accepted and some were rejected. Check `errors`. |
| `422` | Every event was rejected, or the request named no destination. |

Each entry in `errors` has the event's `index`, an `error` code, and a `message`:

| `error` | What it means |
| --- | --- |
| `duplicate_event` | The same content arrived within 60 seconds. See [Duplicates](/docs/memory/essentials/duplicates). |
| `memory_space_not_authorized` | The key can't write to this memory space. |
| `dum_ingestion_failed` | The memory couldn't be stored. The `message` says why. |

<Callout type="warn">
Flush or close `Dock` before your process exits. Events still in the buffer when the process ends are never sent. See [Batching and flush](/docs/memory/essentials/batching-and-flush).
</Callout>

## Next steps [#next-steps]

Your app is writing memories. Read them back next.

<Cards>
  <Card title="Recall memory" href="/docs/memory/recall-memory" description="Every option for reading memories back." />
  <Card title="Memory types" href="/docs/memory/memory-types" description="The type you send and the type Docklee assigns." />
  <Card title="Instrument your app" href="/docs/memory/automatic-capture/instrument" description="Capture without calling capture." />
</Cards>
