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

# Atualizar webhook

> Atualiza `url` e/ou `event_types`. `event_types` é obrigatório no PATCH
(substitui a lista inteira). Não regenera o secret.




## OpenAPI

````yaml /openapi.yaml patch /api/public/v1/webhooks/{id}
openapi: 3.1.0
info:
  title: aidesk Public API
  version: 1.0.0
  summary: API pública para envio de mensagens, consulta de status e webhooks
  description: >
    Base oficial: `https://api.aideskbr.com`


    Autenticação com API key (`ak_live_...`). A organização é resolvida pela key
    —

    não envie `organization_id` nestas rotas.
  contact:
    name: aidesk
    url: https://developers.aideskbr.com
servers:
  - url: https://api.aideskbr.com
    description: Produção
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Health
    description: Verificação de autenticação e escopos
  - name: Messages
    description: Envio e consulta de mensagens
  - name: Webhooks
    description: Endpoints para receber eventos de delivery
paths:
  /api/public/v1/webhooks/{id}:
    patch:
      tags:
        - Webhooks
      summary: Atualizar webhook
      description: |
        Atualiza `url` e/ou `event_types`. `event_types` é obrigatório no PATCH
        (substitui a lista inteira). Não regenera o secret.
      operationId: updateWebhook
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateWebhookRequest'
      responses:
        '200':
          description: Atualizado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookEndpoint'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    UpdateWebhookRequest:
      type: object
      required:
        - event_types
      properties:
        url:
          type: string
          format: uri
        event_types:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/WebhookEventType'
    WebhookEndpoint:
      type: object
      properties:
        id:
          type: string
          format: uuid
        url:
          type: string
          format: uri
        status:
          type: string
          examples:
            - healthy
        event_types:
          type: array
          items:
            $ref: '#/components/schemas/WebhookEventType'
        created_at:
          type: string
          format: date-time
    WebhookEventType:
      type: string
      enum:
        - message.sent
        - message.delivered
        - message.read
        - message.failed
    ErrorEnvelope:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              examples:
                - api_key_required
                - rate_limited
                - idempotency_key_reused
            message:
              type: string
  responses:
    BadRequest:
      description: Validação / janela 24h / mídia inválida
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Unauthorized:
      description: API key ausente, inválida, revogada ou expirada
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            missing:
              value:
                error:
                  code: api_key_required
                  message: API key ausente
    Forbidden:
      description: Scope ou canal não permitido
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            scope:
              value:
                error:
                  code: missing_scope
                  message: Scope insuficiente
    NotFound:
      description: Recurso inexistente ou fora da org da key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            message:
              value:
                error:
                  code: message_not_found
                  message: Mensagem não encontrada
    RateLimited:
      description: Rate limit excedido
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          example:
            error:
              code: rate_limited
              message: Rate limit exceeded
  headers:
    Retry-After:
      description: Segundos para retry (em 429)
      schema:
        type: integer
    X-RateLimit-Limit:
      description: Limite do bucket na janela atual
      schema:
        type: integer
    X-RateLimit-Remaining:
      description: Restante no bucket
      schema:
        type: integer
    X-RateLimit-Reset:
      description: Unix timestamp do reset
      schema:
        type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: ak_live
      description: 'Authorization: Bearer ak_live_<secret>'
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: 'Alternativa ao Bearer — X-Api-Key: ak_live_<secret>'

````