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

# Criar webhook

> Cadastra um webhook na instância. Até 5 por instância.



## OpenAPI

````yaml /pt-br/api-reference/openapi.json post /instances/{id}/webhooks
openapi: 3.1.0
info:
  title: Zapfy API
  description: >-
    API de WhatsApp multi-tenant. Envie mensagens e gerencie webhooks por uma
    superfície única.
  version: 1.0.0
servers:
  - url: https://api.zapfy.io/v1
security:
  - accountToken: []
paths:
  /instances/{id}/webhooks:
    parameters:
      - $ref: '#/components/parameters/InstanceId'
    post:
      tags:
        - Webhooks
      summary: Criar webhook
      description: Cadastra um webhook na instância. Até 5 por instância.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookInput'
      responses:
        '201':
          description: Webhook criado.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Webhook'
        '401':
          $ref: '#/components/responses/Error'
        '404':
          $ref: '#/components/responses/Error'
        '409':
          $ref: '#/components/responses/Error'
components:
  parameters:
    InstanceId:
      name: id
      in: path
      required: true
      description: ID da instância.
      schema:
        type: string
  schemas:
    WebhookInput:
      type: object
      required:
        - url
        - events
      properties:
        url:
          type: string
          format: uri
          example: https://seu-app.com/webhooks
          description: URL HTTPS que receberá os eventos via POST.
        events:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/WebhookEvent'
          example:
            - MESSAGE_RECEIVED
            - MESSAGE_STATUS
          description: Eventos que disparam o webhook.
        enabled:
          type: boolean
          default: true
          description: 'Se o webhook está ativo. Padrão: `true`.'
    Webhook:
      type: object
      properties:
        id:
          type: string
          example: 01J9Z...
          description: Identificador do webhook.
        url:
          type: string
          example: https://seu-app.com/webhooks
          description: URL HTTPS que recebe os eventos.
        events:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEvent'
          description: Eventos assinados por este webhook.
        enabled:
          type: boolean
          example: true
          description: Se o webhook está ativo.
        createdAt:
          type: string
          format: date-time
          description: Data de criação (ISO 8601).
    WebhookEvent:
      type: string
      enum:
        - MESSAGE_RECEIVED
        - MESSAGE_SENT
        - MESSAGE_STATUS
        - CONNECTION_UPDATE
        - QRCODE_UPDATED
      description: >-
        Tipo de evento. `MESSAGE_RECEIVED` = mensagem recebida; `MESSAGE_SENT` =
        mensagem enviada pela instância; `MESSAGE_STATUS` = mudança de status de
        entrega/leitura; `CONNECTION_UPDATE` = mudança na conexão da instância;
        `QRCODE_UPDATED` = novo QR Code para parear.
  responses:
    Error:
      description: Erro.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: Instance not found
  securitySchemes:
    accountToken:
      type: http
      scheme: bearer
      description: Token de conta (`zpfy_acct_...`) — gerencia instâncias e webhooks.

````