Get 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")

# Get all webhooks
webhooks = client.get_webhooks(project_id="your_project_id")
print(webhooks)

# 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)

JavaScript

// To use the JavaScript SDK, install the package:
// npm i mem0ai

import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key' });

// Get all webhooks
client.getWebhooks('your_project_id')
  .then(webhooks => console.log(webhooks))
  .catch(err => console.error(err));

// Create a webhook
client.createWebhook({
  url: 'https://your-webhook-url.com',
  name: 'My Webhook',
  project_id: 'your_project_id',
  event_types: ['memory:add']
})
  .then(webhook => console.log(webhook))
  .catch(err => console.error(err));

cURL

# Get all webhooks
curl --request GET \
  --url 'https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/' \
  --header 'Authorization: Token your-api-key'

# Create a webhook
curl --request POST \
  --url 'https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/' \
  --header 'Authorization: Token your-api-key' \
  --header 'Content-Type: application/json' \
  --data '{
    "url": "https://your-webhook-url.com",
    "name": "My Webhook",
    "event_types": ["memory:add"]
  }'

PHP

<?php

$curl = curl_init();

// Get all webhooks
curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["Authorization: Token your-api-key"],
]);
$response = curl_exec($curl);

// Create a webhook
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);

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {
    // Get all webhooks
    req, _ := http.NewRequest("GET", "https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/", nil)
    req.Header.Add("Authorization", "Token your-api-key")

res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)
    fmt.Println(string(body))

// Create a webhook
    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))
}

Java

// Get all webhooks
HttpResponse<String> response = Unirest.get("https://api.mem0.ai/api/v1/webhooks/your_project_id/webhook/")
  .header("Authorization", "Token your-api-key")
  .asString();

// 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();

Ruby

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::Get.new(url)
request["Authorization"] = '<api-key>'

response = http.request(request)
puts response.read_body

Response Formats

Success Response

[
  {
    "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 Response

{
  "error": "You don't have access to this project"
}

Authorizations

Authorization

API key authentication. Prefix your Mem0 API key with 'Token '. Example: 'Token your_api_key'

Path Parameters

Additional Information

Response Details