Skip to Content

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

OptionPythonTypeScriptDescription
Contentcontentfirst argumentThe text to remember, up to 50,000 characters. Blank content is ignored.
Typetypetypeconversation, event, preference, or entity for memory. Defaults to conversation. See Memory types.
MetadatametadatametadataYour own key and value pairs, up to 10 KB. See Metadata.
Dedup keydedup_keydedupKeyYour own key for deciding when two captures are the same. See Duplicates.
End userend_userendUserThe person this memory belongs to. See End users.

Dock settings

SettingPythonTypeScriptDefault
API keyapi_keyapiKeyDOCKLEE_API_KEY
Memory spacememory_space_idmemorySpaceIdDOCKLEE_MEMORY_SPACE_ID
Default end userend_userendUserDOCKLEE_END_USER
Events per batchbuffer_sizebufferSize10
Retries per requestmax_retriesmaxRetries3
Request timeouttimeout (seconds)timeout (milliseconds)30 seconds
Base URLbase_urlbaseUrlDOCKLEE_URL, then https://api.docklee.com

Status codes

StatusMeaning
200Every event was accepted.
207Some events were accepted and some were rejected. Check errors.
422Every event was rejected, or the request named no destination.

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

errorWhat it means
duplicate_eventThe same content arrived within 60 seconds. See Duplicates.
memory_space_not_authorizedThe key can't write to this memory space.
dum_ingestion_failedThe 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.

On this page