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

# Create a Whatsapp message template



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/whatsapp/management.yml post /whatsapp/message_templates
openapi: 3.1.0
info:
  title: Telnyx WhatsApp Management API
  version: 2.0.0
  description: >
    API for managing WhatsApp Business Accounts (WABAs), phone numbers, and
    message templates.


    Use these endpoints to:

    - List and manage WhatsApp Business Accounts

    - Configure phone numbers for WhatsApp

    - Create and manage message templates

    - Set up webhook configurations
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /whatsapp/message_templates:
    post:
      tags:
        - Whatsapp Message Templates
      summary: Create a Whatsapp message template
      operationId: PostWhatsappTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WhatsappCreateTemplateRequest'
      responses:
        '201':
          $ref: '#/components/responses/WhatsappTemplateSingleResponse'
          description: Template created
        4XX:
          $ref: '#/components/responses/messaging_GenericErrorResponse'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const template = await client.whatsapp.templates.create({
              category: 'MARKETING',
              components: [{ format: 'TEXT', type: 'HEADER' }],
              language: 'language',
              name: 'name',
              waba_id: 'waba_id',
            });

            console.log(template.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            template = client.whatsapp.templates.create(
                category="MARKETING",
                components=[{
                    "format": "TEXT",
                    "type": "HEADER",
                }],
                language="language",
                name="name",
                waba_id="waba_id",
            )
            print(template.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\ttemplate, err := client.Whatsapp.Templates.New(context.TODO(), telnyx.WhatsappTemplateNewParams{\n\t\tCategory: telnyx.WhatsappTemplateNewParamsCategoryMarketing,\n\t\tComponents: []telnyx.WhatsappTemplateNewParamsComponentUnion{{\n\t\t\tOfHeader: &telnyx.WhatsappTemplateNewParamsComponentHeader{\n\t\t\t\tFormat: \"TEXT\",\n\t\t\t},\n\t\t}},\n\t\tLanguage: \"language\",\n\t\tName:     \"name\",\n\t\tWabaID:   \"waba_id\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", template.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.whatsapp.templates.TemplateCreateParams;

            import
            com.telnyx.sdk.models.whatsapp.templates.TemplateCreateResponse;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    TemplateCreateParams params = TemplateCreateParams.builder()
                        .category(TemplateCreateParams.Category.MARKETING)
                        .addHeaderComponent(TemplateCreateParams.Component.Header.Format.TEXT)
                        .language("language")
                        .name("name")
                        .wabaId("waba_id")
                        .build();
                    TemplateCreateResponse template = client.whatsapp().templates().create(params);
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            template = telnyx.whatsapp.templates.create(
              category: :MARKETING,
              components: [{format: :TEXT, type: :HEADER}],
              language: "language",
              name: "name",
              waba_id: "waba_id"
            )

            puts(template)
        - lang: CLI
          source: |-
            telnyx whatsapp:templates create \
              --api-key 'My API Key' \
              --category MARKETING \
              --component '{format: TEXT, type: HEADER}' \
              --language language \
              --name name \
              --waba-id waba_id
components:
  schemas:
    WhatsappCreateTemplateRequest:
      type: object
      required:
        - waba_id
        - name
        - category
        - language
        - components
      properties:
        waba_id:
          type: string
          description: The WhatsApp Business Account ID.
        name:
          type: string
          description: Template name. Lowercase letters, numbers, and underscores only.
        category:
          type: string
          enum:
            - MARKETING
            - UTILITY
            - AUTHENTICATION
          description: 'Template category: AUTHENTICATION, UTILITY, or MARKETING.'
        language:
          type: string
          description: Template language code (e.g. en_US, es, pt_BR).
        components:
          type: array
          description: >-
            Template components defining message structure. Passed through to
            Meta Graph API. Templates with variables must include example
            values. Supports HEADER, BODY, FOOTER, BUTTONS, CAROUSEL and any
            future Meta component types.
          items:
            oneOf:
              - $ref: '#/components/schemas/WhatsappTemplateHeaderComponent'
              - $ref: '#/components/schemas/WhatsappTemplateBodyComponent'
              - $ref: '#/components/schemas/WhatsappTemplateFooterComponent'
              - $ref: '#/components/schemas/WhatsappTemplateButtonsComponent'
              - $ref: '#/components/schemas/WhatsappTemplateCarouselComponent'
            description: >-
              A template component. Additional Meta component types not listed
              here are also accepted.
    WhatsappTemplateHeaderComponent:
      type: object
      description: Optional header displayed at the top of the message.
      required:
        - type
        - format
      properties:
        type:
          type: string
          enum:
            - HEADER
        format:
          type: string
          enum:
            - TEXT
            - IMAGE
            - VIDEO
            - DOCUMENT
            - LOCATION
          description: >-
            Header format type: TEXT (supports one variable), IMAGE, VIDEO,
            DOCUMENT, or LOCATION.
        text:
          type: string
          description: >-
            Header text. Required when format is TEXT. Supports one variable
            ({{1}}). Variables cannot be at the start or end.
        example:
          type: object
          description: Sample values for header variables.
          properties:
            header_text:
              type: array
              items:
                type: string
              description: Sample values for text header variables.
            header_handle:
              type: array
              items:
                type: string
              description: Media handle for IMAGE, VIDEO, or DOCUMENT headers.
    WhatsappTemplateBodyComponent:
      type: object
      description: >-
        The main text content of the message. Supports multiple variable
        parameters ({{1}}, {{2}}, etc.). Variables cannot be at the start or
        end. Maximum 1024 characters.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - BODY
        text:
          type: string
          description: >-
            Body text content. Use {{1}}, {{2}}, etc. for variable placeholders.
            Required for MARKETING and UTILITY templates. Optional for
            AUTHENTICATION templates where Meta provides the built-in OTP body.
          maxLength: 1024
        example:
          type: object
          description: >-
            Sample values for body variables. Required when body text contains
            parameters.
          properties:
            body_text:
              type: array
              description: >-
                Array containing one array of sample values, one per variable in
                order.
              items:
                type: array
                items:
                  type: string
    WhatsappTemplateFooterComponent:
      type: object
      description: >-
        Optional footer displayed at the bottom of the message. Does not support
        variables.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - FOOTER
        text:
          type: string
          description: >-
            Footer text. Maximum 60 characters. For non-authentication
            templates.
          maxLength: 60
        code_expiration_minutes:
          type: integer
          description: >-
            OTP code expiration time in minutes. Used in AUTHENTICATION template
            footers instead of free-form text.
    WhatsappTemplateButtonsComponent:
      type: object
      description: Optional interactive buttons. Maximum 3 buttons per template.
      required:
        - type
        - buttons
      properties:
        type:
          type: string
          enum:
            - BUTTONS
        buttons:
          type: array
          items:
            type: object
            required:
              - type
            properties:
              type:
                type: string
                enum:
                  - URL
                  - PHONE_NUMBER
                  - QUICK_REPLY
                  - OTP
                  - COPY_CODE
                  - FLOW
              text:
                type: string
                maxLength: 25
                description: >-
                  Button label text. Maximum 25 characters. Required for URL,
                  PHONE_NUMBER, and QUICK_REPLY buttons. Not required for OTP
                  buttons (Meta supplies the label).
              url:
                type: string
                description: URL for URL-type buttons. Supports one variable ({{1}}).
              phone_number:
                type: string
                description: Phone number in E.164 format.
              otp_type:
                type: string
                enum:
                  - COPY_CODE
                  - ONE_TAP
              example:
                type: array
                items:
                  type: string
                description: Sample values for URL variable.
              package_name:
                type: string
                description: Android package name. Required for ONE_TAP OTP buttons.
              signature_hash:
                type: string
                description: >-
                  Android app signing key hash. Required for ONE_TAP OTP
                  buttons.
              autofill_text:
                type: string
                description: Custom autofill button text for ONE_TAP OTP buttons.
              zero_tap_terms_accepted:
                type: boolean
                description: Whether zero-tap terms have been accepted.
              flow_id:
                type: string
                description: Flow ID for FLOW-type buttons.
              flow_action:
                type: string
                enum:
                  - navigate
                  - data_exchange
                description: Flow action type for FLOW-type buttons.
              navigate_screen:
                type: string
                description: Target screen name for FLOW buttons with navigate action.
          description: >-
            Array of button objects. Meta supports various combinations of
            button types.
    WhatsappTemplateCarouselComponent:
      type: object
      description: >-
        Carousel component for multi-card templates. Each card can contain its
        own header, body, and buttons.
      required:
        - type
        - cards
      properties:
        type:
          type: string
          enum:
            - CAROUSEL
        cards:
          type: array
          description: Array of card objects, each with its own components.
          items:
            type: object
            properties:
              components:
                type: array
                items:
                  type: object
    WhatsappTemplateData:
      type: object
      properties:
        id:
          type: string
        record_type:
          type: string
          example: whatsapp_message_template
        template_id:
          type: string
        name:
          type: string
        category:
          type: string
          enum:
            - MARKETING
            - UTILITY
            - AUTHENTICATION
        language:
          type: string
        status:
          type: string
          description: >-
            Current template status from Meta (e.g. PENDING, APPROVED, REJECTED,
            PAUSED, DISABLED). Additional statuses may be returned as Meta
            evolves the template lifecycle.
        rejection_reason:
          type: string
        components:
          type: array
          items:
            type: object
          description: >-
            Template components (header, body, footer, buttons) as submitted,
            including example values.
        whatsapp_business_account:
          type: object
          properties:
            id:
              type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    messaging_Errors:
      properties:
        errors:
          type: array
          items:
            $ref: '#/components/schemas/messaging_Error'
    messaging_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
          x-format: integer
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
              format: json-pointer
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
  responses:
    WhatsappTemplateSingleResponse:
      description: Successful response with Whatsapp template
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                $ref: '#/components/schemas/WhatsappTemplateData'
    messaging_GenericErrorResponse:
      description: Unexpected error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/messaging_Errors'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````