Keyoku
Engine / API Reference

API Reference.

All endpoints are under the base path /api/v1/. Every request requires a Bearer token via the Authorization header. Set the token with the KEYOKU_SESSION_TOKEN environment variable.

Default port: 18900. All request/response bodies are JSON.

Bearer token on every request.

# All API calls require the session token
curl -H "Authorization: Bearer $KEYOKU_SESSION_TOKEN" \
  http://localhost:18900/api/v1/health
Health

Health endpoints.

GET/api/v1/health

Returns engine health status, version, uptime, and database stats.

Memory

Memory endpoints.

POST/api/v1/remember

Ingests a conversation exchange. The LLM extracts structured memories, runs dedup, and stores results. Body: { entity_id, content, source?, session_id?, agent_id?, schema_id?, team_id?, visibility? }.

POST/api/v1/seed

Insert memories directly without LLM extraction. Useful for testing, migration, and bootstrapping. Body: { memories: [{ entity_id, content, type, importance?, ... }] }.

POST/api/v1/search

Semantic search over stored memories. Body: { entity_id, query, limit?, mode?, agent_id?, team_aware?, min_score? }. Returns ranked results with similarity scores.

GET/api/v1/memories

List all memories for an entity. Query params: entity_id, type?, state?, limit?, offset?. Returns paginated results.

GET/api/v1/memories/:id

Fetch a single memory by ID. Returns the full memory object including metadata, embedding status, and access history.

DELETE/api/v1/memories/:id

Soft-delete a memory by ID. Sets state to DELETED. Memory is purged after retention period (default 90 days).

DELETE/api/v1/memories

Bulk delete memories for an entity. Query params: entity_id, type?, before?. Use with caution.

PUT/api/v1/memories/:id/tags

Update tags on a memory. Body: { tags: string[] }. Replaces existing tags.

GET/api/v1/memories/sample

Returns a random sample of memories for an entity. Query params: entity_id, limit?. Useful for debugging and testing.

Stats

Stats endpoints.

GET/api/v1/stats

Global engine statistics: total memories, entities, memory type distribution, storage size, HNSW index stats.

GET/api/v1/stats/:entity_id

Per-entity statistics: memory count by type, average importance, decay distribution, relationship count, last activity.

Heartbeat

Heartbeat endpoints.

POST/api/v1/heartbeat/check

Run the heartbeat signal scan. Body: { entity_id, deadline_window?, decay_threshold?, importance_floor?, max_results?, agent_id?, team_id? }. Returns { should_act, pending_work, deadlines, scheduled, decaying, conflicts, summary }.

POST/api/v1/heartbeat/context

Combined heartbeat check + context-relevant memory search in a single call. Body: { entity_id, query?, top_k?, min_score?, autonomy?, analyze?, agent_id?, in_conversation? }. Returns heartbeat signals plus relevant memories.

POST/api/v1/heartbeat/record-message

Record the actual message text sent in a heartbeat for dedup tracking. Body: { entity_id, agent_id, action_id?, message }.

Scheduling

Scheduling endpoints.

POST/api/v1/schedule

Create a scheduled reminder. Body: { entity_id, content, cron_expression?, trigger_at?, repeat? }.

GET/api/v1/scheduled

List scheduled items. Query params: entity_id?, active_only?. Returns all scheduled reminders with next trigger time.

POST/api/v1/schedule/ack

Acknowledge a triggered schedule. Body: { schedule_id }. Prevents re-triggering for one-shot schedules.

PUT/api/v1/schedule/:id

Update a scheduled item. Body: { content?, cron_expression?, trigger_at?, active? }.

DELETE/api/v1/schedule/:id

Delete a scheduled item permanently.

Watcher

Watcher endpoints.

GET/api/v1/watcher/status

Returns the current watcher state including running status, adaptive mode, watched entities, and next tick time.

GET/api/v1/watcher/history

Returns the tick history ring buffer for auditing. Shows recent heartbeat check results and timing.

POST/api/v1/watcher/start

Start the heartbeat watcher loop. Body: { entity_ids, interval_ms?, adaptive?, delivery? }. Begins polling for watched entities.

POST/api/v1/watcher/stop

Stop the heartbeat watcher loop. No more automatic heartbeat checks until restarted.

POST/api/v1/watcher/watch

Add an entity to the watch list. Body: { entity_id }. The watcher will include this entity in heartbeat scans.

POST/api/v1/watcher/unwatch

Remove an entity from the watch list. Body: { entity_id }. Stops heartbeat scanning for this entity.

Teams

Teams endpoints.

POST/api/v1/teams

Create a new team. Body: { name, description? }. Returns team ID.

GET/api/v1/teams/:id

Get team details including member list, shared memory count, and team stats.

DELETE/api/v1/teams/:id

Delete a team. Does not delete member entities or their memories.

POST/api/v1/teams/:id/members

Add a member to a team. Body: { agent_id, role? }. Members share team-scoped memories.

DELETE/api/v1/teams/:id/members/:agent_id

Remove a member from a team. Their personal memories are unaffected.

GET/api/v1/teams/:id/members

List all members of a team with their roles and join dates.

Other

Other endpoints.

GET/api/v1/entities

List all known entities (people, orgs, locations, products) and their relationship graph. Query params: type?, limit?.

POST/api/v1/consolidate

Trigger memory consolidation for an entity. Merges near-duplicates, resolves conflicts, and rebuilds the HNSW index. Body: { entity_id }.

GET/api/v1/events

Server-Sent Events stream. Real-time notifications for memory changes, heartbeat signals, and watcher events. Connect with EventSource.

Store and search memories.

# Store a conversation exchange
curl -X POST http://localhost:18900/api/v1/remember \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "entity_id": "user-1",
    "content": "User: I just got promoted to senior engineer\nAgent: Congratulations!"
  }'

# Search memories
curl -X POST http://localhost:18900/api/v1/search \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "entity_id": "user-1",
    "query": "career milestones",
    "limit": 5
  }'
Response codes

Standard HTTP responses.

CodeMeaning
200Success
201Created (new memory, schedule, team)
400Bad request — missing or invalid parameters
401Unauthorized — missing or invalid Bearer token
404Not found — invalid memory/schedule/team ID
500Internal server error