Create Webhook - Mem0
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
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("{\n \"url\": \"https://your-webhook-url.com\",\n \"name\": \"My Webhook\",\n \"event_types\": [\"memory:add\"]\n }")
.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
Authorizations
Authorization
- Type: Header
- Required: Yes
- Description: API key authentication. Prefix your Mem0 API key with 'Token '. Example: 'Token your_api_key'
Path Parameters
- project_id: Unique identifier of the project. (string, required)
Body
- url: URL endpoint for the webhook. (string, required)
- name: Name of the webhook. (string)
- event_types: List of event types to subscribe to. (enum
[], required) - is_active: Whether the webhook is active. (boolean)
- project_id: Unique identifier of the project. (string)
Response
- Status Code: 201
- Content-Type: application/json
- Description: Webhook created successfully
- Response Structure:
{
"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"
}