apps/docs/memory-api/creation/adding-memories.mdx
Read more about [filtering](/memory-api/features/filtering)
2. Performance Tips
Batch Operations
containerTags for different spacesSearch Optimization
{
"q": "error logs",
"documentThreshold": 0.7, // Higher = more precise
"limit": 5, // Keep it small
"onlyMatchingChunks": true // Skip extra context if not needed
}
To add a memory, send a POST request to /add with your content:
curl https://api.supermemory.ai/v3/documents \
--request POST \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY' \
--data '{
"customId": "xyz-my-db-id",
"content": "This is the content of my memory",
"metadata": {
"category": "technology",
"tag_1": "ai",
"tag_2": "machine-learning",
},
"containerTags": ["user_123", "project_xyz"]
}'
await client.memory.create({
customId: "xyz-mydb-id",
content: "This is the content of my memory",
metadata: {
category: "technology",
tag_1": "ai",
tag_2": "machine-learning",
},
containerTags: ["user_123", "project_xyz"]
})
client.memory.create(
customId="xyz-mydb-id",
content="documents related to python",
metadata={
"category": "datascience",
"tag_1": "ai",
"tag_2": "machine-learning",
},
containerTags=["user_123", "project_xyz"]
)
The API will return a response with an ID and initial status:
{
"id": "mem_abc123",
"status": "queued"
}
curl https://api.supermemory.ai/v3/documents \
--request POST \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY' \
-d '{
"content": "https://example.com/article",
"metadata": {
"source": "web", # Just example metadata
"category": "technology" # NOT required
},
"containerTags": ["user_456", "research_papers"]
}'
await client.memory.create({
content: "https://example.com/article",
userId: "user_456",
metadata: {
source: "web", // Just example metadata
category: "technology", // NOT required
},
containerTags: ["user_456", "research_papers"],
});
client.memory.create(
content="https://example.com/article",
userId="user_456",
metadata={
"source": "web",
"category": "technology"
},
containerTags=["user_456", "research_papers"]
)
You can add rich metadata to organize your content:
{
"metadata": {
"source": "string", // String
"priority": 1234, // Custom numeric field
"custom_field": "any" // Any custom field
}
}
You can attribute and partition your data by providing a userId:
curl https://api.supermemory.ai/v3/documents \
--request POST \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY' \
-d '{
"content": "This is space-specific content",
"userId": "space_123",
"metadata": {
"category": "space-content"
}
}'
await client.memory.create({
content: "This is space-specific content",
userId: "space_123",
metadata: {
category: "space-content",
},
});
client.memory.create(
content="This is space-specific content",
userId="space_123",
metadata={
"category": "space-content"
}
)
You can group memories by providing an array of containerTags:
curl https://api.supermemory.ai/v3/documents \
--request POST \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY' \
-d '{
"content": "This is space-specific content",
"containerTags": ["user_123", "project_xyz"]
}'
await client.memory.create({
content: "This is space-specific content",
containerTags: ["user_123", "project_xyz"],
});
client.memory.create(
content="This is space-specific content",
containerTags=["user_123", "project_xyz"]
)
Check status using the memory ID:
<CodeGroup>curl https://api.supermemory.ai/v3/documents/mem_abc123 \
--request GET \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY'
await client.memory.get("mem_abc123");
client.memory.get("mem_abc123")
Memories are deleted after 2 minutes if an irrecoverable error occurs.
</Warning>For file uploads, use the dedicated file upload endpoint. You can include containerTags directly in the form data:
curl https://api.supermemory.ai/v3/documents/file \
--request POST \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY' \
--form 'file=@/path/to/your/file.pdf' \
--form 'containerTags=["user_123", "project_xyz"]'
const formData = new FormData();
formData.append("file", fileBlob);
formData.append("containerTags", JSON.stringify(["user_123", "project_xyz"]));
const response = await fetch("https://api.supermemory.ai/v3/documents/file", {
method: "POST",
headers: {
Authorization: "Bearer SUPERMEMORY_API_KEY",
},
body: formData,
});
import requests
import json
with open('/path/to/your/file.pdf', 'rb') as f:
files = {'file': f}
data = {'containerTags': json.dumps(["user_123", "project_xyz"])}
response = requests.post(
'https://api.supermemory.ai/v3/documents/file',
headers={'Authorization': 'Bearer SUPERMEMORY_API_KEY'},
files=files,
data=data
)
If you need to add additional metadata (like title or description) after upload, you can use the PATCH endpoint:
<CodeGroup>curl https://api.supermemory.ai/v3/documents/MEMORY_ID \
--request PATCH \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer SUPERMEMORY_API_KEY' \
--data '{
"metadata": {
"title": "My Document",
"description": "Important project document"
}
}'
await fetch(`https://api.supermemory.ai/v3/documents/${memoryId}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer SUPERMEMORY_API_KEY",
},
body: JSON.stringify({
metadata: {
title: "My Document",
description: "Important project document",
},
}),
});
import requests
requests.patch(
f'https://api.supermemory.ai/v3/documents/{memory_id}',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer SUPERMEMORY_API_KEY'
},
json={
'metadata': {
'title': 'My Document',
'description': 'Important project document'
}
}
)
Explore more advanced features in our API Reference tab.