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

# Create Webhook Endpoint

> Register a new URL to receive webhook events.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.thinnest.ai/webhooks/endpoints \
    -H "Authorization: Bearer $THINNESTAI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
    "url": "https://your-app.com/webhooks/thinnestai",
    "event_types": [
      "chat.message.completed",
      "voice.call.ended"
    ],
    "description": "Production webhook",
    "max_retries": 3,
    "timeout_ms": 5000
  }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.thinnest.ai/webhooks/endpoints"
  headers = {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
      "Content-Type": "application/json",
  }

  payload = {
    "url": "https://your-app.com/webhooks/thinnestai",
    "event_types": [
      "chat.message.completed",
      "voice.call.ended"
    ],
    "description": "Production webhook",
    "max_retries": 3,
    "timeout_ms": 5000
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("https://api.thinnest.ai/webhooks/endpoints", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + "YOUR_THINNESTAI_API_KEY",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
    "url": "https://your-app.com/webhooks/thinnestai",
    "event_types": [
      "chat.message.completed",
      "voice.call.ended"
    ],
    "description": "Production webhook",
    "max_retries": 3,
    "timeout_ms": 5000
  }),
  });

  const data = await response.json();
  console.log(data);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "fmt"
      "io"
      "net/http"
  )

  func main() {
      payload := []byte(`{
    "url": "https://your-app.com/webhooks/thinnestai",
    "event_types": [
      "chat.message.completed",
      "voice.call.ended"
    ],
    "description": "Production webhook",
    "max_retries": 3,
    "timeout_ms": 5000
  }`)
      req, _ := http.NewRequest("POST", "https://api.thinnest.ai/webhooks/endpoints", bytes.NewBuffer(payload))
      req.Header.Set("Authorization", "Bearer YOUR_THINNESTAI_API_KEY")
      req.Header.Set("Content-Type", "application/json")

      resp, err := http.DefaultClient.Do(req)
      if err != nil { panic(err) }
      defer resp.Body.Close()
      body, _ := io.ReadAll(resp.Body)
      fmt.Println(string(body))
  }
  ```
</RequestExample>

***

## Request Body

<ParamField body="url" type="string" required>
  HTTPS URL to receive events
</ParamField>

<ParamField body="event_types" type="array" required>
  List of event types to subscribe to
</ParamField>

<ParamField body="agent_id" type="integer" default="null">
  Filter events to a specific agent (null = all agents)
</ParamField>

<ParamField body="description" type="string" default="null">
  Human-readable description
</ParamField>

<ParamField body="max_retries" type="integer" default="3">
  Number of retry attempts (0–5)
</ParamField>

<ParamField body="timeout_ms" type="integer" default="5000">
  Request timeout in milliseconds
</ParamField>

## Response

<ResponseExample>
  ```json 200 theme={null}
  {
    "status": "success",
    "endpoint": {
      "id": 1,
      "url": "https://your-app.com/webhooks/thinnestai",
      "secret": "a1b2c3d4e5f6...",
      "event_types": ["chat.message.completed", "voice.call.ended"],
      "agent_id": null,
      "description": "Production webhook",
      "is_active": true,
      "max_retries": 3,
      "timeout_ms": 5000,
      "created_at": "2026-03-16T10:00:00"
    }
  }
  ```
</ResponseExample>

The `secret` is only returned on creation. Save it immediately — it cannot be retrieved later.

## Errors

| Status | Description                                                               |
| ------ | ------------------------------------------------------------------------- |
| `400`  | Invalid URL (not HTTPS), invalid event types, or max 20 endpoints reached |
| `401`  | Missing or invalid API key                                                |


## OpenAPI

````yaml POST /webhooks/endpoints
openapi: 3.1.0
info:
  title: ThinnestAI API
  description: REST API for ThinnestAI — build, deploy, and manage AI agents.
  version: 1.0.0
servers: []
security: []
tags:
  - name: Agents
    description: Create, configure, and manage AI agents
  - name: Chat
    description: Send messages and get AI responses from agents
  - name: Knowledge
    description: Upload files, URLs, and text to agent knowledge bases
  - name: Sessions
    description: View and manage chat sessions and message history
  - name: Voice
    description: Start and manage voice call sessions
  - name: Recordings
    description: Manage voice call recordings
  - name: Campaigns
    description: Create and run automated outreach campaigns
  - name: Webhooks
    description: Register webhook endpoints for real-time event notifications
  - name: Evaluations
    description: Run and track agent evaluation benchmarks
  - name: Analytics
    description: Query agent performance metrics and usage data
  - name: Agent Tools
    description: View and manage tools attached to agents
  - name: BYOK
    description: >-
      Bring Your Own Key — manage credentials for LLM/STT/TTS providers,
      telephony BYOK (Vobiz/Twilio/Plivo/Exotel/Telnyx), and tool-specific BYOK
      (Razorpay UPI Payment, Surepass Aadhaar eKYC)
paths:
  /webhooks/endpoints:
    post:
      tags:
        - Webhooks
      summary: Create Endpoint
      description: Register a new webhook endpoint.
      operationId: create_endpoint_webhooks_endpoints_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEndpointRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CreateEndpointRequest:
      properties:
        url:
          type: string
          title: Url
        event_types:
          items:
            type: string
          type: array
          title: Event Types
        agent_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Agent Id
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        max_retries:
          type: integer
          title: Max Retries
          default: 3
        timeout_ms:
          type: integer
          title: Timeout Ms
          default: 5000
      type: object
      required:
        - url
        - event_types
      title: CreateEndpointRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````