Parameters Reference Template - Mem0

Parameters Reference Template

Parameter references document every input/output detail for one operation after the quickstart/onboarding journey. Keep them scannable: signature, tables, examples, exits.


❌ DO NOT COPY: Guidance & Constraints


✅ COPY THIS: Content Skeleton

---
title: [Operation title] Parameters
description: Full reference for `[client.method]` inputs and responses.
icon: "table"
---

# [Operation title] Parameters

<CodeGroup>
```python Python
client.memories.add(
    user_id: str,
    memory: str,
    metadata: Optional[dict] = None,
    memory_type: Literal["session", "long_term"] = "session",
)
await mem0.memories.add({
userId: string;
memory: string;
metadata?: Record<string, string>;
memoryType?: "session" | "long_term";
});
Defaults to session memories. Override `memory_type` for long-term storage. [Optional: call out deprecated fields or upcoming removals.]

Parameters

Name Type Required Description Notes
user_id string Yes Unique identifier for the end user. Must match follow-up operations.
memory string Yes Content to persist. Managed & OSS. Markdown allowed.
metadata object No Key-value pairs for filters. OSS stores as JSONB; limit to 2KB.
memory_type string No Retention bucket Platform supports shared.
Set `ttl_seconds` when you need memories to expire automatically (OSS only).

Response fields

Field Type Description Example
memory_id string Identifier used for updates/deletes. mem_123
created_at string (ISO 8601) Timestamp when the memory was stored. 2025-02-04T12:00:00Z
metadata object Echoed metadata (if provided). { "team": "support" }
{
"memory_id": "mem_123",
"memory": "I am training for a marathon.",
"metadata": {
    "team": "support"
}
}

Examples

```python Python response = client.memories.add( user_id="alex", memory="I am training for a marathon.", ) print(response["memory_id"]) ``` ```typescript TypeScript const { memoryId } = await mem0.memories.add({ userId: "alex", memory: "I am training for a marathon.", }); console.log(memoryId); ```

These snippets confirm the method returns the new memory_id for follow-up operations.

Related operations

Troubleshooting


✅ Publish Checklist