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

# Register a new webhook



## OpenAPI

````yaml /api-reference/openapi.json post /api/webhooks
openapi: 3.0.3
info:
  title: Polymorfa WhatsApp API
  version: 0.0.0
  description: >-
    Public Polymorfa REST API for sessions, messaging, media, webhooks,
    campaigns, templates, client tokens, widgets, and bridge routing.
  contact:
    name: Polymorfa API
    url: https://docs.polymorfa.com
servers:
  - url: https://api.polymorfa.com
security:
  - BearerAuth: []
paths:
  /api/webhooks:
    post:
      tags:
        - Webhooks
      summary: Register a new webhook
      operationId: createWebhook
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWebhookRequest'
      responses:
        '201':
          description: Webhook created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateWebhookResponse'
        '400':
          description: Bad request — request body or params failed validation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Authenticated but not permitted (missing scope or rule violation)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    CreateWebhookRequest:
      type: object
      properties:
        session:
          type: string
        url:
          type: string
          format: uri
        events:
          type: array
          items:
            type: string
        hmacKey:
          type: string
        retries:
          $ref: '#/components/schemas/RetryConfig'
        headers:
          type: array
          items:
            $ref: '#/components/schemas/WebhookHeader'
        format:
          type: string
          enum:
            - native
            - meta
          description: >-
            "native" (default) = Polymorfa event envelope. "meta" = Meta Cloud
            API webhook shape (object/entry/changes/value), signed with
            X-Hub-Signature-256.
      required:
        - url
    CreateWebhookResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/Webhook'
      required:
        - success
        - data
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
        docs:
          type: string
          description: URL to the documentation for this error
      required:
        - error
    RetryConfig:
      type: object
      properties:
        attempts:
          type: integer
          minimum: 0
        delaySeconds:
          type: integer
          minimum: 0
        policy:
          type: string
          description: linear, exponential, or constant
      required:
        - attempts
        - delaySeconds
        - policy
    WebhookHeader:
      type: object
      properties:
        name:
          type: string
        value:
          type: string
      required:
        - name
        - value
    Webhook:
      type: object
      properties:
        id:
          type: string
        tenantId:
          type: string
        session:
          type: string
        url:
          type: string
        events:
          type: array
          items:
            type: string
        retries:
          $ref: '#/components/schemas/RetryConfig'
        headers:
          type: array
          items:
            $ref: '#/components/schemas/WebhookHeader'
        enabled:
          type: boolean
        format:
          type: string
          enum:
            - native
            - meta
        createdAt:
          type: string
      required:
        - id
        - tenantId
        - url
        - events
        - retries
        - headers
        - enabled
        - createdAt
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Polymorfa organization key (titan_ prefix), project token (titan_pt_
        prefix), or client token (titan_ct_ prefix), where the operation permits
        that audience.

````