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

> ## Agent Instructions
> Integrating Pilot Status end to end? Follow https://docs.pilotstatus.com.br/guides/integrate-with-ai.md (pt-BR: https://docs.pilotstatus.com.br/pt-BR/guides/integrate-with-ai.md). No step requires contacting support: every credential is shown in the dashboard or in an API response, and a lost one is regenerated, not recovered.
> Webhook signing secret: shown ONCE in the Signing secret window right after creating the webhook on /webhooks, and in the `secret` field of the POST /v1/webhooks response (MCP: webhooks_create). Lost it: Edit Webhook → Generate a new secret, POST /v1/webhooks/{id}/rotate-secret, or webhooks_rotate_secret (the old one stops working at once). Verify `x-pilot-status-signature` = hex HMAC-SHA256 of the raw request body keyed with that secret.
> Meta verify token (number connected with the user's own Meta app credentials): Meta Number Created! window after connecting, then the number's card on Numbers (workspace Owner), or webhook.verifyToken in the POST /v1/numbers/meta response. It is not the webhook signing secret.
> REST auth: `x-api-key: ps_...` header, never Authorization: Bearer. MCP: https://mcp.pilotstatus.com.br/mcp (148 tools, OAuth 2.1 or x-api-key); Code Mode: https://mcp.pilotstatus.com.br/code. Destructive MCP tools return a preview and a confirm_token: show the preview and call again only after the user's explicit yes. Over OAuth, revealing or creating ps_ API keys is workspace Owner only.

# Crear webhook

> Crea un webhook suscrito a UN número de WhatsApp. El número viene del alcance de la clave (clave de número), del header `x-whatsapp-number-id` o del campo `whatsappNumberId` del cuerpo; si el cuerpo contradice el alcance de la clave → `400 NUMBER_MISMATCH`; sin número resoluble → `400 NUMBER_REQUIRED`; número de otro workspace → `404 NUMBER_NOT_FOUND`. `events` elige qué se entrega: una lista vacía/omitida NO despacha NADA (no hay un "suscribirse a todo" implícito; usa `"*"` para todo, es decir, todos los eventos excepto el opcional `lead.received`, que debe listarse por nombre) y los eventos que el proveedor del número no puede emitir se descartan en silencio. Los campos desconocidos del cuerpo se ignoran.

**El `201` trae el `secret` de firma en claro, junto con `hasSecret: true`: la única respuesta que lo hace, aparte de `rotate-secret`.** Guárdalo de inmediato (la respuesta se envía con `Cache-Control: no-store`). Por OAuth/MCP la creación se registra primero en la registro de auditoría; si ese registro no se puede escribir, el webhook se crea igual, pero `secret` vuelve `null` con `secretWithheld: true`, `secretWithheldReason` y `secretWithheldCode: "OAUTH_SECRET_AUDIT_UNAVAILABLE"`; rótalo para obtener uno.

Límites: la misma `url` dos veces en el mismo número → `409 WEBHOOK_DUPLICATE`; como máximo 50 webhooks por workspace → `409 WEBHOOK_LIMIT_REACHED`.

Permisos: `webhooks:manage` (Owner o Admin con una clave de cuenta o token OAuth/MCP).



## OpenAPI

````yaml openapi.es.json POST /v1/webhooks
openapi: 3.1.0
info:
  title: Pilot Status API
  version: 1.0.0
  license:
    name: Pilot Status Terms of Service
    url: https://pilotstatus.com.br/terms
  description: >-
    API REST pública de Pilot Status. Autentícate con el encabezado `x-api-key:
    ps_...` (o `x-api-key-id`). URL base: https://pilotstatus.com.br
servers:
  - url: https://pilotstatus.com.br
security:
  - apiKey: []
  - apiKeyId: []
paths:
  /v1/webhooks:
    post:
      tags:
        - Webhooks
      summary: Crear webhook
      description: >-
        Crea un webhook suscrito a UN número de WhatsApp. El número viene del
        alcance de la clave (clave de número), del header `x-whatsapp-number-id`
        o del campo `whatsappNumberId` del cuerpo; si el cuerpo contradice el
        alcance de la clave → `400 NUMBER_MISMATCH`; sin número resoluble → `400
        NUMBER_REQUIRED`; número de otro workspace → `404 NUMBER_NOT_FOUND`.
        `events` elige qué se entrega: una lista vacía/omitida NO despacha NADA
        (no hay un "suscribirse a todo" implícito; usa `"*"` para todo, es
        decir, todos los eventos excepto el opcional `lead.received`, que debe
        listarse por nombre) y los eventos que el proveedor del número no puede
        emitir se descartan en silencio. Los campos desconocidos del cuerpo se
        ignoran.


        **El `201` trae el `secret` de firma en claro, junto con `hasSecret:
        true`: la única respuesta que lo hace, aparte de `rotate-secret`.**
        Guárdalo de inmediato (la respuesta se envía con `Cache-Control:
        no-store`). Por OAuth/MCP la creación se registra primero en la registro
        de auditoría; si ese registro no se puede escribir, el webhook se crea
        igual, pero `secret` vuelve `null` con `secretWithheld: true`,
        `secretWithheldReason` y `secretWithheldCode:
        "OAUTH_SECRET_AUDIT_UNAVAILABLE"`; rótalo para obtener uno.


        Límites: la misma `url` dos veces en el mismo número → `409
        WEBHOOK_DUPLICATE`; como máximo 50 webhooks por workspace → `409
        WEBHOOK_LIMIT_REACHED`.


        Permisos: `webhooks:manage` (Owner o Admin con una clave de cuenta o
        token OAuth/MCP).
      operationId: post_webhooks
      parameters:
        - name: x-whatsapp-number-id
          in: header
          required: false
          description: >-
            Limita a un solo número (obligatorio para permisos OAuth por
            número).
          schema:
            type: string
          example: num_01HZX...
        - name: x-workspace-id
          in: header
          required: false
          schema:
            type: string
          description: >-
            Solo con una clave de cuenta (`ps_account_`): el workspace sobre el
            que actuar, de `GET /v1/workspaces`. Sin él, una clave de cuenta
            recibe `400 WORKSPACE_ID_REQUIRED`.
          example: cmh2a9z8y0002ws8example1q
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  description: >-
                    URL de destino, `http` o `https`. Algo que no es una URL →
                    `400 Validation error`; otro esquema, `localhost`, una IP de
                    loopback o privada, o un host sin punto → `400
                    INVALID_WEBHOOK_URL`. La misma URL dos veces en el mismo
                    número → `409 WEBHOOK_DUPLICATE`.
                  example: https://hooks.acme.com/whatsapp
                name:
                  type: string
                  description: >-
                    Nombre visible, hasta 100 caracteres (predeterminado: el
                    hostname de la URL).
                  example: n8n
                  maxLength: 100
                events:
                  type: array
                  items:
                    type: string
                  description: >-
                    Eventos a los que suscribirse (p. ej. ["message.received"]);
                    "*" = todos, excepto el opcional `lead.received`, que solo
                    se entrega cuando se lista por nombre. Vacío/omitido = no
                    despacha nada.
                  example:
                    - message.received
                    - message.delivered
                whatsappNumberId:
                  type: string
                  description: >-
                    Número de destino: solo se necesita con una clave de tenant
                    y sin header de número; con una clave de número debe
                    coincidir con el alcance (400 NUMBER_MISMATCH).
                  example: num_01HZX...
                deliveryTimeoutMs:
                  type:
                    - integer
                    - 'null'
                  minimum: 1000
                  maximum: 15000
                  description: >-
                    **Solo para el equipo de Pilot Status.** Plazo de entrega
                    por webhook en ms, entero 1000–15000; `null` lo borra
                    (vuelve al predeterminado de 10 s). Enviar la clave en
                    absoluto (`null` incluido) con cualquier otra credencial →
                    `403 DELIVERY_TIMEOUT_STAFF_ONLY`. Las claves `ps_` clásicas
                    nunca son del equipo.
              required:
                - url
      responses:
        '201':
          description: Crear webhook
          headers:
            Cache-Control:
              schema:
                type: string
              example: no-store
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Id del webhook.
                  tenantId:
                    type: string
                    description: Id del workspace.
                  name:
                    type: string
                    description: >-
                      Nombre visible. Vacío o ausente al crear/editar → el
                      hostname de la URL.
                  url:
                    type: string
                    description: >-
                      URL de destino (`http` o `https`; los hosts internos se
                      rechazan).
                  environment:
                    type: string
                    description: Siempre `LIVE` para webhooks creados mediante la API.
                  deliveryTimeoutMs:
                    type:
                      - integer
                      - 'null'
                    description: >-
                      Plazo de entrega por webhook en ms (1000–15000), o `null`
                      para el valor predeterminado de 10 s. Solo el equipo de
                      Pilot Status puede configurarlo.
                  active:
                    type: boolean
                    description: '`false` = desactivado por ti: no se entrega nada.'
                  events:
                    type: array
                    items:
                      type: string
                    description: >-
                      Eventos suscritos. Vacío = no se entrega nada; `"*"` =
                      todos los eventos excepto el opcional `lead.received`.
                  createdAt:
                    type: string
                    format: date-time
                  updatedAt:
                    type: string
                    format: date-time
                  hasSecret:
                    type: boolean
                    description: >-
                      `true` cuando las entregas están firmadas
                      (`x-pilot-status-signature`). El secreto en sí nunca se
                      devuelve en una lectura.
                  secret:
                    type:
                      - string
                      - 'null'
                    description: >-
                      El secreto de firma (64 caracteres hexadecimales), en
                      claro. **Se devuelve solo aquí y en `rotate-secret`.**
                      `null` cuando se retiene (ver `secretWithheld`).
                  secretWithheld:
                    type: boolean
                    description: >-
                      Presente (`true`) solo cuando, por OAuth/MCP, la creación
                      no se pudo escribir en la registro de auditoría: el
                      webhook SÍ se creó, pero su secreto no se devuelve. Llama
                      a `POST /v1/webhooks/{id}/rotate-secret` para obtener uno.
                  secretWithheldReason:
                    type: string
                    description: Explicación bilingüe, presente con `secretWithheld`.
                  secretWithheldCode:
                    type: string
                    description: >-
                      `OAUTH_SECRET_AUDIT_UNAVAILABLE`, presente con
                      `secretWithheld`.
              examples:
                created:
                  summary: Created
                  value:
                    id: wh_01HZX...
                    tenantId: tenant_01HZX...
                    name: n8n
                    url: https://hooks.acme.com/whatsapp
                    environment: LIVE
                    deliveryTimeoutMs: null
                    active: true
                    events:
                      - message.received
                    createdAt: '2026-07-03T12:00:00.000Z'
                    updatedAt: '2026-07-03T12:00:00.000Z'
                    hasSecret: true
                    secret: >-
                      9f2c4e6a8b0d1f3a5c7e9b1d3f5a7c9e2b4d6f8a0c1e3b5d7f9a1c3e5b7d9f1a
                secretWithheld:
                  summary: OAuth/MCP, audit unavailable
                  value:
                    id: wh_01HZX...
                    tenantId: tenant_01HZX...
                    name: n8n
                    url: https://hooks.acme.com/whatsapp
                    environment: LIVE
                    deliveryTimeoutMs: null
                    active: true
                    events:
                      - message.received
                    createdAt: '2026-07-03T12:00:00.000Z'
                    updatedAt: '2026-07-03T12:00:00.000Z'
                    hasSecret: true
                    secret: null
                    secretWithheld: true
                    secretWithheldReason: >-
                      The secret could not be recorded in the audit trail, so it
                      was not returned. Rotate it to obtain a new one | Não foi
                      possível registrar o segredo na auditoria, então ele não
                      foi devolvido. Rotacione-o para obter um novo
                    secretWithheldCode: OAUTH_SECRET_AUDIT_UNAVAILABLE
        '400':
          description: Solicitud inválida
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                  details:
                    type: object
              examples:
                validation:
                  summary: Schema validation failed (no `code`)
                  value:
                    error: Validation error
                    details:
                      formErrors: []
                      fieldErrors:
                        url:
                          - Must be a valid URL
                invalidBody:
                  summary: Body is not valid JSON
                  value:
                    error: >-
                      The request body is not valid JSON | O corpo da requisição
                      não é um JSON válido
                    code: INVALID_BODY
                notAnObject:
                  summary: JSON body is not an object
                  value:
                    error: >-
                      The request body must be a JSON object | O corpo da
                      requisição deve ser um objeto JSON
                    code: INVALID_BODY
                invalidUrl:
                  summary: >-
                    URL refused by shape (internal host, loopback, unsupported
                    scheme)
                  value:
                    error: 'URL de webhook recusada: host de loopback (localhost)'
                    code: INVALID_WEBHOOK_URL
                numberMismatch:
                  summary: Body `whatsappNumberId` differs from the key's number
                  value:
                    error: whatsappNumberId does not match the key's number scope
                    code: NUMBER_MISMATCH
                numberRequired:
                  summary: No number resolvable (tenant key, no body field, no header)
                  value:
                    error: >-
                      whatsappNumberId is required (body field or
                      x-whatsapp-number-id header)
                    code: NUMBER_REQUIRED
                workspaceIdRequired:
                  summary: Account key without `x-workspace-id`
                  value:
                    error: >-
                      An account API key must name the workspace to act on: send
                      the x-workspace-id header (a workspace id from GET
                      /v1/workspaces) | Uma API key de conta precisa indicar o
                      workspace: envie o header x-workspace-id (o id de um
                      workspace, obtido em GET /v1/workspaces)
                    code: WORKSPACE_ID_REQUIRED
        '401':
          description: Credencial ausente o inválida
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              examples:
                missing:
                  summary: No credential
                  value:
                    error: >-
                      Missing x-api-key, x-api-key-id or Authorization Bearer
                      token
                invalid:
                  summary: Invalid API key
                  value:
                    error: Invalid API key
        '403':
          description: No permitido
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              examples:
                permissionDenied:
                  summary: Account key / OAuth user who is not Owner or Admin
                  value:
                    error: >-
                      Your workspace role does not allow this action
                      (webhooks:manage).
                    code: PERMISSION_DENIED
                notMember:
                  summary: Account key / OAuth user who is not an active member
                  value:
                    error: >-
                      The user behind this token is not an active member of this
                      workspace.
                    code: WORKSPACE_MEMBERSHIP_REQUIRED
                tenantRequired:
                  summary: Credential not bound to a workspace
                  value:
                    error: This credential is not bound to a workspace.
                    code: TENANT_REQUIRED
                archived:
                  summary: Workspace archived
                  value:
                    error: >-
                      This workspace has been archived and its API is closed. |
                      Este workspace foi arquivado e sua API está encerrada.
                    code: WORKSPACE_ARCHIVED
                deliveryTimeoutStaffOnly:
                  summary: >-
                    `deliveryTimeoutMs` sent by someone who is not Pilot Status
                    staff
                  value:
                    error: >-
                      deliveryTimeoutMs can only be set by Pilot Status platform
                      staff; remove the field from the request. |
                      deliveryTimeoutMs só pode ser definido pela equipe da
                      Pilot Status; remova o campo do pedido.
                    code: DELIVERY_TIMEOUT_STAFF_ONLY
        '404':
          description: Número que no está en tu workspace
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: WhatsApp number not found
                code: NUMBER_NOT_FOUND
        '409':
          description: Conflicto con los webhooks ya registrados
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              examples:
                duplicate:
                  summary: Same URL already registered on this number
                  value:
                    error: >-
                      Já existe um webhook com esta URL para este número.
                      Atualize o existente em vez de criar outro.
                    code: WEBHOOK_DUPLICATE
                limit:
                  summary: Workspace already has 50 webhooks
                  value:
                    error: >-
                      Limite de 50 webhooks por workspace atingido (50). Remova
                      os que não usa ou fale com o suporte.
                    code: WEBHOOK_LIMIT_REACHED
        '500':
          description: Falla inesperada
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Internal server error
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: Tu API key ps_
    apiKeyId:
      type: apiKey
      in: header
      name: x-api-key-id
      description: Id de la API key (alternativa a x-api-key)

````

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