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

# Create a webhook endpoint

> Subscribes an https URL on a public host to events, as Developers → Webhooks does. The answer carries the endpoint's `id`, to delete it with, and its signing `secret`, which is shown this once and never again. The endpoint is the key's maker's, and sends while they are an owner or admin. Each call adds one: to resubscribe, delete the old one.



## OpenAPI

````yaml /api-reference/openapi.json post /webhooks
openapi: 3.1.0
info:
  title: Wiredesk API
  version: 1.0.0
  description: >-
    Read and change a Wiredesk workspace: agents, conversations, contacts, leads
    and knowledge, and talk to an agent. Authenticate with an API key from
    Developers → API keys. Every response carries an x-request-id header, which
    Developers → Logs finds the request by.
servers:
  - url: https://wiredesk.ai/api/v1
security:
  - bearerAuth: []
tags:
  - name: Agents
    description: 'The workspace''s agents: their name, greeting, instructions and channels.'
  - name: Chat
    description: >-
      Send a customer's message to an agent and get its reply, without the chat
      widget.
  - name: Knowledge
    description: >-
      What an agent answers from: pasted text and websites, and the sources
      added in the dashboard.
  - name: Conversations
    description: Conversations on every channel, and their transcripts.
  - name: Contacts
    description: The people the agents talk to, by phone number, email or your own id.
  - name: Leads
    description: Leads the agents captured.
  - name: Webhooks
    description: 'Where Wiredesk sends events: subscribe a URL, list them, unsubscribe.'
  - name: Onboarding
    description: >-
      Agent-first onboarding: an AI agent builds a trial agent from a website,
      and a person claims it.
  - name: Workspace
    description: Who a key is, and the workspace at a glance.
  - name: Analytics
    description: 'How the agents are doing: the numbers on the dashboard''s Analytics page.'
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Create a webhook endpoint
      description: >-
        Subscribes an https URL on a public host to events, as Developers →
        Webhooks does. The answer carries the endpoint's `id`, to delete it
        with, and its signing `secret`, which is shown this once and never
        again. The endpoint is the key's maker's, and sends while they are an
        owner or admin. Each call adds one: to resubscribe, delete the old one.
      operationId: create_webhook_endpoint
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  maxLength: 2000
                  description: 'Where to send events: https, on a public host.'
                events:
                  type: array
                  minItems: 1
                  items:
                    type: string
                    enum:
                      - message.created
                      - handover.requested
                      - lead.captured
                      - conversation.ended
                  description: The events to send it.
                description:
                  type: string
                  maxLength: 120
                  description: What it is for, shown in the dashboard.
              required:
                - url
                - events
      responses:
        '201':
          description: Created, with its signing secret
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    allOf:
                      - $ref: '#/components/schemas/WebhookEndpoint'
                      - type: object
                        required:
                          - secret
                        properties:
                          secret:
                            type: string
                            description: >-
                              `whsec_…`: verify each delivery's
                              `webhook-signature` header with it. Only returned
                              here.
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '400':
          description: 'Invalid request: not https, not a public host, or an unknown event'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '403':
          description: >-
            Read-only key, or the workspace has 10 endpoints already
            (`webhook_limit`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '409':
          description: An unclaimed onboarding trial's workspace (`conflict`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
        '503':
          description: Webhooks are not set up on this server (`not_configured`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          headers:
            x-request-id:
              $ref: '#/components/headers/RequestId'
components:
  schemas:
    WebhookEndpoint:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          const: webhook_endpoint
        url:
          type: string
          format: uri
        description:
          anyOf:
            - type: string
            - type: 'null'
        events:
          type: array
          items:
            type: string
            enum:
              - message.created
              - handover.requested
              - lead.captured
              - conversation.ended
        enabled:
          type: boolean
          description: >-
            False when it was switched off: by hand, after failing for days, or
            because whoever added it is no longer an owner or admin.
        disabled_reason:
          anyOf:
            - type: string
            - type: 'null'
          description: Why it was switched off, when Wiredesk did it.
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - invalid_request
                - unauthorized
                - spend_cap_reached
                - read_only_key
                - channel_disabled
                - knowledge_full
                - agent_limit
                - webhook_limit
                - not_found
                - method_not_allowed
                - already_exists
                - conflict
                - rate_limited
                - internal_error
                - upstream_error
                - not_configured
            message:
              type: string
          additionalProperties: true
  headers:
    RequestId:
      description: >-
        A unique id for this request, on every response including errors.
        Developers → Logs finds the request by it; quote it to support.
      schema:
        type: string
        format: uuid
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An API key, `wd_...`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.