Python
# To use the Python SDK, install the package:
# pip install mem0ai
from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")
# Create a webhook
webhook = client.create_webhook(
url="https://your-webhook-url.com",
name="My Webhook",
project_id="your_project_id",
event_types=["memory:add", "memory:categorize"]
)
print(webhook)// To use the JavaScript SDK, install the package:
// npm i mem0ai
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
// Create a webhook
client.createWebhook({
url: "https://your-webhook-url.com",
name: "My Webhook",
project_id: "your_project_id",
event_types: ["memory:add"]
})
.then(response => console.log('Create webhook response:', response))
.catch(error => console.error(error));curl -X POST "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-webhook-url.com",
"name": "My Webhook",
"event_types": ["memory:add"]
}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://your-webhook-url.com",
"name" => "My Webhook",
"event_types" => ["memory:add"]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Token your-api-key",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
payload := strings.NewReader(`{
"url": "https://your-webhook-url.com",
"name": "My Webhook",
"event_types": ["memory:add"]
}`)
req, _ := http.NewRequest("POST", "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/", payload)
req.Header.Add("Authorization", "Token your-api-key")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}import com.konghq.unirest.http.HttpResponse;
import com.konghq.unirest.http.Unirest;
// Create a webhook
HttpResponse<String> response = Unirest.post("https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/")
.header("Authorization", "Token your-api-key")
.header("Content-Type", "application/json")
.body("{
\"url\": \"https://your-webhook-url.com\",
\"name\": \"My Webhook\",
\"event_types\": [\"memory:add\"]
}")
.asString();
System.out.println(response.getBody());require 'uri'
require 'net/http'
url = URI("https://api.mem0.ai/api/v1/webhooks/projects/{project_id}/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"name\": \"<string>\",\n \"event_types\": [],\n \"is_active\": true,\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"webhook_id": "<string>",
"name": "<string>",
"url": "<string>",
"event_types": [
"<string>"
],
"is_active": true,
"project": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>"
}{
"error": "You don't have access to this project"
}Webhooks
Create Webhook
Create a new webhook for a project to receive real-time notifications about memory events.
POST
/
api
/
v1
/
webhooks
/
projects
/
{project_id}
/
Python
# To use the Python SDK, install the package:
# pip install mem0ai
from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")
# Create a webhook
webhook = client.create_webhook(
url="https://your-webhook-url.com",
name="My Webhook",
project_id="your_project_id",
event_types=["memory:add", "memory:categorize"]
)
print(webhook)// To use the JavaScript SDK, install the package:
// npm i mem0ai
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
// Create a webhook
client.createWebhook({
url: "https://your-webhook-url.com",
name: "My Webhook",
project_id: "your_project_id",
event_types: ["memory:add"]
})
.then(response => console.log('Create webhook response:', response))
.catch(error => console.error(error));curl -X POST "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/" \
-H "Authorization: Token your-api-key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-webhook-url.com",
"name": "My Webhook",
"event_types": ["memory:add"]
}'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
"url" => "https://your-webhook-url.com",
"name" => "My Webhook",
"event_types" => ["memory:add"]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Token your-api-key",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
payload := strings.NewReader(`{
"url": "https://your-webhook-url.com",
"name": "My Webhook",
"event_types": ["memory:add"]
}`)
req, _ := http.NewRequest("POST", "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/", payload)
req.Header.Add("Authorization", "Token your-api-key")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}import com.konghq.unirest.http.HttpResponse;
import com.konghq.unirest.http.Unirest;
// Create a webhook
HttpResponse<String> response = Unirest.post("https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/")
.header("Authorization", "Token your-api-key")
.header("Content-Type", "application/json")
.body("{
\"url\": \"https://your-webhook-url.com\",
\"name\": \"My Webhook\",
\"event_types\": [\"memory:add\"]
}")
.asString();
System.out.println(response.getBody());require 'uri'
require 'net/http'
url = URI("https://api.mem0.ai/api/v1/webhooks/projects/{project_id}/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"name\": \"<string>\",\n \"event_types\": [],\n \"is_active\": true,\n \"project_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"webhook_id": "<string>",
"name": "<string>",
"url": "<string>",
"event_types": [
"<string>"
],
"is_active": true,
"project": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": "<string>"
}{
"error": "You don't have access to this project"
}Authorizations
API key authentication. Prefix your Mem0 API key with 'Token '. Example: 'Token your_api_key'
Path Parameters
Unique identifier of the project.
Body
application/json
URL endpoint for the webhook.
Name of the webhook
List of event types to subscribe to.
Available options:
memory:add, memory:update, memory:delete, memory:categorize Whether the webhook is active
Unique identifier of the project.
Was this page helpful?
⌘I