# Operation Guide Template

Operation guides focus on a single action (add, search, update, delete). Show the minimal path to execute it, verify the result, and route readers to references or applied guides.

## ❌ DO NOT COPY: Guidance & Constraints

- Frontmatter needs `title`, `description`, `icon`. Title should be a verb phrase (“Add Memories”).
- Lead with a two-sentence promise (problem → outcome), followed by an `<Info>` prerequisites block and optional `<Warning>` for hazards (overwrites, rate limits).
- Include a “When to pick this” bullet list (≤3 items) so readers confirm they’re in the right doc.
- Use Tabs with Python and TypeScript examples. If only one SDK exists, add a `<Note>` stating that explicitly.
- When migrating legacy guides, keep existing code paths and notes. Slot them into these sections instead of replacing them unless behavior changed.
- Provide `<Info icon=\"check\">` verification after each critical step; call out the most common error with a `<Warning>` close to where it can occur.
- End with exactly two CTA cards: left = conceptual depth, right = applied example/cookbook.

## ✅ COPY THIS: Content Skeleton

````
---
title: [Operation title]
description: [Outcome in one sentence]
icon: "bolt"
---

# [Operation headline: say what it does]

[State the problem this solves.] [Explain the outcome after running it.]

<Info>
  **Prerequisites**
  - [API key, project, runtime requirements]
  - [Identifiers the reader needs ready]
</Info>

<Warning>
  [Optional: describe the main risk, e.g., duplicates or destructive behavior.]
</Warning>

## When to pick this

- [Scenario 1]
- [Scenario 2]
- [Scenario 3]

## Configure access

```bash
export MEM0_API_KEY="sk-..."
```

<Tip>
  Already configured Mem0? Skip this and move to the next section.
</Tip>

## Prepare inputs

[Brief sentence describing payload requirements.]

<Tabs>
  <Tab title="Python">
<CodeGroup>
```python Python
payload = {
    "user_id": "alex",
    "memory": "I am training for a marathon."
}
```
</CodeGroup>
  </Tab>
  <Tab title="TypeScript">
<CodeGroup>
```typescript TypeScript
const payload = {
userId: "alex",
memory: "I am training for a marathon."
};
```
</CodeGroup>
  </Tab>
</Tabs>

## Call the operation

<Tabs>
  <Tab title="Python">
<CodeGroup>
```python Python
from mem0 import Memory

memory = Memory(api_key=os.environ["MEM0_API_KEY"])
response = memory.add(payload)
```
</CodeGroup>
  </Tab>
  <Tab title="TypeScript">
<CodeGroup>
```typescript TypeScript
import { Memory } from "mem0ai/oss";

const memory = new Memory({ apiKey: process.env.MEM0_API_KEY! });
const response = await memory.add(payload);
```
</CodeGroup>
  </Tab>
</Tabs>

<Info icon="check">
  Expect `{"memory_id": "mem_123"}` (or similar). Keep this ID for updates or deletes.
</Info>

<Warning>
  `401 Unauthorized` usually means the API key is missing or scoped incorrectly.
</Warning>

## Interpret the response

| Field       | Description                              |
| ----------- | ---------------------------------------- |
| `memory_id` | Use to update or delete later.          |
| `created_at` | ISO 8601 timestamp for auditing.        |

<Tip>
  Need to upsert instead? Switch to the update operation and supply the `memory_id`.
</Tip>

## Verify it worked

- Check the Mem0 dashboard for the new memory entry.
- Run the search operation with the same `user_id` and confirm it appears in results.

## Common follow-ups

- [Link to parameter reference]
- [Link to complementary operation]
- [Link to troubleshooting playbook section]

<CardGroup cols={2}>
  <Card
    title="[Concept guide]"
    description="[Deepen understanding of the operation’s model]"
    icon="layers"
    href="/[concept-link]"
  />
  <Card
    title="[Applied cookbook]"
    description="[How to apply this operation in a workflow]"
    icon="rocket"
    href="/[cookbook-link]"
  />
</CardGroup>
````

## ✅ Publish Checklist

- [ ]  Intro states problem + outcome, and prerequisites are complete.
- [ ]  Python and TypeScript snippets stay in sync (or a `<Note>` clarifies missing parity).
- [ ]  Every major step includes an actionable `<Info icon=\"check\">`.
- [ ]  Warnings cover the most likely failure mode near where it occurs.
- [ ]  CTA pair is present with valid links (concept left, cookbook right).
