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

# Submeter template

> Cria um template e o envia ao WhatsApp para aprovação. A aprovação é decidida pelo provedor, no tempo dele. Acompanhe pelos eventos `template.*` ou consultando o template.

Somente templates `approved` podem ser usados em `POST /v1/messages`. Veja [Templates](/concepts/templates).



## OpenAPI

````yaml openapi.json POST /v1/templates
openapi: 3.0.3
info:
  title: API da Routa
  description: >-
    API REST para enviar e receber mensagens de WhatsApp, acompanhar a entrega e
    receber eventos normalizados por webhook.
  version: '1'
servers:
  - url: https://api.routa.chat
    description: Produção
security:
  - bearerAuth: []
tags:
  - name: Mensagens
    description: Envie, consulte e liste mensagens.
  - name: Eventos
    description: Consulte o log de eventos normalizados.
  - name: Webhooks
    description: Gerencie endpoints de webhook, segredos e entregas.
  - name: Templates
    description: Submeta e consulte templates de WhatsApp.
  - name: Mídia
    description: Envie e obtenha arquivos de mídia.
  - name: Uso
    description: Consulte o uso medido do projeto.
  - name: Identidade
    description: Identifique a chave de API em uso.
paths:
  /v1/templates:
    post:
      tags:
        - Templates
      summary: Submeter template
      description: >-
        Cria um template e o envia ao WhatsApp para aprovação. A aprovação é
        decidida pelo provedor, no tempo dele. Acompanhe pelos eventos
        `template.*` ou consultando o template.


        Somente templates `approved` podem ser usados em `POST /v1/messages`.
        Veja [Templates](/concepts/templates).
      operationId: createTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - channel
                - name
                - language
                - category
                - body_text
              properties:
                channel:
                  description: Canal ao qual o template pertence (`chan_...`).
                  type: string
                  example: chan_01J8ZK9M3Q7XABCDEFGHJKMNPQ
                name:
                  type: string
                  description: Nome do template.
                  example: confirmacao_pedido
                language:
                  description: Código de idioma, por exemplo `pt_BR` ou `en_US`.
                  type: string
                  example: pt_BR
                category:
                  type: string
                  enum:
                    - marketing
                    - utility
                    - authentication
                  description: >-
                    Categoria do template: `marketing`, `utility` ou
                    `authentication`.
                body_text:
                  description: >-
                    Corpo do template, com placeholders posicionais `{{1}}`,
                    `{{2}}`, …
                  type: string
                  example: Olá {{1}}! Seu pedido {{2}} foi confirmado.
                components:
                  description: >-
                    Componentes opcionais: cabeçalho de texto ou de mídia,
                    rodapé e até 10 botões. Omita o campo para um template só de
                    texto.
                  type: object
                  properties:
                    header:
                      oneOf:
                        - type: object
                          required:
                            - kind
                            - text
                          properties:
                            kind:
                              type: string
                              enum:
                                - text
                            text:
                              description: >-
                                Header text, at most 60 characters, at most one
                                `{{1}}` placeholder.
                              type: string
                        - type: object
                          required:
                            - kind
                            - media_id
                          properties:
                            kind:
                              type: string
                              enum:
                                - media
                            media_id:
                              description: >-
                                A `TemplateMedia` id from `POST
                                /v1/templates/media`.
                              type: string
                      description: >-
                        Cabeçalho de texto (até 60 caracteres e uma variável) ou
                        de mídia (um `media_id` de `POST /v1/templates/media`).
                    footer:
                      type: object
                      required:
                        - text
                      properties:
                        text:
                          description: Footer text, at most 60 characters.
                          type: string
                      description: Rodapé em texto, com até 60 caracteres.
                    buttons:
                      description: >-
                        Até 10 botões. No máximo um botão `phone_number`. O
                        texto de cada botão tem até 25 caracteres, e a URL de um
                        botão `url` pode ter uma variável `{{1}}`.
                      type: array
                      items:
                        oneOf:
                          - type: object
                            required:
                              - kind
                              - text
                            properties:
                              kind:
                                type: string
                                enum:
                                  - quick_reply
                              text:
                                description: Button label, at most 25 characters.
                                type: string
                          - type: object
                            required:
                              - kind
                              - text
                              - phone_number
                            properties:
                              kind:
                                type: string
                                enum:
                                  - phone_number
                              text:
                                description: Button label, at most 25 characters.
                                type: string
                              phone_number:
                                description: The phone number the button dials.
                                type: string
                          - type: object
                            required:
                              - kind
                              - text
                              - url
                            properties:
                              kind:
                                type: string
                                enum:
                                  - url
                              text:
                                description: Button label, at most 25 characters.
                                type: string
                              url:
                                description: >-
                                  Destination URL. May contain exactly one
                                  `{{1}}` placeholder.
                                type: string
            example:
              channel: chan_01J8ZK9M3Q7XABCDEFGHJKMNPQ
              name: confirmacao_pedido
              language: pt_BR
              category: utility
              body_text: Olá {{1}}! Seu pedido {{2}} foi confirmado.
      responses:
        '201':
          description: Recurso criado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Template'
        '401':
          description: >-
            Chave de API ausente, inválida, revogada ou expirada
            (`api_key_invalid`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: A chave não tem o escopo necessário (`insufficient_scope`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: O recurso não existe ou pertence a outro projeto
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Requisição inválida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Limite de taxa excedido. Veja o header `Retry-After`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth:
            - templates:write
components:
  schemas:
    Template:
      type: object
      properties:
        id:
          type: string
          description: Identificador do template.
          example: tmpl_01J8ZK9M3Q7XABCDEFGHJKMNPQ
        channel:
          type: string
          description: Canal ao qual o template pertence.
          example: chan_01J8ZK9M3Q7XABCDEFGHJKMNPQ
        name:
          type: string
          description: Nome do template.
          example: confirmacao_pedido
        language:
          type: string
          description: Código de idioma.
          example: pt_BR
        category:
          type: string
          enum:
            - marketing
            - utility
            - authentication
          description: 'Categoria: `marketing`, `utility` ou `authentication`.'
        variables:
          type: array
          items:
            type: object
            required:
              - index
            properties:
              index:
                type: number
          description: Placeholders posicionais do corpo (`{{1}}`, `{{2}}`, …).
        components:
          type: object
          properties:
            header:
              oneOf:
                - type: object
                  required:
                    - kind
                    - text
                  properties:
                    kind:
                      type: string
                      enum:
                        - text
                    text:
                      type: string
                - type: object
                  required:
                    - kind
                    - format
                    - media_id
                  properties:
                    kind:
                      type: string
                      enum:
                        - media
                    format:
                      type: string
                      enum:
                        - image
                        - video
                        - document
                    media_id:
                      type: string
            footer:
              type: object
              required:
                - text
              properties:
                text:
                  type: string
            buttons:
              type: array
              items:
                oneOf:
                  - type: object
                    required:
                      - kind
                      - text
                    properties:
                      kind:
                        type: string
                        enum:
                          - quick_reply
                      text:
                        type: string
                  - type: object
                    required:
                      - kind
                      - text
                      - phone_number
                    properties:
                      kind:
                        type: string
                        enum:
                          - phone_number
                      text:
                        type: string
                      phone_number:
                        type: string
                  - type: object
                    required:
                      - kind
                      - text
                      - url
                    properties:
                      kind:
                        type: string
                        enum:
                          - url
                      text:
                        type: string
                      url:
                        type: string
          description: Cabeçalho, rodapé e botões do template, quando existirem.
        status:
          type: string
          enum:
            - draft
            - submitted
            - pending
            - approved
            - rejected
            - paused
            - disabled
          description: Estado de aprovação. Somente `approved` permite enviar.
        rejection_reason:
          type: string
          enum:
            - abusive_content
            - incorrect_category
            - invalid_format
            - scam
            - tag_content_mismatch
            - other
          nullable: true
          description: Motivo da rejeição, quando `status` é `rejected`.
        created_at:
          format: date-time
          type: string
          description: Quando o template foi criado.
          example: '2026-09-04T13:22:41.031Z'
        updated_at:
          format: date-time
          type: string
          description: Quando o template foi atualizado pela última vez.
          example: '2026-09-04T13:22:41.031Z'
      required:
        - id
        - channel
        - name
        - language
        - category
        - variables
        - status
        - rejection_reason
        - created_at
        - updated_at
    Error:
      type: object
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
            - request_id
          properties:
            type:
              type: string
              description: >-
                Categoria do erro: `invalid_request_error`,
                `authentication_error`, `permission_error`, `not_found_error`,
                `conflict_error`, `rate_limit_error`, `billing_error` ou
                `api_error`.
              example: invalid_request_error
            code:
              type: string
              description: >-
                Código estável e legível por máquina. Veja [Códigos de
                erro](/errors/error-codes).
              example: channel_inactive
            message:
              type: string
              description: >-
                Texto para humanos, em inglês. Pode mudar, então não faça parse
                dele.
              example: Channel chan_01J8... is not active and cannot send messages.
            param:
              type: string
              description: O campo da requisição com problema, quando se aplica.
            doc_url:
              type: string
              description: Link para a documentação do código, quando disponível.
            details:
              type: object
              additionalProperties:
                oneOf:
                  - type: string
                  - type: number
              description: >-
                Valores acionáveis, como `limit`, `used` e `resets_at` em
                `message_quota_exceeded`.
            request_id:
              type: string
              description: Identificador da requisição. Informe-o ao falar com o suporte.
              example: req_01J8ZK9M3Q7XABCDEFGHJKMNPQ
          description: Detalhes do erro.
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Chave de API do projeto, no formato `rt_live_...` ou `rt_test_...`,
        enviada como `Authorization: Bearer <chave>`.

````

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