Core Concepts
Capture memory
Write memories from your app with Dock, with a type, metadata, and an end user when the memory belongs to one person.
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
This example writes one event and sends it straight away:
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)The response counts what was stored and explains anything that wasn't:
{
"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
| 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. |
| Metadata | metadata | metadata | Your own key and value pairs, up to 10 KB. See Metadata. |
| Dedup key | dedup_key | dedupKey | Your own key for deciding when two captures are the same. See Duplicates. |
| End user | end_user | endUser | The person this memory belongs to. See End users. |
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 | 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. |
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. |
Flush or close Dock before your process exits. Events still in the buffer when the process ends are never sent. See Batching and flush.
Next steps
Your app is writing memories. Read them back next.