Skip to content

Memories

The Memory API provides persistent key-value storage with tagging, categorization, and full-text search. Agents use memories to retain context between sessions, share knowledge, and build up institutional understanding over time.

Base path: /api/memories

All endpoints require Authorization: Bearer <token>.

Memory access is scope-aware — pass X-Scope-Organization-Id and/or X-Scope-Project-Id headers to isolate memories to a specific context.


List Memories

GET /api/memories

Query parameters:

ParameterTypeDescription
agentNamestringFilter to memories created by a specific agent
categorystringFilter by category
tagsstringComma-separated tags to filter by
keystringKey pattern match (prefix search)
sessionstringFilter by session ID
searchstringFull-text search over key and value
limitnumberDefault 20, max 100
offsetnumberDefault 0

Response:

json
{
  "success": true,
  "data": [
    {
      "id": "mem_01J...",
      "key": "project:cortex:api-patterns",
      "value": "All API routes use consistent Hono patterns with typed responses",
      "category": "architecture",
      "tags": ["hono", "api", "patterns"],
      "agentName": "architect",
      "sessionId": "sess_01J...",
      "createdAt": "2026-04-01T10:00:00Z",
      "updatedAt": "2026-04-01T10:00:00Z"
    }
  ],
  "pagination": { "limit": 20, "offset": 0, "total": 142 }
}

curl:

bash
curl "https://api.cortex.acrobi.com/api/memories?category=architecture&tags=api,patterns" \
  -H "Authorization: Bearer <token>"

Store Memory

POST /api/memories

Request body:

json
{
  "key": "project:cortex:api-patterns",
  "value": "All API routes use consistent Hono patterns with typed responses",
  "category": "architecture",
  "tags": ["hono", "api", "patterns"],
  "agentName": "architect",
  "sessionId": "sess_01J...",
  "ttl": 86400
}
FieldTypeRequiredDescription
keystringYesUnique key (use : separators for namespacing)
valuestringYesMemory content
categorystringNoSemantic category for grouping
tagsstring[]NoSearchable tags
agentNamestringNoAgent that created this memory
sessionIdstringNoSession this memory belongs to
ttlnumberNoTime-to-live in seconds (omit for permanent)

Response: 201 Created

json
{
  "success": true,
  "data": {
    "id": "mem_01J...",
    "key": "project:cortex:api-patterns",
    "createdAt": "2026-04-03T12:00:00Z"
  }
}

If a memory with the same key already exists in this scope, it is updated and 200 OK is returned.

curl:

bash
curl -X POST "https://api.cortex.acrobi.com/api/memories" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "project:cortex:api-patterns",
    "value": "All routes use Hono with typed responses",
    "category": "architecture",
    "tags": ["hono", "api"]
  }'

Get Memory

GET /api/memories/:id

Response:

json
{
  "success": true,
  "data": {
    "id": "mem_01J...",
    "key": "project:cortex:api-patterns",
    "value": "All API routes use consistent Hono patterns...",
    "category": "architecture",
    "tags": ["hono", "api", "patterns"],
    "agentName": "architect",
    "sessionId": "sess_01J...",
    "expiresAt": null,
    "createdAt": "2026-04-01T10:00:00Z",
    "updatedAt": "2026-04-01T10:00:00Z"
  }
}

Update Memory

PATCH /api/memories/:id

Request body:

json
{
  "value": "All routes use Hono with strict TypeScript — no any types",
  "tags": ["hono", "api", "patterns", "typescript"]
}

Response: 200 OK — returns updated memory object.


Delete Memory

DELETE /api/memories/:id

Response:

json
{ "success": true }

Search Memories

Full-text search using FTS5 over keys and values.

GET /api/memories/search

Query parameters:

ParameterTypeRequiredDescription
qstringYesSearch query
categorystringNoRestrict to category
agentNamestringNoRestrict to agent
limitnumberNoDefault 20

Response:

json
{
  "success": true,
  "data": [
    {
      "id": "mem_01J...",
      "key": "project:cortex:api-patterns",
      "value": "All API routes use consistent Hono patterns...",
      "score": 0.94,
      "category": "architecture",
      "tags": ["hono", "api"]
    }
  ]
}

curl:

bash
curl "https://api.cortex.acrobi.com/api/memories/search?q=Hono+patterns&category=architecture" \
  -H "Authorization: Bearer <token>"

Bulk Store

Store multiple memories in a single request.

POST /api/memories/bulk

Request body:

json
{
  "memories": [
    {
      "key": "decision:use-hono",
      "value": "Chose Hono over Express for Cloudflare Workers compatibility",
      "category": "decisions"
    },
    {
      "key": "decision:use-turso",
      "value": "Chose Turso for edge-compatible SQLite with branching",
      "category": "decisions"
    }
  ]
}

Response: 201 Created

json
{
  "success": true,
  "data": {
    "created": 2,
    "updated": 0,
    "failed": 0
  }
}

Bulk Retrieve

Retrieve multiple memories by key in a single request.

POST /api/memories/bulk-get

Request body:

json
{
  "keys": ["decision:use-hono", "decision:use-turso", "project:cortex:api-patterns"]
}

Response: 200 OK

json
{
  "success": true,
  "data": {
    "found": [
      { "key": "decision:use-hono", "value": "...", "id": "mem_01J..." },
      { "key": "decision:use-turso", "value": "...", "id": "mem_02J..." }
    ],
    "missing": ["project:cortex:api-patterns"]
  }
}

Memory Stats

Returns counts and usage statistics for the current scope.

GET /api/memories/stats

Response:

json
{
  "success": true,
  "data": {
    "total": 142,
    "byCategory": {
      "architecture": 34,
      "decisions": 28,
      "research": 21,
      "other": 59
    },
    "byAgent": {
      "architect": 41,
      "backend-coder": 38,
      "qa-tester": 18
    },
    "storageBytes": 284912,
    "expiringIn24h": 3
  }
}

Built by Acrobi