Skip to content

Webhooks

Fresh

Webhooks send real-time HTTP POST notifications when memory events occur. They are configured at the project level.

Event Types

EventTrigger
memory_addMemory is created
memory_updateMemory is modified
memory_deleteMemory is removed
memory_categorizeMemory is categorized

Create a Webhook

python
from mem0 import MemoryClient

client = MemoryClient(api_key="your-api-key")

webhook = client.create_webhook(
    url="https://your-app.com/webhook",
    name="Memory Logger",
    project_id="proj_123",
    event_types=["memory_add", "memory_categorize"]
)
javascript
const { MemoryClient } = require('mem0ai');
const client = new MemoryClient({ apiKey: 'your-api-key' });

const webhook = await client.createWebhook({
    url: "https://your-app.com/webhook",
    name: "Memory Logger",
    projectId: "proj_123",
    eventTypes: ["memory_add", "memory_categorize"]
});

Get Webhooks

python
webhooks = client.get_webhooks(project_id="proj_123")
javascript
const webhooks = await client.getWebhooks({ projectId: "proj_123" });

Update a Webhook

python
updated = client.update_webhook(
    name="Updated Logger",
    url="https://your-app.com/new-webhook",
    event_types=["memory_update", "memory_add"],
    webhook_id="wh_123"
)
javascript
const updated = await client.updateWebhook({
    name: "Updated Logger",
    url: "https://your-app.com/new-webhook",
    eventTypes: ["memory_update", "memory_add"],
    webhookId: "wh_123"
});

Delete a Webhook

python
client.delete_webhook(webhook_id="wh_123")
javascript
await client.deleteWebhook({ webhookId: "wh_123" });

Webhook Payload

Memory Add/Update/Delete

json
{
    "event_details": {
        "id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
        "data": {
            "memory": "Name is Alex"
        },
        "event": "ADD"
    }
}

Memory Categorize

json
{
    "event_details": {
        "event": "CATEGORIZE",
        "memory_id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
        "categories": ["hobbies", "travel"]
    }
}

Best Practices

  1. Implement Retry Logic -- Handle temporary failures gracefully
  2. Verify Webhook Source -- Add security validation
  3. Process Asynchronously -- Handle events in background jobs
  4. Monitor Health -- Track webhook logs regularly

SOP Documentation Site for Mem0