REST API

Full HTTP API for managing memories programmatically. All endpoints require authentication via API key.

Base URL: https://cortex-mem.com/api

POST

/memories

Save a new memory.

Request Body

FieldTypeRequiredDescription
contentstringYesThe memory content to save
tagsstring[]NoCategorization tags
agent_idstringNoAgent identifier for scoping
importancenumberNo0.0-1.0, higher values decay slower
session_idstringNoSession identifier

Example

POST /api/memories
Authorization: Bearer ctx_your_key
Content-Type: application/json

{
  "content": "User prefers dark mode and Python",
  "tags": ["preference"],
  "agent_id": "my-agent",
  "importance": 0.8
}
GET

/memories/search

Search memories by semantic meaning.

Query Parameters

ParamRequiredDescription
qYesNatural language search query
limitNoMax results (default 10)
tagsNoComma-separated tags to filter by
agent_idNoFilter by agent

Example

GET /api/memories/search?q=user+preferences&limit=5
Authorization: Bearer ctx_your_key
PUT

/memories/:id

Update an existing memory.

Example

PUT /api/memories/mem_abc123
Authorization: Bearer ctx_your_key
Content-Type: application/json

{
  "content": "User prefers dark mode, Python, and VS Code",
  "tags": ["preference", "tools"]
}
DELETE

/memories/:id

Permanently delete a memory.

Example

DELETE /api/memories/mem_abc123
Authorization: Bearer ctx_your_key

Response Format

All responses return JSON. A memory object looks like:

{
  "id": "mem_abc123",
  "content": "User prefers dark mode and Python",
  "tags": ["preference"],
  "agent_id": "my-agent",
  "importance": 0.8,
  "created_at": "2025-01-15T10:30:00Z",
  "updated_at": "2025-01-15T10:30:00Z",
  "score": 0.92
}