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

# Create template

> Submit a new message template for Meta review.

Submits a new message template to Meta for review.

* `name` — lowercase, in `snake_case` format (e.g. `boas_vindas_cliente`).
* `category` — `MARKETING`, `UTILITY` or `AUTHENTICATION`.
* `language` — Meta language code (e.g. `pt_BR`).
* `bodyText` — template body. Use `{{1}}`, `{{2}}`… placeholders for
  variables.
* `bodyExample` — one example value per placeholder, required by Meta on
  submission.
* `footerText` — optional footer.

### Header

Choose the header type with `headerFormat`:

* `TEXT` (default) — use `headerText`.
* `IMAGE`, `VIDEO` or `DOCUMENT` — provide the sample media in `headerMediaUrl`
  (public URL) **or** `headerMediaBase64`. The backend uploads the sample to
  Meta's Resumable Upload API automatically — you do not need to generate the
  `header_handle` manually.

### Buttons

Pass `buttons[]` (Meta limits them by type — e.g. 1 phone number, up to 2 URLs):

* `QUICK_REPLY` — `{ "type": "QUICK_REPLY", "text": "Sim" }`
* `URL` — `{ "type": "URL", "text": "Ver pedido", "url": "https://site.com/{{1}}", "urlExample": "https://site.com/42" }` (`urlExample` is only required when the `url` contains `{{1}}`).
* `PHONE_NUMBER` — `{ "type": "PHONE_NUMBER", "text": "Ligar", "phoneNumber": "+5511999999999" }`
* `COPY_CODE` — `{ "type": "COPY_CODE", "example": "PROMO10" }`

The response in `data` contains the id of the created template and its initial status
(usually `PENDING`).

> [!WARNING]
>
> Approval is done by Meta and can take from minutes to hours. Only `APPROVED`
> templates can be sent.


## OpenAPI

````yaml api-reference/openapi.en.json POST /api/v1/connections/cloud-api/{id}/templates
openapi: 3.1.0
info:
  title: D-API - Complete WhatsApp Infrastructure
  description: >-
    A scalable, robust solution for automation managers, SaaS products and end
    users who need a reliable WhatsApp integration. It offers multiple
    simultaneous instances, real-time webhooks, an intuitive dashboard and a
    documented REST API with 99.9% uptime and latency under 30ms.
  version: 1.2.1
  contact:
    name: Suporte D-API
    email: suporte@d-api.cloud
    url: https://d-api.cloud
servers:
  - url: https://api.d-api.cloud
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Home
    description: Base endpoints
  - name: Sessions
    description: Endpoints for managing sessions
  - name: Messages
    description: Endpoints for sending messages
  - name: Cloud API
    description: >-
      WhatsApp Official API (Meta Cloud API): manual connection, template
      management (list/create/delete) and template sending.
  - name: IVR Calls
    description: 'Voice call dispatch (IVR): single or bulk, with audio or an IVR flow.'
  - name: SMS
    description: 'SMS sending: single or bulk.'
  - name: Commands
    description: >-
      Look up asynchronous commands (async: true) by the commandId returned when
      enqueued.
