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

# Update template

> Updates an existing template (by id or name) in the linked number's scope. The body follows the same contract as Create template: body as an OBJECT { header?, body, footer?, buttons? } (recommended), the same JSON as a STRING, or PLAIN TEXT; header NONE | TEXT (0–1 variable, up to 60) | IMAGE | VIDEO | DOCUMENT (media via header.url OR header.base64, re-hosted); body.text up to 1024 (variables {{nome}}, must not start/end with a variable); footer up to 60 with no variables; up to 10 buttons — QUICK_REPLY (≤ 10), URL (≤ 2; static or dynamic with {{1}} + example), PHONE_NUMBER (≤ 1), COPY_CODE (≤ 1; code in button.example). The examples field is REQUIRED whenever variables exist; missing → 400 { code: "TEMPLATE_EXAMPLES_REQUIRED", details: { missing: [...] } }. For Meta numbers the new version is re-submitted to Meta for approval (metaStatus PENDING); 400 META_TEMPLATE_SUBMIT_FAILED if Meta rejects it. 404 TEMPLATE_NOT_FOUND if it doesn't exist in the number's scope. Requires a number-scoped key.

**Requires a number-scoped key.**



## OpenAPI

````yaml openapi.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: >-
    Public REST API for Pilot Status. Authenticate with the `x-api-key: ps_...`
    header (or `x-api-key-id`). Base URL: https://pilotstatus.com.br
servers:
  - url: https://pilotstatus.com.br
security:
  - apiKey: []
  - apiKeyId: []
paths:
  /v1/templates/{id}:
    put:
      tags:
        - Templates
      summary: Update template
      description: >-
        Updates an existing template (by id or name) in the linked number's
        scope. The body follows the same contract as Create template: body as an
        OBJECT { header?, body, footer?, buttons? } (recommended), the same JSON
        as a STRING, or PLAIN TEXT; header NONE | TEXT (0–1 variable, up to 60)
        | IMAGE | VIDEO | DOCUMENT (media via header.url OR header.base64,
        re-hosted); body.text up to 1024 (variables {{nome}}, must not start/end
        with a variable); footer up to 60 with no variables; up to 10 buttons —
        QUICK_REPLY (≤ 10), URL (≤ 2; static or dynamic with {{1}} + example),
        PHONE_NUMBER (≤ 1), COPY_CODE (≤ 1; code in button.example). The
        examples field is REQUIRED whenever variables exist; missing → 400 {
        code: "TEMPLATE_EXAMPLES_REQUIRED", details: { missing: [...] } }. For
        Meta numbers the new version is re-submitted to Meta for approval
        (metaStatus PENDING); 400 META_TEMPLATE_SUBMIT_FAILED if Meta rejects
        it. 404 TEMPLATE_NOT_FOUND if it doesn't exist in the number's scope.
        Requires a number-scoped key.


        **Requires a number-scoped key.**
      operationId: put_templates_id
      parameters:
        - name: id
          in: path
          required: true
          description: Id or name of the template to update.
          schema:
            type: string
          example: promo_cupom
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                body:
                  type: string
                  description: >-
                    New template content: object { header?, body, footer?,
                    buttons? } (recommended), the same JSON as a string, or
                    plain text (auto-wrapped).
                  example: '{ "body": { "text": "Oi {{nome}}!" } }'
                body.header:
                  type: string
                  description: >-
                    Optional header. TEXT: text with 0–1 variable (up to 60
                    chars). IMAGE/VIDEO/DOCUMENT: provide url (http/https) OR
                    base64 (data URI); base64 is re-hosted server-side. No
                    location header.
                  example: '{ "type": "IMAGE", "url": "https://cdn.loja.com/promo.png" }'
                body.footer:
                  type: string
                  description: Optional footer, up to 60 chars, no variables.
                  example: '{ "text": "Promoção por tempo limitado" }'
                body.buttons:
                  type: string
                  description: >-
                    Up to 10 buttons: QUICK_REPLY (≤ 10; text), URL (≤ 2; text +
                    static url or dynamic with trailing {{1}}), PHONE_NUMBER (≤
                    1; text + phone_number E.164), COPY_CODE (≤ 1; code in
                    example). Quick-reply and CTA can coexist.
                  example: >-
                    [{ "type": "QUICK_REPLY", "text": "Quero!" }, { "type":
                    "URL", "text": "Comprar", "url":
                    "https://loja.com/promo/{{link}}" }]
                examples:
                  type: string
                  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.
                  example: '{ "nome": "Maria", "desconto": "15%", "link": "abc123" }'
                category:
                  type: string
                  description: Template category (default UTILITY).
                  example: MARKETING
                language:
                  type: string
                  description: Template language (default pt_BR).
                  example: pt_BR
              required:
                - body
            example:
              category: MARKETING
              language: pt_BR
              body:
                header:
                  type: IMAGE
                  url: https://cdn.loja.com/promo.png
                body:
                  text: Oi {{nome}}! Agora com {{desconto}} de desconto.
                footer:
                  text: Promoção por tempo limitado
                buttons:
                  - type: QUICK_REPLY
                    text: Quero!
                  - type: URL
                    text: Comprar
                    url: https://loja.com/promo/{{link}}
              examples:
                nome: Maria
                desconto: 15%
                link: abc123
      responses:
        '200':
          description: Update template
          content:
            application/json:
              example:
                id: tpl_01HZX...
                name: promo_cupom
                category: MARKETING
                metaStatus: PENDING
        '400':
          description: Missing examples
          content:
            application/json:
              example:
                code: TEMPLATE_EXAMPLES_REQUIRED
                details:
                  missing:
                    - nome
        '401':
          description: Missing or invalid `x-api-key` / `x-api-key-id` header
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Unauthorized
        '403':
          description: Tenant-scoped key used on a number-scoped endpoint
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  code:
                    type: string
              example:
                error: Tenant-scoped keys cannot call number endpoints
                code: TENANT_SCOPE_NOT_ALLOWED
        '429':
          description: Rate limit exceeded
          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: Your ps_ API key
    apiKeyId:
      type: apiKey
      in: header
      name: x-api-key-id
      description: API key id (alternative to x-api-key)

````