improvement: Update webhook docs. (#2249)

This commit is contained in:
Taranjeet Singh
2025-02-23 16:10:21 -08:00
committed by GitHub
parent 7f25caba47
commit 7443e58a9d

View File

@@ -7,14 +7,13 @@ iconType: "solid"
## Overview
Webhooks allow you to receive real-time notifications when memory events occur in your Mem0 project. Webhooks are configured at the project level, meaning each webhook is associated with a specific project and will only receive events 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, or deleted.
## Managing Webhooks
### Create Webhook
Create a new webhook for your project. The webhook will only receive events from the specified project:
Create a webhook for your project; it will receive events only from that project:
<CodeGroup>
```python Python
@@ -63,7 +62,7 @@ console.log(webhook);
### Get Webhooks
Retrieve all webhooks configured for your project:
Retrieve all webhooks for your project:
<CodeGroup>
@@ -100,7 +99,7 @@ console.log(webhooks);
### Update Webhook
Modify an existing webhook's configuration. Use `webhook_id` to update the parameters of the webhook:
Update an existing webhooks configuration by specifying its `webhook_id`:
<CodeGroup>
@@ -136,7 +135,7 @@ console.log(updatedWebhook);
### Delete Webhook
Webhook can be deleted by using the `webhook_id` of the webhook:
Delete a webhook by providing its `webhook_id`:
<CodeGroup>
@@ -164,13 +163,13 @@ console.log(response);
Mem0 supports the following event types for webhooks:
- `memory_add`: Triggered when a new memory is added.
- `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.
## Webhook Payload
When a memory event occurs in your project, Mem0 sends a POST request to your webhook URL with the following example payload structure:
When a memory event occurs, Mem0 sends an HTTP POST request to your webhook URL with the following payload:
```json
{
@@ -186,13 +185,13 @@ When a memory event occurs in your project, Mem0 sends a POST request to your we
## Best Practices
1. **Implement Retry Logic**: Your webhook endpoint should be able to handle temporary failures and implement appropriate retry mechanisms.
1. **Implement Retry Logic**: Ensure your webhook endpoint can handle temporary failures by implementing retry logic.
2. **Verify Webhook Source**: Implement security measures to verify that webhook requests are coming from Mem0.
2. **Verify Webhook Source**: Implement security measures to verify that webhook requests originate from Mem0.
3. **Process Events Asynchronously**: Handle webhook events asynchronously to prevent timeouts and ensure reliable processing.
3. **Process Events Asynchronously**: Process webhook events asynchronously to avoid timeouts and ensure reliable handling.
4. **Monitor Webhook Health**: Regularly check your webhook logs to ensure proper functionality and handle any delivery failures.
4. **Monitor Webhook Health**: Regularly review your webhook logs to ensure functionality and promptly address any delivery failures.
If you have any questions, please feel free to reach out to us using one of the following methods: