mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-06 02:47:54 +00:00
direct add memory support
This commit is contained in:
parent
5dd358a939
commit
8b976015b6
1 changed files with 108 additions and 0 deletions
|
|
@ -9,8 +9,116 @@ icon: "database"
|
|||
These v4 endpoints operate on extracted memories (not raw documents). SDK support coming soon — use fetch or cURL for now.
|
||||
|
||||
For document management (list, get, update, delete), see [Document Operations](/document-operations).
|
||||
For ingesting raw content (text, files, URLs) through the processing pipeline, see [Add Context](/add-memories).
|
||||
</Info>
|
||||
|
||||
## Create Memories
|
||||
|
||||
Create memories directly without going through the document ingestion workflow. Memories are embedded and immediately searchable.
|
||||
|
||||
This is useful for storing user preferences, traits, or any structured facts where you already know the exact memory content.
|
||||
|
||||
<Tabs>
|
||||
<Tab title="fetch">
|
||||
```typescript
|
||||
const response = await fetch("https://api.supermemory.ai/v4/memories", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${API_KEY}`,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
memories: [
|
||||
{
|
||||
content: "John prefers dark mode",
|
||||
isStatic: false,
|
||||
metadata: { source: "user_preference" }
|
||||
},
|
||||
{
|
||||
content: "John is from Seattle",
|
||||
isStatic: true
|
||||
}
|
||||
],
|
||||
containerTag: "user_123"
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
// {
|
||||
// documentId: "abc123",
|
||||
// memories: [
|
||||
// { id: "mem_1", memory: "John prefers dark mode", isStatic: false, createdAt: "2025-..." },
|
||||
// { id: "mem_2", memory: "John is from Seattle", isStatic: true, createdAt: "2025-..." }
|
||||
// ]
|
||||
// }
|
||||
```
|
||||
</Tab>
|
||||
<Tab title="cURL">
|
||||
```bash
|
||||
curl -X POST "https://api.supermemory.ai/v4/memories" \
|
||||
-H "Authorization: Bearer $SUPERMEMORY_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"memories": [
|
||||
{
|
||||
"content": "John prefers dark mode",
|
||||
"isStatic": false,
|
||||
"metadata": { "source": "user_preference" }
|
||||
},
|
||||
{
|
||||
"content": "John is from Seattle",
|
||||
"isStatic": true
|
||||
}
|
||||
],
|
||||
"containerTag": "user_123"
|
||||
}'
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `memories` | array | yes | Array of memory objects (1–100 items) |
|
||||
| `memories[].content` | string | yes | The memory text (max 10,000 chars). Should be entity-centric, e.g. "John prefers dark mode" |
|
||||
| `memories[].isStatic` | boolean | no | `true` for permanent identity traits (name, hometown). Defaults to `false` |
|
||||
| `memories[].metadata` | object | no | Key-value metadata (strings, numbers, booleans) |
|
||||
| `containerTag` | string | yes | Space / container tag these memories belong to |
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"documentId": "abc123",
|
||||
"memories": [
|
||||
{
|
||||
"id": "mem_1",
|
||||
"memory": "John prefers dark mode",
|
||||
"isStatic": false,
|
||||
"createdAt": "2025-01-15T10:30:00.000Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `documentId` | string \| null | ID of the lightweight source document created for traceability |
|
||||
| `memories` | array | The created memory entries |
|
||||
| `memories[].id` | string | Unique memory ID |
|
||||
| `memories[].memory` | string | The memory content |
|
||||
| `memories[].isStatic` | boolean | Whether this is a permanent trait |
|
||||
| `memories[].createdAt` | string | ISO 8601 timestamp |
|
||||
|
||||
<Tip>
|
||||
**When to use this vs [Add Context](/add-memories)?**
|
||||
|
||||
Use **Create Memories** when you already know the exact facts to store (user preferences, traits, structured data). Use **Add Context** when you have raw content (conversations, documents, URLs) that Supermemory should process and extract memories from.
|
||||
</Tip>
|
||||
|
||||
---
|
||||
|
||||
## Forget Memory
|
||||
|
||||
Soft-delete a memory — excluded from search results but preserved in the system. Use this when you might want to restore later.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue