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

# Create a webhook subscription

> Requires `webhooks:write`. 



## OpenAPI

````yaml /openapi.json post /webhooks
openapi: 3.0.3
info:
  title: Visito M2M API
  version: 1.0.0
  description: >-
    Tenant-scoped server-to-server API for channels, conversations, commerce,
    custom AI tools, and WhatsApp templates. Send operations are asynchronous
    and return queued acknowledgements. Expansion adds conversation controls,
    knowledge, sales opportunities, delivery status, reporting, and signed
    webhooks.
servers:
  - url: https://platform-api.visitoai.com/m2m/v1
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Channels
  - name: Conversations
  - name: Commerce
  - name: Custom tools
  - name: WhatsApp templates
  - name: Properties
  - name: Knowledge
  - name: Sales CRM
  - name: Delivery
  - name: Reporting
  - name: Webhooks
paths:
  /webhooks:
    post:
      tags:
        - Webhooks
      summary: Create a webhook subscription
      description: 'Requires `webhooks:write`. '
      operationId: m2mPostWebhooks
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookInput'
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookCreated'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    WebhookInput:
      type: object
      properties:
        url:
          type: string
          format: uri
          maxLength: 2048
        events:
          type: array
          minItems: 1
          maxItems: 5
          items:
            type: string
            enum:
              - message.created
              - message.delivery.updated
              - conversation.handoff.updated
              - crm.opportunity.created
              - crm.opportunity.updated
      required:
        - url
        - events
      example:
        url: https://integrations.example.com/visito/webhooks
        events:
          - message.created
          - message.delivery.updated
    WebhookCreated:
      type: object
      properties:
        webhook:
          $ref: '#/components/schemas/Webhook'
        secret:
          type: string
          description: Returned once. Store securely.
    Webhook:
      type: object
      properties:
        subscriptionId:
          type: string
        url:
          type: string
        events:
          type: array
          items:
            type: string
            enum:
              - message.created
              - message.delivery.updated
              - conversation.handoff.updated
              - crm.opportunity.created
              - crm.opportunity.updated
        active:
          type: boolean
        createdAt:
          type: string
        updatedAt:
          type: string
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: M2M_AUTH_INSUFFICIENT_SCOPE
            message:
              type: string
            details:
              type: object
              additionalProperties: true
      example:
        error:
          code: M2M_AUTH_INSUFFICIENT_SCOPE
          message: M2M credential does not have required scope.
          details:
            requiredScopes:
              - conversations:write
            missingScopes:
              - conversations:write
  responses:
    Error:
      description: Structured error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Visito M2M API key
      description: Server-side tenant-scoped credential created from Build > API Keys.

````