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

# Criar template

> Crie um novo template e envie para aprovação da Meta

## Conceituação

Cria um novo template de mensagem e envia para aprovação da Meta. O template começa com status `PENDING` e é atualizado para `APPROVED` ou `REJECTED` após a revisão.

Use o endpoint de [Sincronizar templates](/templates/sync-templates) para forçar a atualização do status.

<Warning>
  O nome do template deve ser em `snake_case`, sem espaços ou caracteres especiais. Uma vez criado, o nome não pode ser alterado.
</Warning>

<Note>
  O `wabaId` é obtido através do endpoint de [Listar WABAs](/templates/list-businesses).
</Note>


## OpenAPI

````yaml POST /whatsapp/businesses/{wabaId}/templates
openapi: 3.1.0
info:
  title: Hub Message - Templates API
  description: API for managing WhatsApp Business message templates
  version: 1.0.0
servers:
  - url: https://api.hubmessage.io
security:
  - bearerAuth: []
paths:
  /whatsapp/businesses/{wabaId}/templates:
    post:
      tags:
        - Templates
      summary: Create template
      description: Creates a new message template and submits it for Meta approval.
      operationId: createTemplate
      parameters:
        - name: wabaId
          in: path
          required: true
          description: WABA ID (obtained via List WABAs)
          schema:
            type: string
            example: '428083093730937'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTemplateRequest'
            examples:
              utility:
                summary: Utility - Order update
                value:
                  name: order_update_v1
                  category: UTILITY
                  language: en_US
                  components:
                    - type: BODY
                      text: >-
                        Hello {{1}}, your order {{2}} has been updated to {{3}},
                        see you soon.
                      example:
                        body_text:
                          - - Ana
                            - ORD-1024
                            - in transit
              marketing:
                summary: Marketing - Discount campaign
                value:
                  name: discount_campaign_v1
                  category: MARKETING
                  language: en_US
                  components:
                    - type: BODY
                      text: Enjoy {{1}} off on the {{2}} plan until {{3}}.
                      example:
                        body_text:
                          - - 20%
                            - Premium
                            - 04/30
                    - type: BUTTONS
                      buttons:
                        - type: URL
                          text: View offer
                          url: https://example.com/offer
              authentication:
                summary: Authentication - OTP code
                value:
                  name: otp_login_v1
                  category: AUTHENTICATION
                  language: en_US
                  components:
                    - type: BODY
                      text: >-
                        Your verification code is *{{1}}*. For your security, do
                        not share it.
                      add_security_recommendation: true
                      example:
                        body_text:
                          - - '123456'
                    - type: BUTTONS
                      buttons:
                        - type: URL
                          text: Copy code
                          url: >-
                            https://www.whatsapp.com/otp/code/?otp_type=COPY_CODE&code=otp{{1}}
                          example:
                            - >-
                              https://www.whatsapp.com/otp/code/?otp_type=COPY_CODE&code=otp123456
      responses:
        '200':
          description: Template created and submitted for approval
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateTemplateResponse'
              example:
                id: '1613165359891625'
                status: PENDING
                category: UTILITY
        '400':
          $ref: '#/components/responses/MetaError'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    CreateTemplateRequest:
      type: object
      required:
        - name
        - category
        - language
        - components
      properties:
        name:
          type: string
          description: Template name (snake_case, no spaces)
        category:
          type: string
          description: Template category
          enum:
            - UTILITY
            - MARKETING
            - AUTHENTICATION
        language:
          type: string
          description: Template language (e.g. en_US, pt_BR)
        components:
          type: array
          description: Template components (HEADER, BODY, FOOTER, BUTTONS)
          items:
            type: object
    CreateTemplateResponse:
      type: object
      properties:
        id:
          type: string
          description: Created template ID
        status:
          type: string
          description: Initial status (usually PENDING)
          enum:
            - PENDING
            - APPROVED
            - REJECTED
        category:
          type: string
          description: Created template category
          enum:
            - UTILITY
            - MARKETING
            - AUTHENTICATION
    MetaError:
      type: object
      properties:
        error:
          type: string
          description: General error description
        value:
          type: object
          properties:
            errors:
              type: array
              items:
                type: object
                properties:
                  description:
                    type: string
                  name:
                    type: string
                    description: Error type (e.g. META_WHATSAPP_ERROR)
                  message:
                    type: string
                    description: Meta error message
                  code:
                    type: string
                    description: Meta error code
    Error:
      type: object
      properties:
        error:
          type: integer
          description: Error code
        message:
          type: string
          description: Error description
  responses:
    MetaError:
      description: Error returned by Meta when processing the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MetaError'
          example:
            error: Newport request failed
            value:
              errors:
                - description: ''
                  name: META_WHATSAPP_ERROR
                  message: >-
                    Your message could not be sent because it contains content
                    that other people on Facebook have reported as abusive.
                  code: '368'
    Unauthorized:
      description: Invalid or missing token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 401
            message: Unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Secret Key generated in the Hub Message Security panel

````