Use customId to update existing documents or conversations. When you send content with the same customId, Supermemory intelligently processes only what’s new.
// First requestawait client.add({ content: "user: Hi, I'm Sarah.\nassistant: Nice to meet you!", customId: "conv_123", containerTag: "user_sarah"});// Later: send only new messagesawait client.add({ content: "user: What's the weather?\nassistant: It's sunny today.", customId: "conv_123", // Same ID — Supermemory links them containerTag: "user_sarah"});
Option 2: Send the full updated content
// Supermemory detects the diff and only processes new partsawait client.add({ content: "user: Hi, I'm Sarah.\nassistant: Nice to meet you!\nuser: What's the weather?\nassistant: It's sunny today.", customId: "conv_123", containerTag: "user_sarah"});
Format your conversations however you want. Supermemory handles any string format:
// Simple stringcontent: "user: Hello\nassistant: Hi there!"// JSON stringifycontent: JSON.stringify(messages)// Template literalcontent: messages.map(m => `${m.role}: ${m.content}`).join('\n')// Any format — just make it a stringcontent: formatConversation(messages)
// Guide memory extraction for this container tag{ containerTag: "session_abc123", entityContext: `Design exploration conversation between john@acme.com and Brand.ai assistant. Focus on John's design preferences and brand requirements.`}
By default, when you add content, Supermemory uses all existing memories in the space as context for generating new memories. With filtered writes, you can scope this context to only memories from documents matching specific metadata.This is useful when you have many documents in a space but want new memories to build on top of a specific subset — for example, only memories from a particular source, category, or user.
The metadata itself is still written to the document, but the memories will only be built on top of what’s already there matching the filter.
TypeScript
Python
cURL
await client.add({ content: "New research findings on transformer architectures...", containerTag: "user_123", metadata: { category: "ml", source: "arxiv" }, filterByMetadata: { category: "ml" }});
client.add( content="New research findings on transformer architectures...", container_tag="user_123", metadata={"category": "ml", "source": "arxiv"}, filter_by_metadata={"category": "ml"})
curl -X POST "https://api.supermemory.ai/v3/documents" \ -H "Authorization: Bearer $SUPERMEMORY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content": "New research findings on transformer architectures...", "containerTag": "user_123", "metadata": {"category": "ml", "source": "arxiv"}, "filterByMetadata": {"category": "ml"} }'
Record<string, string | number | boolean | string[]>
Key-value pairs to filter existing memories by their source document metadata
Scalar values (string, number, boolean) match exactly
Array values match if any value in the array matches (OR logic)
Multiple keys are combined with AND logic
// Match documents where category is "ml" AND source is either "arxiv" or "pubmed"await client.add({ content: "...", containerTag: "user_123", filterByMetadata: { category: "ml", source: ["arxiv", "pubmed"] }});