Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

Docs: update webhooks (#2237)

Dev Khantc86b1e4d4c7d
diff --git a/docs/features/webhook.mdx b/docs/features/webhook.mdx
index 477025ba7..6aa503629 100644
--- a/docs/features/webhook.mdx
+++ b/docs/features/webhook.mdx
@@ -11,6 +11,49 @@ Webhooks allow you to receive real-time notifications when memory events occur i
## Managing Webhooks
+### Create Webhook
+
+Create a new webhook for your project. The webhook will only receive events from the specified project:
+
+<CodeGroup>
+
+```python Python
+# Create webhook in a specific project
+webhook = client.create_webhook(
+ url="https://your-app.com/webhook",
+ name="Memory Logger",
+ project_id="proj_123",
+ event_types=["memory:add"]
+)
+print(webhook)
+```
+
+```javascript JavaScript
+// Create webhook in a specific project
+const webhook = await client.createWebhook({
+ url: "https://your-app.com/webhook",
+ name: "Memory Logger",
+ projectId: "proj_123",
+ eventTypes: ["memory:add"]
+});
+console.log(webhook);
+```
+
+```json Output
+{
+ 'webhook_id': "wh_123",
+ 'name': 'Memory Logger',
+ 'url': 'https://your-app.com/webhook',
+ 'event_types': ['memory_add'],
+ 'project': 'default-project',
+ 'is_active': True,
+ 'created_at': '2025-02-18T22:59:56.804993-08:00',
+ 'updated_at': '2025-02-18T23:06:41.479361-08:00'
+}
+```
+
+</CodeGroup>
+
### Get Webhooks
Retrieve all webhooks configured for your project:
@@ -32,7 +75,7 @@ const { MemoryClient } = require('mem0ai');
const client = new MemoryClient('your-api-key');
// Get webhooks for a specific project
-const webhooks = await client.getWebhooks("proj_123");
+const webhooks = await client.getWebhooks({projectId: "proj_123"});
console.log(webhooks);
```
@@ -55,49 +98,6 @@ console.log(webhooks);
</CodeGroup>
-### Create Webhook
-
-Create a new webhook for your project. The webhook will only receive events from the specified project:
-
-<CodeGroup>
-
-```python Python
-# Create webhook in a specific project
-webhook = client.create_webhook(
- url="https://your-app.com/webhook",
- name="Memory Logger",
- project_id="proj_123"
- event_types=["memory:add"]
-)
-print(webhook)
-```
-
-```javascript JavaScript
-// Create webhook in a specific project
-const webhook = await client.createWebhook({
- url: "https://your-app.com/webhook",
- name: "Memory Logger",
- projectId: "proj_123",
- eventTypes: ["memory:add"]
-});
-console.log(webhook);
-```
-
-```json Output
-{
- 'webhook_id': "wh_123",
- 'name': 'Memory Logger',
- 'url': 'https://your-app.com/webhook',
- 'event_types': ['memory_add'],
- 'project': 'default-project',
- 'is_active': True,
- 'created_at': '2025-02-18T22:59:56.804993-08:00',
- 'updated_at': '2025-02-18T23:06:41.479361-08:00'
-}
-```
-
-</CodeGroup>
-
### Update Webhook
Modify an existing webhook's configuration. Remember that webhooks can only be updated within their associated project:
@@ -108,7 +108,8 @@ Modify an existing webhook's configuration. Remember that webhooks can only be u
# Update webhook for a specific project
updated_webhook = client.update_webhook(
name="Updated Logger",
- url="https://your-app.com/new-webhook"
+ url="https://your-app.com/new-webhook",
+ event_types=["memory:update", "memory:add"],
project_id="proj_123",
webhook_id="wh_123"
)
@@ -117,10 +118,12 @@ print(updated_webhook)
```javascript JavaScript
// Update webhook for a specific project
-const updatedWebhook = await client.updateWebhook("wh_123", {
+const updatedWebhook = await client.updateWebhook({
name: "Updated Logger",
url: "https://your-app.com/new-webhook",
- projectId: "proj_123"
+ projectId: "proj_123",
+ webhookId: "wh_123",
+ eventTypes: ["memory:update", "memory:add"]
});
console.log(updatedWebhook);
```
@@ -169,15 +172,17 @@ Mem0 supports the following event types for webhooks:
## Webhook Payload
-When a memory event occurs in your project, Mem0 sends a POST request to your webhook URL with the following payload structure:
+When a memory event occurs in your project, Mem0 sends a POST request to your webhook URL with the following example payload structure:
```json
{
- "id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
- "data": {
- "memory": "Name is Alex"
- },
- "event": "ADD"
+ "event_details": {
+ "id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5",
+ "data": {
+ "memory": "Name is Alex"
+ },
+ "event": "ADD"
+ }
}
```