> ## 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 plantilla

> Crea una plantilla en el alcance del número vinculado. El campo body acepta tres formas: (1) un OBJETO estructurado { header?, body, footer?, buttons? } (recomendado); (2) ese mismo JSON como STRING; o (3) TEXTO PLANO, envuelto automáticamente en { "body": { "text": ... } }. Estructura: header opcional NONE (predeterminado) | TEXT (0–1 variable, hasta 60 caracteres) | IMAGE | VIDEO | DOCUMENT, con el medio provisto mediante header.url (http/https) O header.base64 (data URI data:<mime>;base64,…, re-alojado en el servidor); body.text hasta 1024 caracteres, con variables de estilo nombrado {{nome}} (no debe empezar ni terminar con una variable); footer.text hasta 60 caracteres, sin variables; buttons (hasta 10 en total) de los tipos QUICK_REPLY (≤ 10), URL (≤ 2; estática o dinámica con una variable nombrada al final, como {{link}} en la URL + un ejemplo resuelto), PHONE_NUMBER (≤ 1) y COPY_CODE (≤ 1; el código va en button.example); se permite mezclar botones de respuesta rápida con botones CTA. Los botones pueden acompañar un header de video o documento (PDF). El campo examples es OBLIGATORIO siempre que el body/header (o la URL dinámica) use variables: un objeto que asigna a cada variable un valor de ejemplo; si falta → 400 { code: "TEMPLATE_EXAMPLES_REQUIRED", details: { missing: [...] } }. Para números de Meta, la plantilla se envía a Meta para aprobación (metaStatus PENDING); 400 META_TEMPLATE_SUBMIT_FAILED si Meta la rechaza. 409 si ya existe una plantilla con ese nombre para este número. Solo se leen name, category, language, body y examples; variables, whatsappNumberId y metaWabaId se aceptan y se ignoran, y cualquier otro campo de nivel superior (por ejemplo, buttons colocado junto a body) se rechaza con 400 TEMPLATE_UNKNOWN_FIELDS. Requiere una clave con alcance de número.

Permiso `templates:manage`: `OWNER` o `ADMIN` para claves de cuenta y tokens OAuth; las claves de número y de workspace no tienen verificación de rol. Una clave de workspace, una clave de cuenta o un token OAuth deben indicar el número en `x-whatsapp-number-id`.

**Requiere una clave con alcance de número.**



## OpenAPI

