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

# Actualizar plantilla

> Actualiza una plantilla existente (por id) en el alcance del número vinculado. Solo se aplican body y examples; name, category, language, variables, whatsappNumberId y metaWabaId se aceptan y se ignoran (name, category y language no se pueden cambiar), y cualquier otro campo de nivel superior se rechaza con 400 TEMPLATE_UNKNOWN_FIELDS. El campo body sigue el mismo contrato que Crear plantilla: body como OBJETO { header?, body, footer?, buttons? } (recomendado), el mismo JSON como STRING, o TEXTO PLANO; header NONE | TEXT (0–1 variable, hasta 60) | IMAGE | VIDEO | DOCUMENT (medio vía header.url O header.base64, vuelto a alojar); body.text hasta 1024 (variables {{nome}}, no debe empezar ni terminar con una variable); footer hasta 60 sin variables; hasta 10 botones: QUICK_REPLY (≤ 10), URL (≤ 2; estática o dinámica con una variable con nombre al final como {{link}} + example), PHONE_NUMBER (≤ 1), COPY_CODE (≤ 1; código en button.example). El campo examples es OBLIGATORIO siempre que existan variables; si falta → 400 { code: "TEMPLATE_EXAMPLES_REQUIRED", details: { missing: [...] } }. Para números de Meta, la nueva versión se vuelve a enviar a Meta para aprobación (metaStatus PENDING); 400 META_TEMPLATE_SUBMIT_FAILED si Meta la rechaza. 409 TEMPLATE_NOT_EDITABLE si Meta no permite editar la plantilla en su estado actual (solo se pueden editar plantillas rechazadas); cuando Meta rechaza una edición por cualquier motivo, la plantilla almacenada queda sin cambios. 404 TEMPLATE_NOT_FOUND si no existe en el alcance del número. 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, clave de cuenta o token OAuth debe indicar el número en `x-whatsapp-number-id`.

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



## OpenAPI

````yaml openapi.es.json PUT /v1/templates/{id}
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/{id}:
    put:
      tags:
        - Templates
      summary: Actualizar plantilla
      description: >-
        Actualiza una plantilla existente (por id) en el alcance del número
        vinculado. Solo se aplican body y examples; name, category, language,
        variables, whatsappNumberId y metaWabaId se aceptan y se ignoran (name,
        category y language no se pueden cambiar), y cualquier otro campo de
        nivel superior se rechaza con 400 TEMPLATE_UNKNOWN_FIELDS. El campo body
        sigue el mismo contrato que Crear plantilla: body como OBJETO { header?,
        body, footer?, buttons? } (recomendado), el mismo JSON como STRING, o
        TEXTO PLANO; header NONE | TEXT (0–1 variable, hasta 60) | IMAGE | VIDEO
        | DOCUMENT (medio vía header.url O header.base64, vuelto a alojar);
        body.text hasta 1024 (variables {{nome}}, no debe empezar ni terminar
        con una variable); footer hasta 60 sin variables; hasta 10 botones:
        QUICK_REPLY (≤ 10), URL (≤ 2; estática o dinámica con una variable con
        nombre al final como {{link}} + example), PHONE_NUMBER (≤ 1), COPY_CODE
        (≤ 1; código en button.example). El campo examples es OBLIGATORIO
        siempre que existan variables; si falta → 400 { code:
        "TEMPLATE_EXAMPLES_REQUIRED", details: { missing: [...] } }. Para
        números de Meta, la nueva versión se vuelve a enviar a Meta para
        aprobación (metaStatus PENDING); 400 META_TEMPLATE_SUBMIT_FAILED si Meta
        la rechaza. 409 TEMPLATE_NOT_EDITABLE si Meta no permite editar la
        plantilla en su estado actual (solo se pueden editar plantillas
        rechazadas); cuando Meta rechaza una edición por cualquier motivo, la
        plantilla almacenada queda sin cambios. 404 TEMPLATE_NOT_FOUND si no
        existe en el alcance del número. 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, clave de cuenta o token OAuth debe
        indicar el número en `x-whatsapp-number-id`.


        **Requiere una clave con alcance de número.**
      operationId: put_templates_id
      parameters:
        - name: id
          in: path
          required: true
          description: Id de la plantilla a actualizar (no se acepta el nombre).
          schema:
            type: string
          example: tpl_01HZX...
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                body:
                  type: object
                  description: >-
                    Nuevo 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
                    url: https://cdn.loja.com/promo.png
                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: QUICK_REPLY
                      text: Quero!
                    - type: URL
                      text: Comprar
                      url: https://loja.com/promo/{{link}}
                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: 15%
                    link: abc123
                category:
                  type: string
                  description: 'Se acepta y se ignora: la categoría no se puede cambiar.'
                  example: MARKETING
                language:
                  type: string
                  description: 'Se acepta y se ignora: el idioma no se puede cambiar.'
                  example: pt_BR
              required:
                - body
      responses:
        '200':
          description: Actualizar plantilla
          content:
            application/json:
              example:
                id: tpl_01HZX...
                name: promo_cupom
                category: MARKETING
                body: '{"body":{"text":"Oi {{nome}}!"}}'
                variables:
                  - nome
                metaStatus: PENDING
        '400':
          description: >-
            Campo de nivel superior desconocido (`TEMPLATE_UNKNOWN_FIELDS`),
            error de validación, faltan ejemplos (`TEMPLATE_EXAMPLES_REQUIRED`),
            botón que no se puede crear ni enviar
            (`TEMPLATE_WEB_BUTTON_NOT_SUPPORTED`,
            `TEMPLATE_LIST_NOT_SUPPORTED_BY_META`), Meta rechazó el reenvío
            (solo `error`), o `INVALID_BODY`
          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
        '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: >-
            Plantilla no encontrada en el alcance de la clave (también cuando
            `{id}` es un nombre de plantilla: solo se acepta el id)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Template not found
                code: TEMPLATE_NOT_FOUND
        '409':
          description: >-
            Meta se negó a editar esta plantilla (código Graph 100, subcódigo
            2388003: Meta solo permite editar plantillas rechazadas). No cambió
            nada: la plantilla almacenada conserva su body y `metaStatus`
            anteriores. Crea una plantilla nueva con el cambio, o envía el
            documento como parámetro en tiempo de ejecución al enviar. `error`
            es una frase bilingüe `English | Português`; `meta_user_message` es
            el texto propio de Meta, o `null`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
                    enum:
                      - TEMPLATE_NOT_EDITABLE
                  meta_user_message:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Texto de error propio de Meta, o `null` cuando Meta no
                      envió ninguno.
              example:
                error: >-
                  Meta does not allow editing this template in its current state
                  (only rejected templates can be edited). Create a new template
                  with the change, or send the document at send time. | A Meta
                  não permite editar este template no estado atual (só templates
                  rejeitados podem ser editados). Crie um novo template com a
                  alteração ou envie o documento no momento do envio.
                code: TEMPLATE_NOT_EDITABLE
                meta_user_message: >-
                  Message templates can only be edited if they have been
                  rejected.
        '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.