> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mem0.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Webhook

> Create a new webhook for a project to receive real-time notifications about memory events.



## OpenAPI

````yaml post /api/v1/webhooks/projects/{project_id}/
openapi: 3.0.1
info:
  title: Mem0 API Docs
  description: mem0.ai API Docs
  contact:
    email: support@mem0.ai
  license:
    name: Apache 2.0
  version: v1
servers:
  - url: https://api.mem0.ai/
security:
  - ApiKeyAuth: []
paths:
  /api/v1/webhooks/projects/{project_id}/:
    post:
      tags:
        - webhooks
      summary: Create Webhook
      description: Create a new webhook for a specific project
      operationId: create_webhook
      parameters:
        - name: project_id
          in: path
          required: true
          description: Unique identifier of the project.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - url
              properties:
                name:
                  type: string
                  description: Name of the webhook
                url:
                  type: string
                  description: URL endpoint for the webhook.
                event_types:
                  type: array
                  items:
                    type: string
                    enum:
                      - memory:add
                      - memory:update
                      - memory:delete
                      - memory:categorize
                  description: List of event types to subscribe to.
                is_active:
                  type: boolean
                  description: Whether the webhook is active
                project_id:
                  type: string
                  description: Unique identifier of the project.
      responses:
        '201':
          description: Webhook created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  webhook_id:
                    type: string
                  name:
                    type: string
                  url:
                    type: string
                  event_types:
                    type: array
                    items:
                      type: string
                  is_active:
                    type: boolean
                  project:
                    type: string
                  created_at:
                    type: string
                    format: date-time
                  updated_at:
                    type: string
                    format: date-time
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '403':
          description: Unauthorized access
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: You don't have access to this project
      x-code-samples:
        - lang: Python
          source: |-
            # 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)
        - lang: JavaScript
          source: |-
            // 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));
        - lang: cURL
          source: >-
            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"]
                 }'
        - lang: PHP
          source: |-
            <?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;
        - lang: Go
          source: |-
            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))
            }
        - lang: Java
          source: >-
            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());
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        API key authentication. Prefix your Mem0 API key with 'Token '. Example:
        'Token your_api_key'

````