paths:
  /api/v1/connections/cloud-api/{id}/templates:
    post:
      tags:
        - Cloud API
      summary: Create message template on the WABA
      description: >-
        Submits a new message template for Meta review. `name` must be lowercase
        snake_case; `category` is MARKETING, UTILITY or AUTHENTICATION;
        `language` is a Meta language code (e.g. pt_BR). Body placeholders use
        {{1}}, {{2}}… and `bodyExample` provides a sample value for each
        placeholder.


        Headers: set `headerFormat` to TEXT (with `headerText`) or
        IMAGE/VIDEO/DOCUMENT (with `headerMediaUrl` or `headerMediaBase64` — the
        sample is sent to Meta automatically). Buttons: use `buttons[]` with
        QUICK_REPLY (`text`), URL (`text`, `url` — include `urlExample` when the
        url has {{1}}), PHONE_NUMBER (`text`, `phoneNumber`), COPY_CODE
        (`example`), FLOW (`text`, `flowId`, `flowAction`
        NAVIGATE/DATA_EXCHANGE, `navigateScreen`, `icon`) or PAYMENT_REQUEST
        (`text`, `paymentSetting.pixDynamicCode.code` — the Pix code lives in
        the template definition). `data` contains the created template's id and
        initial status (usually PENDING).
      operationId: postApiV1ConnectionsCloud-apiByIdTemplates
      parameters:
        - schema:
            type: string
          in: path
          name: id
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  minLength: 1
                  pattern: ^[a-z0-9_]+$
                  type: string
                category:
                  anyOf:
                    - const: MARKETING
                      type: string
                    - const: UTILITY
                      type: string
                    - const: AUTHENTICATION
                      type: string
                language:
                  minLength: 2
                  type: string
                headerFormat:
                  anyOf:
                    - const: TEXT
                      type: string
                    - const: IMAGE
                      type: string
                    - const: VIDEO
                      type: string
                    - const: DOCUMENT
                      type: string
                headerText:
                  type: string
                headerMediaUrl:
                  type: string
                headerMediaBase64:
                  type: string
                headerMediaMime:
                  type: string
                bodyText:
                  minLength: 1
                  type: string
                footerText:
                  type: string
                bodyExample:
                  type: array
                  items:
                    type: string
                buttons:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          type:
                            anyOf:
                              - const: QUICK_REPLY
                                type: string
                              - const: URL
                                type: string
                              - const: PHONE_NUMBER
                                type: string
                              - const: COPY_CODE
                                type: string
                          text:
                            type: string
                          url:
                            type: string
                          urlExample:
                            type: string
                          phoneNumber:
                            type: string
                          example:
                            type: string
                        required:
                          - type
                      - type: object
                        properties:
                          type:
                            const: FLOW
                            type: string
                          text:
                            minLength: 1
                            type: string
                          flowId:
                            minLength: 1
                            pattern: ^[0-9]+$
                            type: string
                          flowAction:
                            anyOf:
                              - const: NAVIGATE
                                type: string
                              - const: DATA_EXCHANGE
                                type: string
                          navigateScreen:
                            minLength: 1
                            type: string
                          icon:
                            minLength: 1
                            type: string
                        required:
                          - type
                          - text
                          - flowId
                      - type: object
                        properties:
                          type:
                            const: PAYMENT_REQUEST
                            type: string
                          text:
                            minLength: 1
                            type: string
                          paymentSetting:
                            type: object
                            properties:
                              type:
                                const: PIX_DYNAMIC_CODE
                                type: string
                              pixDynamicCode:
                                type: object
                                properties:
                                  code:
                                    minLength: 1
                                    type: string
                                required:
                                  - code
                            required:
                              - type
                              - pixDynamicCode
                        required:
                          - type
                          - text
                          - paymentSetting
              required:
                - name
                - category
                - language
                - bodyText
              additionalProperties: false
          multipart/form-data:
            schema:
              type: object
              properties:
                name:
                  minLength: 1
                  pattern: ^[a-z0-9_]+$
                  type: string
                category:
                  anyOf:
                    - const: MARKETING
                      type: string
                    - const: UTILITY
                      type: string
                    - const: AUTHENTICATION
                      type: string
                language:
                  minLength: 2
                  type: string
                headerFormat:
                  anyOf:
                    - const: TEXT
                      type: string
                    - const: IMAGE
                      type: string
                    - const: VIDEO
                      type: string
                    - const: DOCUMENT
                      type: string
                headerText:
                  type: string
                headerMediaUrl:
                  type: string
                headerMediaBase64:
                  type: string
                headerMediaMime:
                  type: string
                bodyText:
                  minLength: 1
                  type: string
                footerText:
                  type: string
                bodyExample:
                  type: array
                  items:
                    type: string
                buttons:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          type:
                            anyOf:
                              - const: QUICK_REPLY
                                type: string
                              - const: URL
                                type: string
                              - const: PHONE_NUMBER
                                type: string
                              - const: COPY_CODE
                                type: string
                          text:
                            type: string
                          url:
                            type: string
                          urlExample:
                            type: string
                          phoneNumber:
                            type: string
                          example:
                            type: string
                        required:
                          - type
                      - type: object
                        properties:
                          type:
                            const: FLOW
                            type: string
                          text:
                            minLength: 1
                            type: string
                          flowId:
                            minLength: 1
                            pattern: ^[0-9]+$
                            type: string
                          flowAction:
                            anyOf:
                              - const: NAVIGATE
                                type: string
                              - const: DATA_EXCHANGE
                                type: string
                          navigateScreen:
                            minLength: 1
                            type: string
                          icon:
                            minLength: 1
                            type: string
                        required:
                          - type
                          - text
                          - flowId
                      - type: object
                        properties:
                          type:
                            const: PAYMENT_REQUEST
                            type: string
                          text:
                            minLength: 1
                            type: string
                          paymentSetting:
                            type: object
                            properties:
                              type:
                                const: PIX_DYNAMIC_CODE
                                type: string
                              pixDynamicCode:
                                type: object
                                properties:
                                  code:
                                    minLength: 1
                                    type: string
                                required:
                                  - code
                            required:
                              - type
                              - pixDynamicCode
                        required:
                          - type
                          - text
                          - paymentSetting
              required:
                - name
                - category
                - language
                - bodyText
              additionalProperties: false
          text/plain:
            schema:
              type: object
              properties:
                name:
                  minLength: 1
                  pattern: ^[a-z0-9_]+$
                  type: string
                category:
                  anyOf:
                    - const: MARKETING
                      type: string
                    - const: UTILITY
                      type: string
                    - const: AUTHENTICATION
                      type: string
                language:
                  minLength: 2
                  type: string
                headerFormat:
                  anyOf:
                    - const: TEXT
                      type: string
                    - const: IMAGE
                      type: string
                    - const: VIDEO
                      type: string
                    - const: DOCUMENT
                      type: string
                headerText:
                  type: string
                headerMediaUrl:
                  type: string
                headerMediaBase64:
                  type: string
                headerMediaMime:
                  type: string
                bodyText:
                  minLength: 1
                  type: string
                footerText:
                  type: string
                bodyExample:
                  type: array
                  items:
                    type: string
                buttons:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          type:
                            anyOf:
                              - const: QUICK_REPLY
                                type: string
                              - const: URL
                                type: string
                              - const: PHONE_NUMBER
                                type: string
                              - const: COPY_CODE
                                type: string
                          text:
                            type: string
                          url:
                            type: string
                          urlExample:
                            type: string
                          phoneNumber:
                            type: string
                          example:
                            type: string
                        required:
                          - type
                      - type: object
                        properties:
                          type:
                            const: FLOW
                            type: string
                          text:
                            minLength: 1
                            type: string
                          flowId:
                            minLength: 1
                            pattern: ^[0-9]+$
                            type: string
                          flowAction:
                            anyOf:
                              - const: NAVIGATE
                                type: string
                              - const: DATA_EXCHANGE
                                type: string
                          navigateScreen:
                            minLength: 1
                            type: string
                          icon:
                            minLength: 1
                            type: string
                        required:
                          - type
                          - text
                          - flowId
                      - type: object
                        properties:
                          type:
                            const: PAYMENT_REQUEST
                            type: string
                          text:
                            minLength: 1
                            type: string
                          paymentSetting:
                            type: object
                            properties:
                              type:
                                const: PIX_DYNAMIC_CODE
                                type: string
                              pixDynamicCode:
                                type: object
                                properties:
                                  code:
                                    minLength: 1
                                    type: string
                                required:
                                  - code
                            required:
                              - type
                              - pixDynamicCode
                        required:
                          - type
                          - text
                          - paymentSetting
              required:
                - name
                - category
                - language
                - bodyText
              additionalProperties: false
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data: {}
                  error:
                    type: string
                  code:
                    type: string
                required:
                  - success
            multipart/form-data:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data: {}
                  error:
                    type: string
                  code:
                    type: string
                required:
                  - success
            text/plain:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data: {}
                  error:
                    type: string
                  code:
                    type: string
                required:
                  - success
          description: Successful response
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'API Key for authentication. Format: <API_KEY>'

````

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