Write Memory
POST/agent/memory/write
Store a memory in the knowledge base. The memory pipeline automatically:
- Classifies the memory type
- Runs guard checks (conflict detection & quality scoring)
- Extracts entities and relationships
- Builds/updates the knowledge graph
- Stores the vector embedding
Requestโ
Headersโ
| Header | Value |
|---|---|
Authorization | Bearer sm_agent_... |
Content-Type | application/json |
Body Parametersโ
contentstringrequired
The memory content to store (1โ50,000 characters).
volume_idstring (UUID)required
Target volume to write the memory into.
memory_typeenum
Optional. One of:
factual, preference, event, relationship, technical, episodic, procedural. Auto-detected if omitted.Responseโ
200 Memory stored successfully
{
"status": "approved",
"reason": "New factual information about John Smith's role",
"confidence": 0.92,
"memory_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"agent": "my-agent",
"volume_id": "..."
}
| Field | Description |
|---|---|
status | approved โ stored ยท rejected โ blocked by guard ยท merged โ merged with existing |
reason | Human-readable explanation of the guard decision |
confidence | 0โ1 confidence score from the guard |
memory_id | UUID of the stored memory |
Exampleโ
- cURL
- TypeScript SDK
- Python
curl -X POST https://api.sharedmemory.ai/agent/memory/write \
-H "Authorization: Bearer sm_agent_..." \
-H "Content-Type: application/json" \
-d '{
"content": "John Smith is the CTO of Acme Corp. He joined in 2022.",
"volume_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"memory_type": "factual"
}'
import { SharedMemory } from '@sharedmemory/sdk'
const memory = new SharedMemory({ apiKey: 'sm_agent_...' })
const result = await memory.remember(
"John Smith is the CTO of Acme Corp. He joined in 2022.",
{ volumeId: 'a1b2c3d4-...', memoryType: 'factual' }
)
console.log(result.status) // "approved"
console.log(result.confidence) // 0.92
import requests
response = requests.post(
"https://api.sharedmemory.ai/agent/memory/write",
headers={"Authorization": "Bearer sm_agent_..."},
json={
"content": "John Smith is the CTO of Acme Corp. He joined in 2022.",
"volume_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"memory_type": "factual"
}
)
print(response.json())
Errorsโ
| Status | Error | Description |
|---|---|---|
400 | validation_failed | Invalid input โ check details for field-level errors |
403 | agent_not_authorized_for_volume | Agent doesn't have write access to this volume |
429 | Too Many Requests | Rate limit exceeded (30/min) |
500 | write_failed | Internal error โ retry with exponential backoff |