Skip to main content

Retain

POST /api/v2/containers/{container_tag}/retain

Retain captures evidence and candidate memory. The runtime classifies junk, extracts atomic claims, and promotes only clean supported facts.

Authentication

Send a scoped UnifiedMemory key:

-H "Authorization: Bearer $UNIFIED_MEMORY_API_KEY"

The key determines the effective workspace, source app, agent identity, and capabilities. Request body agent_id and source_app are diagnostics only when they conflict with key metadata.

Path parameters

NameRequiredDescription
container_tagYesMemory container, usually jeethendra for the primary workspace.

Request fields

At least one of content or contents is required.

FieldTypeDefaultNotes
contentstring-Single memory candidate, 1 to 50000 characters.
contentsarray-Batch form, 1 to 100 content items.
sourcestringapiCaller source label.
source_appstring-App identity hint; key metadata wins on conflict.
agent_idstring-Agent identity hint; key metadata wins on conflict.
app_idstring-App/run grouping hint.
run_idstring-Run identifier for grouping and audit.
user_idstring-User hint when allowed by key scope.
memory_planestring-Common values: personal, task, tool, working.
memory_scopestring-Common values: session, user, agent, app, org.
tagsstring[]-Optional retrieval and proof tags.
metadataobject-Additional non-secret provenance.
auto_extractbooleantrueWhether cognition may extract atomic claims.
review_requiredbooleanfalseForce human review instead of direct promotion.
review_reasonstring-Why review is requested.
confidencenumber-Compatibility-only signal from 0 to 1. Not a trust override.
trust_scorenumber-Compatibility-only signal from 0 to 1. Not a trust override.
expires_in_hoursnumber-Optional positive TTL for short-lived memory.
recall_hintstring-Optional hint for future retrieval.
custom_idstring-Caller idempotency/reference identifier.
request_idstring-Caller request id for tracing.

Schema from OpenAPI

This section is generated from /openapi.public.json. Edit the OpenAPI source or generator, not this block.

POST /api/v2/containers/{container_tag}/retain

  • Operation ID: retain_memories_api_v2_containers__container_tag__retain_post
  • Declared response statuses: 200, 422

Request schema

Schema: RetainRequest

FieldRequiredTypeNullableDefaultConstraints
agent_idNostringYes--
app_idNostringYes--
auto_extractNobooleanNotrue-
capture_kindNostringYes--
confidenceNonumberYes-minimum=0.0, maximum=1.0
contentNostringYes-minLength=1, maxLength=50000
contentsNoarray of RetainContentItemYes-minItems=1, maxItems=100
custom_idNostringYes--
durabilityNostringYes--
expires_in_hoursNonumberYes--
extraction_profileNostringYes--
lifecycle_stateNostringYes--
memory_planeNostringYes--
memory_scopeNostringYes--
metadataNoobjectYes--
org_idNostringYes--
promotion_stateNostringYes--
recall_hintNostringYes--
request_idNostringYes--
review_reasonNostringYes--
review_requiredNobooleanNofalse-
run_idNostringYes--
sourceNostringNo"api"-
source_appNostringYes--
source_refNostringYes--
source_typeNostringYes--
tagsNoarray of stringYes--
trust_scoreNonumberYes-minimum=0.0, maximum=1.0
user_idNostringYes--

200 response schema

Schema: RetainResponse

FieldRequiredTypeNullableDefaultConstraints
container_tagYesstringNo--
errorsNoarray of objectNo--
memoriesYesarray of objectNo--
runtime_fanoutNoobjectYes--
savedYesintegerNo--

Example

curl -sS https://edge-api.jithendranara.dev/api/v2/containers/jeethendra/retain \
-H "Authorization: Bearer $UNIFIED_MEMORY_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"content": "The owner prefers MiniMax-backed search first for factual/current queries.",
"source": "codex",
"source_app": "codex",
"agent_id": "codex",
"memory_plane": "task",
"memory_scope": "agent",
"tags": ["search", "preference"]
}'

Response shape

{
"container_tag": "jeethendra",
"saved": 1,
"committed": true,
"committed_memory_ids": ["mem_example_123"],
"enrichment_status": "queued",
"pending_jobs": ["runtime_lifecycle"],
"client_retry_safe": false,
"idempotency_status": "request_id_missing",
"memories": [
{
"id": "mem_example_123",
"content": "The owner prefers MiniMax-backed search first for factual/current queries.",
"lifecycle_state": "active",
"trust_bucket": "needs_review"
}
],
"errors": [],
"runtime_fanout": {
"queued": true,
"routes": ["distill", "embed", "google_memory_bank_compare"]
}
}

Required response fields are container_tag, saved, and memories. errors is an array when batch items fail. The acknowledgement fields separate durable commit from slower enrichment:

FieldMeaning
committedWhether memory rows were durably written before the response.
committed_memory_idsIDs that are safe to use for follow-up reads, evidence, or Courtroom.
enrichment_statuscomplete, queued, pending, or not_applicable for slower lifecycle work.
pending_jobsAsync lifecycle/enrichment jobs still running after commit.
client_retry_safeWhether retrying the same request is safe from the client side. Prefer setting request_id.
idempotency_statusDiagnostic explaining whether a caller request id was present.

runtime_fanout is present when async lifecycle work is queued.

Common outcomes

StatusMeaning
401Missing or invalid key.
403Key lacks write capability for this container or source.
409Write conflicts with lifecycle, review, or scope policy.
422Request validation failed, such as empty content or invalid field bounds.

Notes

  • Retain is additive at the evidence layer. Updates, conflicts, and deletes are represented as reconciliation state, not silent evidence erasure.
  • Secret-like strings and test/eval rows are quarantined or forensic-only.
  • See Bad candidates and residue before wiring automatic writeback.