API Reference
Complete reference for the CLAIV Memory API.
Base URL: https://api.claiv.io
The tenant_id is inferred from your API key. You never send it in request payloads. CLAIV Memory returns context; your LLM generates the final reply.
Authentication
All API requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEYPOST /v1/ingest
Ingest an event into the memory system. Returns immediately; enrichment happens asynchronously (1–5s).
Request Body
| Parameter | Type | Description |
|---|---|---|
user_idrequired | string | Unique identifier for the user |
typerequired | enum | One of: "message", "tool_call", "app_event" |
contentrequired | string | The event content to ingest |
thread_id | string | Optional thread/conversation scope |
Response
| Field | Type | Description |
|---|---|---|
event_id | string | Unique ID for the ingested event |
deduped | boolean | Whether this event was a duplicate |
Example
Request
curl -X POST https://api.claiv.io/v1/ingest \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123",
"type": "message",
"content": "User prefers dark mode and concise responses"
}'Response (200)
{
"event_id": "evt_abc123",
"deduped": false
}After ingest, a background worker enriches the event asynchronously (1–5 seconds). Recall may return empty results until enrichment completes.
POST /v1/recall
Retrieve relevant context for a user, packed within a token budget. Inject the returned context into your LLM's system prompt.
Request Body
| Parameter | Type | Description |
|---|---|---|
user_idrequired | string | User to retrieve context for |
taskrequired | string | Context/query for relevance ranking |
token_budgetrequired | integer | Maximum tokens to return (200-8000) |
thread_id | string | Optional thread scope filter |
Response
| Field | Type | Description |
|---|---|---|
system_context | string | Pre-built context string to inject into your LLM system prompt |
memory_blocks | array | Array of structured memory objects with type, content, and relevance |
citations | string[] | Event IDs that contributed to the returned context |
token_estimate | integer | Approximate token count of the returned context |
Example
Request
curl -X POST https://api.claiv.io/v1/recall \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123",
"task": "What are the user preferences?",
"token_budget": 2000
}'Response (200)
{
"system_context": "User prefers dark mode and concise responses.",
"memory_blocks": [
{
"type": "fact",
"content": "Prefers dark mode",
"relevance": 0.95
},
{
"type": "fact",
"content": "Likes concise responses",
"relevance": 0.88
}
],
"citations": ["evt_abc123"],
"token_estimate": 42
}POST /v1/forget
Delete derived memory data for a user. Original ingested events are preserved. Returns a compliance receipt.
Request Body
| Parameter | Type | Description |
|---|---|---|
user_idrequired | string | User whose derived data to delete |
thread_id | string | Delete only from specific thread |
Response
| Field | Type | Description |
|---|---|---|
receipt_id | string | Unique receipt ID for compliance records |
deleted_counts | object | Counts of deleted items by category (facts, episodes, embeddings) |
Example
Request
curl -X POST https://api.claiv.io/v1/forget \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_id": "user-123"
}'Response (200)
{
"receipt_id": "rcpt_xyz789",
"deleted_counts": {
"facts": 3,
"episodes": 1,
"embeddings": 12
}
}Error Codes
| Code | Error | Description |
|---|---|---|
400 | Bad Request | Invalid parameters (e.g., missing required fields, invalid type enum) |
401 | Unauthorized | Invalid or missing API key |
404 | Not Found | Resource does not exist |
422 | Unprocessable | Valid JSON but semantically incorrect (e.g., token_budget out of range) |
429 | Quota Exceeded | Plan quota exceeded. Check Usage & Limits for reset date. |
500 | Internal Error | Server error. Retry with exponential backoff. |