From 3db028c7193bf3d5e585ce91fed947654bd52f20 Mon Sep 17 00:00:00 2001 From: Dev Khant Date: Fri, 21 Feb 2025 00:48:59 +0530 Subject: [PATCH] Docs: update webhook (#2238) --- docs/features/webhook.mdx | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/features/webhook.mdx b/docs/features/webhook.mdx index 6aa50362..eac2bf80 100644 --- a/docs/features/webhook.mdx +++ b/docs/features/webhook.mdx @@ -18,6 +18,10 @@ Create a new webhook for your project. The webhook will only receive events from ```python Python +from mem0 import MemoryClient + +client = MemoryClient(api_key="your-api-key") + # Create webhook in a specific project webhook = client.create_webhook( url="https://your-app.com/webhook", @@ -29,6 +33,9 @@ print(webhook) ``` ```javascript JavaScript +const { MemoryClient } = require('mem0ai'); +const client = new MemoryClient('your-api-key'); + // Create webhook in a specific project const webhook = await client.createWebhook({ url: "https://your-app.com/webhook", @@ -41,14 +48,14 @@ 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' + "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" } ``` @@ -61,19 +68,12 @@ Retrieve all webhooks configured for your project: ```python Python -from mem0 import MemoryClient - -client = MemoryClient(api_key="your-api-key") - # Get webhooks for a specific project webhooks = client.get_webhooks(project_id="proj_123") print(webhooks) ``` ```javascript JavaScript -const { MemoryClient } = require('mem0ai'); -const client = new MemoryClient('your-api-key'); - // Get webhooks for a specific project const webhooks = await client.getWebhooks({projectId: "proj_123"}); console.log(webhooks); @@ -82,15 +82,15 @@ console.log(webhooks); ```json Output [ { - 'webhook_id': "wh_123", - 'url': 'https://mem0.ai', - 'name': 'mem0', - 'owner': 'john', - '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' + "webhook_id": "wh_123", + "url": "https://mem0.ai", + "name": "mem0", + "owner": "john", + "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" } ] @@ -121,9 +121,9 @@ print(updated_webhook) const updatedWebhook = await client.updateWebhook({ name: "Updated Logger", url: "https://your-app.com/new-webhook", + eventTypes: ["memory:update", "memory:add"], projectId: "proj_123", - webhookId: "wh_123", - eventTypes: ["memory:update", "memory:add"] + webhookId: "wh_123" }); console.log(updatedWebhook); ```