From 5a93643f1222800a80f3c34706b71de3ce71234a Mon Sep 17 00:00:00 2001 From: Mragank Shekhar Date: Thu, 19 Feb 2026 15:09:11 +0530 Subject: [PATCH] docs: add memory_categorize webhook event type (#4077) --- docs/openapi.json | 14 ++++++++------ docs/platform/features/webhooks.mdx | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/docs/openapi.json b/docs/openapi.json index f842853a2..dfbf87b0c 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -4539,7 +4539,7 @@ "x-code-samples": [ { "lang": "Python", - "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\")\n\n# Get all webhooks\nwebhooks = client.get_webhooks(project_id=\"your_project_id\")\nprint(webhooks)\n\n# Create a webhook\nwebhook = client.create_webhook(\n url=\"https://your-webhook-url.com\",\n name=\"My Webhook\",\n project_id=\"your_project_id\",\n event_types=[\"memory:add\"]\n)\nprint(webhook)" + "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\")\n\n# Get all webhooks\nwebhooks = client.get_webhooks(project_id=\"your_project_id\")\nprint(webhooks)\n\n# Create a webhook\nwebhook = client.create_webhook(\n url=\"https://your-webhook-url.com\",\n name=\"My Webhook\",\n project_id=\"your_project_id\",\n event_types=[\"memory:add\", \"memory:categorize\"]\n)\nprint(webhook)" }, { "lang": "JavaScript", @@ -4606,7 +4606,8 @@ "enum": [ "memory:add", "memory:update", - "memory:delete" + "memory:delete", + "memory:categorize" ] }, "description": "List of event types to subscribe to." @@ -4701,7 +4702,7 @@ "x-code-samples": [ { "lang": "Python", - "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\", org_id=\"your_org_id\", project_id=\"your_project_id\")\n\n# Create a webhook\nwebhook = client.create_webhook(\n url=\"https://your-webhook-url.com\",\n name=\"My Webhook\",\n project_id=\"your_project_id\",\n event_types=[\"memory:add\"]\n)\nprint(webhook)" + "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\", org_id=\"your_org_id\", project_id=\"your_project_id\")\n\n# Create a webhook\nwebhook = client.create_webhook(\n url=\"https://your-webhook-url.com\",\n name=\"My Webhook\",\n project_id=\"your_project_id\",\n event_types=[\"memory:add\", \"memory:categorize\"]\n)\nprint(webhook)" }, { "lang": "JavaScript", @@ -4767,7 +4768,8 @@ "enum": [ "memory:add", "memory:update", - "memory:delete" + "memory:delete", + "memory:categorize" ] }, "description": "New list of event types to subscribe to" @@ -4845,11 +4847,11 @@ "x-code-samples": [ { "lang": "Python", - "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\")\n\n# Update a webhook\nwebhook = client.update_webhook(\n webhook_id=\"your_webhook_id\",\n name=\"Updated Webhook\",\n url=\"https://new-webhook-url.com\",\n event_types=[\"memory:add\"]\n)\nprint(webhook)\n\n# Delete a webhook\nresponse = client.delete_webhook(webhook_id=\"your_webhook_id\")\nprint(response)" + "source": "# To use the Python SDK, install the package:\n# pip install mem0ai\n\nfrom mem0 import MemoryClient\nclient = MemoryClient(api_key=\"your_api_key\")\n\n# Update a webhook\nwebhook = client.update_webhook(\n webhook_id=\"your_webhook_id\",\n name=\"Updated Webhook\",\n url=\"https://new-webhook-url.com\",\n event_types=[\"memory:add\", \"memory:categorize\"]\n)\nprint(webhook)\n\n# Delete a webhook\nresponse = client.delete_webhook(webhook_id=\"your_webhook_id\")\nprint(response)" }, { "lang": "JavaScript", - "source": "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: 'your-api-key' });\n\n// Update a webhook\nclient.updateWebhook('your_webhook_id', {\n name: 'Updated Webhook',\n url: 'https://new-webhook-url.com',\n event_types: ['memory:add']\n})\n .then(webhook => console.log(webhook))\n .catch(err => console.error(err));\n\n// Delete a webhook\nclient.deleteWebhook('your_webhook_id')\n .then(response => console.log(response))\n .catch(err => console.error(err));" + "source": "// To use the JavaScript SDK, install the package:\n// npm i mem0ai\n\nimport MemoryClient from 'mem0ai';\nconst client = new MemoryClient({ apiKey: 'your-api-key' });\n\n// Update a webhook\nclient.updateWebhook('your_webhook_id', {\n name: 'Updated Webhook',\n url: 'https://new-webhook-url.com',\n event_types: ['memory:add', 'memory:categorize']\n})\n .then(webhook => console.log(webhook))\n .catch(err => console.error(err));\n\n// Delete a webhook\nclient.deleteWebhook('your_webhook_id')\n .then(response => console.log(response))\n .catch(err => console.error(err));" }, { "lang": "cURL", diff --git a/docs/platform/features/webhooks.mdx b/docs/platform/features/webhooks.mdx index 240022216..abb7cfcd5 100644 --- a/docs/platform/features/webhooks.mdx +++ b/docs/platform/features/webhooks.mdx @@ -5,7 +5,7 @@ description: 'Configure and manage webhooks to receive real-time notifications a ## Overview -Webhooks enable real-time notifications for memory events in your Mem0 project. Webhooks are configured at the project level, meaning each webhook is tied to a specific project and receives events solely from that project. You can configure webhooks to send HTTP POST requests to your specified URLs whenever memories are created, updated, or deleted. +Webhooks enable real-time notifications for memory events in your Mem0 project. Webhooks are configured at the project level, meaning each webhook is tied to a specific project and receives events solely from that project. You can configure webhooks to send HTTP POST requests to your specified URLs whenever memories are created, updated, deleted, or categorized. ## Managing Webhooks @@ -27,7 +27,7 @@ webhook = client.create_webhook( url="https://your-app.com/webhook", name="Memory Logger", project_id="proj_123", - event_types=["memory_add"] + event_types=["memory_add", "memory_categorize"] ) print(webhook) ``` @@ -41,7 +41,7 @@ const webhook = await client.createWebhook({ url: "https://your-app.com/webhook", name: "Memory Logger", projectId: "proj_123", - eventTypes: ["memory_add"] + eventTypes: ["memory_add", "memory_categorize"] }); console.log(webhook); ``` @@ -167,11 +167,13 @@ Mem0 supports the following event types for webhooks: - `memory_add`: Triggered when a memory is added. - `memory_update`: Triggered when an existing memory is updated. - `memory_delete`: Triggered when a memory is deleted. +- `memory_categorize`: Triggered when a memory is categorized. ## Webhook Payload When a memory event occurs, Mem0 sends an HTTP POST request to your webhook URL with the following payload: +**Memory add/update/delete payload:** ```json { "event_details": { @@ -184,6 +186,17 @@ When a memory event occurs, Mem0 sends an HTTP POST request to your webhook URL } ``` +**Memory categorize payload:** +```json +{ + "event_details": { + "event": "CATEGORIZE", + "memory_id": "a1b2c3d4-e5f6-4g7h-8i9j-k0l1m2n3o4p5", + "categories": ["hobbies", "travel"] + } +} +``` + ## Best Practices 1. **Implement Retry Logic**: Ensure your webhook endpoint can handle temporary failures.