````yaml openapi.es.json POST /v1/templates
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/templates:
    post:
      tags:
        - Templates
      summary: Crear plantilla
      description: >-
        Crea una plantilla en el alcance del número vinculado. El campo body
        acepta tres formas: (1) un OBJETO estructurado { header?, body, footer?,
        buttons? } (recomendado); (2) ese mismo JSON como STRING; o (3) TEXTO
        PLANO, envuelto automáticamente en { "body": { "text": ... } }.
        Estructura: header opcional NONE (predeterminado) | TEXT (0–1 variable,
        hasta 60 caracteres) | IMAGE | VIDEO | DOCUMENT, con el medio provisto
        mediante header.url (http/https) O header.base64 (data URI
        data:<mime>;base64,…, re-alojado en el servidor); body.text hasta 1024
        caracteres, con variables de estilo nombrado {{nome}} (no debe empezar
        ni terminar con una variable); footer.text hasta 60 caracteres, sin
        variables; buttons (hasta 10 en total) de los tipos QUICK_REPLY (≤ 10),
        URL (≤ 2; estática o dinámica con una variable nombrada al final, como
        {{link}} en la URL + un ejemplo resuelto), PHONE_NUMBER (≤ 1) y
        COPY_CODE (≤ 1; el código va en button.example); se permite mezclar
        botones de respuesta rápida con botones CTA. Los botones pueden
        acompañar un header de video o documento (PDF). El campo examples es
        OBLIGATORIO siempre que el body/header (o la URL dinámica) use
        variables: un objeto que asigna a cada variable un valor de ejemplo; si
        falta → 400 { code: "TEMPLATE_EXAMPLES_REQUIRED", details: { missing:
        [...] } }. Para números de Meta, la plantilla se envía a Meta para
        aprobación (metaStatus PENDING); 400 META_TEMPLATE_SUBMIT_FAILED si Meta
        la rechaza. 409 si ya existe una plantilla con ese nombre para este
        número. Solo se leen name, category, language, body y examples;
        variables, whatsappNumberId y metaWabaId se aceptan y se ignoran, y
        cualquier otro campo de nivel superior (por ejemplo, buttons colocado
        junto a body) se rechaza con 400 TEMPLATE_UNKNOWN_FIELDS. Requiere una
        clave con alcance de número.


        Permiso `templates:manage`: `OWNER` o `ADMIN` para claves de cuenta y
        tokens OAuth; las claves de número y de workspace no tienen verificación
        de rol. Una clave de workspace, una clave de cuenta o un token OAuth
        deben indicar el número en `x-whatsapp-number-id`.


        **Requiere una clave con alcance de número.**
      operationId: post_templates
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: >-
                    Nombre de la plantilla. Primero se normaliza (minúsculas,
                    sin acentos, los demás caracteres se convierten en _), luego
                    debe coincidir con [a-z0-9_], hasta 100 caracteres.
                  example: promo_cupom
                  maxLength: 100
                body:
                  type: object
                  description: >-
                    Contenido de la plantilla: objeto { header?, body, footer?,
                    buttons? } (recomendado), el mismo JSON como string, o texto
                    plano (se envuelve automáticamente).
                  example:
                    body:
                      text: Oi {{nome}}!
                body.header:
                  type: object
                  description: >-
                    Encabezado opcional. TEXT: texto con 0–1 variable (hasta 60
                    caracteres). IMAGE/VIDEO/DOCUMENT: proporciona url
                    (http/https) O base64 (data URI); el base64 se vuelve a
                    alojar en el servidor. No hay encabezado de ubicación.
                  example:
                    type: IMAGE
                    base64: data:image/png;base64,...
                body.footer:
                  type: object
                  description: Pie opcional, hasta 60 caracteres, sin variables.
                  example:
                    text: Promoção por tempo limitado
                body.buttons:
                  type: array
                  description: >-
                    Hasta 10 botones: QUICK_REPLY (≤ 10; text), URL (≤ 2; text +
                    url estática o dinámica con una variable con nombre al
                    final, p. ej. {{link}}), PHONE_NUMBER (≤ 1; text +
                    phone_number E.164), COPY_CODE (≤ 1; código en example).
                    Quick-reply y CTA pueden coexistir.
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - QUICK_REPLY
                          - URL
                          - PHONE_NUMBER
                          - COPY_CODE
                        description: Tipo de botón.
                      text:
                        type: string
                        description: Etiqueta del botón (todos los tipos).
                      url:
                        type: string
                        description: >-
                          Solo `URL`: enlace estático, o dinámico con una
                          variable con nombre al final (p. ej.
                          `https://loja.com/promo/{{link}}`).
                      phone_number:
                        type: string
                        description: 'Solo `PHONE_NUMBER`: número a marcar, E.164.'
                      example:
                        type: array
                        items:
                          type: string
                        description: >-
                          `COPY_CODE` only — sample code(s) for the copyable
                          value. On an official (Meta) number this is only the
                          sample Meta reviews: unless it is a `{{variable}}`,
                          the code the customer copies is sent on every send as
                          `variables.button_<N>` (N = the button's 1-based
                          position among all buttons).
                    required:
                      - type
                  example:
                    - type: URL
                      text: Comprar
                      url: https://loja.com/promo/{{link}}
                    - type: COPY_CODE
                      example:
                        - PROMO10
                examples:
                  type: object
                  description: >-
                    Required when variables exist: maps each variable used in
                    body/header (and the dynamic URL) to a sample value. The
                    COPY_CODE code goes in button.example, not here. Missing →
                    400 TEMPLATE_EXAMPLES_REQUIRED.
                  additionalProperties:
                    type: string
                  example:
                    nome: Maria
                    desconto: 10%
                    link: abc123
                category:
                  type: string
                  description: Categoría de la plantilla (por defecto UTILITY).
                  example: MARKETING
                  enum:
                    - MARKETING
                    - UTILITY
                    - OTP
                  default: UTILITY
                language:
                  type: string
                  description: Idioma de la plantilla (por defecto pt_BR).
                  example: pt_BR
                  default: pt_BR
              required:
                - name
                - body
      responses:
        '201':
          description: Crear plantilla completa
          content:
            application/json:
              example:
                id: tpl_01HZX...
                name: promo_cupom
                category: MARKETING
                metaStatus: PENDING
        '400':
          description: >-
            Campo de nivel superior desconocido (`TEMPLATE_UNKNOWN_FIELDS`),
            error de validación, faltan ejemplos (`TEMPLATE_EXAMPLES_REQUIRED`),
            botón que el número no puede enviar
            (`TEMPLATE_WEB_BUTTON_NOT_SUPPORTED`), Meta rechazó la plantilla
            (`META_TEMPLATE_SUBMIT_FAILED`), o `INVALID_BODY` cuando el cuerpo
            no es JSON válido
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              examples:
                templateExamplesRequired:
                  summary: TEMPLATE_EXAMPLES_REQUIRED
                  value:
                    error: 'Faltam valores de exemplo para as variáveis: nome'
                    code: TEMPLATE_EXAMPLES_REQUIRED
                    details:
                      missing:
                        - nome
                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
                templateUnknownFields:
                  value:
                    error: >-
                      Campos não aceitos neste endpoint: buttons. buttons é um
                      bloco do TEMPLATE: vai dentro de `body`, não no topo da
                      requisição. …
                    errorEn: >-
                      Fields not accepted by this endpoint: buttons. buttons is
                      a block of the TEMPLATE: it goes inside `body`, not at the
                      top of the request. …
                    code: TEMPLATE_UNKNOWN_FIELDS
                    details:
                      unknownFields:
                        - buttons
                validationError:
                  value:
                    error: Validation error
                    details:
                      formErrors: []
                      fieldErrors:
                        name:
                          - name is required
        '401':
          description: Encabezado `x-api-key` / `x-api-key-id` ausente o inválido
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Unauthorized
        '403':
          description: >-
            Clave de workspace/cuenta o token OAuth sin `x-whatsapp-number-id`
            (`TENANT_SCOPE_NOT_ALLOWED`), un rol de usuario sin
            `templates:manage` (`PERMISSION_DENIED`), o un número fuera de una
            concesión OAuth (`NUMBER_NOT_IN_GRANT`)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              examples:
                TENANT_SCOPE_NOT_ALLOWED:
                  value:
                    error: >-
                      This endpoint acts on a single WhatsApp number: send the
                      x-whatsapp-number-id header naming the number to act on
                      (its id or instance id from GET /v1/numbers) | Este
                      endpoint atua sobre um único número de WhatsApp: envie o
                      header x-whatsapp-number-id indicando o número desejado (o
                      id dele ou o id da instância, obtidos em GET /v1/numbers)
                    code: TENANT_SCOPE_NOT_ALLOWED
                PERMISSION_DENIED:
                  value:
                    error: >-
                      Your workspace role does not allow this action
                      (templates:manage).
                    code: PERMISSION_DENIED
        '404':
          description: El número de la clave ya no existe
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Template not found
        '409':
          description: Ya existe una plantilla con ese nombre para este número
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Já existe um template com esse nome para este número.
        '422':
          description: El medio de header.base64 no se pudo decodificar ni volver a alojar
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Template media upload failed
                code: TEMPLATE_MEDIA_UPLOAD_FAILED
        '429':
          description: Límite de solicitudes excedido
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Too many requests
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.