Skip to main content

POST /v1/memories

Enqueue a memory for asynchronous processing by the cognition worker. Returns immediately with 202 Accepted and the assigned memory UUID. Required scope: memory:write

Request

curl -X POST https://api.thrindex.com/v1/memories \
  -H "Authorization: Bearer th_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "content": "User prefers weekly email digests over push notifications.",
    "agent_id": "support-agent",
    "user_id": "user-42"
  }'

Body

FieldTypeRequiredDefaultDescription
contentstringyesThe memory text. Maximum 8192 bytes.
agent_idstringyesAgent identifier. Max 256 characters. Allowed charset: [A-Za-z0-9._:-]
user_idstringyesUser identifier. Same constraints as agent_id.
confidencenumberno1.0Your confidence in this memory’s accuracy. Range: 0.01.0.
metadataobjectnoArbitrary key-value pairs stored alongside the memory. Any JSON object.
extractbooleannotrueControls LLM fact extraction in the cognition worker. See below.
Unknown fields in the request body are rejected with 400 validation_error. The org_id is always derived from the API key — never accepted in the body.

The extract field

ValueBehaviour
true (default)The cognition worker runs LLM extraction on the raw content, transforming it into clean, discrete, retrievable facts before storage.
falseContent is stored verbatim — no LLM call is made. Use this when you are supplying a pre-formatted, clean fact and want lower latency with zero extraction cost.

Response

202 Accepted

{
  "id": "3f2e1d0c-1234-5678-abcd-ef0123456789",
  "status": "queued"
}
FieldTypeDescription
idstring (UUID)The memory’s unique identifier. Use this to retrieve or delete the memory later.
statusstringAlways "queued" — the memory is being processed asynchronously.
The memory will be available for search within a few seconds, once the cognition worker completes processing.

Examples

Minimal request

curl -X POST https://api.thrindex.com/v1/memories \
  -H "Authorization: Bearer th_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "content": "User timezone is Europe/Berlin.",
    "agent_id": "support-agent",
    "user_id": "user-42"
  }'

With confidence and metadata

curl -X POST https://api.thrindex.com/v1/memories \
  -H "Authorization: Bearer th_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "content": "User stated they prefer dark mode in their account settings.",
    "agent_id": "support-agent",
    "user_id": "user-42",
    "confidence": 0.95,
    "metadata": {
      "source": "settings-page",
      "session_id": "sess_abc123"
    }
  }'

Bypass extraction (verbatim storage)

curl -X POST https://api.thrindex.com/v1/memories \
  -H "Authorization: Bearer th_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "content": "User prefers dark mode.",
    "agent_id": "support-agent",
    "user_id": "user-42",
    "extract": false
  }'
from thrindex import Thrindex

client = Thrindex(api_key="th_live_...")

# Standard — LLM extraction runs on the content
memory_id = client.add(
    content="User prefers weekly email digests over push notifications.",
    agent_id="support-agent",
    user_id="user-42",
    confidence=0.95,
    metadata={"source": "preference-survey"},
)

# Verbatim storage — no LLM call
memory_id = client.add(
    content="User prefers dark mode.",
    agent_id="support-agent",
    user_id="user-42",
    extract=False,
)

Errors

StatusCodeDescription
400validation_errorMissing required field, invalid charset in agent_id/user_id, confidence out of range, unknown field in body
401unauthorizedMissing or invalid API key
401forbiddenAPI key lacks memory:write scope
413payload_too_largecontent exceeds 8192 bytes
429rate_limitedRate limit exceeded — respect Retry-After header
500internal_errorServer error