# Create a template (/docs/api-reference/whatsapp/createWhatsappTemplate)

> Create a message template on a direct Meta number and send it to WhatsApp for review.

> **Set up WhatsApp first.** Connect a WhatsApp number in the dashboard or with [Connect numbers](/docs/api-reference/whatsapp/importWhatsappNumbers). Included on every paid plan. [See plans](https://omnidim.io/pricing).

**POST** `/whatsapp/numbers/{number_id}/templates`

Create a message template on a direct Meta number and send it to WhatsApp
for review.

It answers the new template with status `pending`. WhatsApp usually
reviews it within minutes. Run `syncWhatsappTemplates` later to see the
result. Only an `approved` template can be sent.

The number must list `template_create` in its capabilities.

For an image or document header, upload the file with
`POST /whatsapp/media` first and pass its `media_id` in `header_media`.
AI assistants connected through MCP can't upload files, so they create
text headers only. Create a video header, an authentication template, or
a link that changes per message in the dashboard.

```yaml
operationId: createWhatsappTemplate
parameters:
  - in: path
    name: number_id
    required: true
    schema:
      type: integer
    description: |
      Id of a WhatsApp number in your workspace, from
      [listWhatsappNumbers](/docs/api-reference/whatsapp/listWhatsappNumbers).
      A number in another workspace answers `404`.
requestBody:
  required: true
  content:
    application/json:
      schema:
        type: object
        required:
          - name
          - language
          - category
          - body
        properties:
          name:
            type: string
            pattern: ^[a-z0-9_]{1,512}$
            description: >-
              Lower-case letters, digits and underscores, such as `order_update`. It must not be on
              the number already, in any language.
          language:
            type: string
            pattern: ^[a-z]{2,3}(_[A-Z]{2})?$
            description: WhatsApp language code, such as `en`, `en_US` or `hi`.
          category:
            type: string
            enum:
              - marketing
              - utility
            description: |
              `utility` is for an update the customer expects, such as an order or
              appointment. `marketing` is for anything else. WhatsApp can change the
              category when it reviews the template.
          header:
            type: string
            description: >-
              Optional header text. It can hold one placeholder, `{{1}}`. Send `header` or
              `header_media`, not both.
          header_media:
            type: object
            required:
              - type
              - media_id
            description: |
              Optional image or document header. Upload the file with
              `POST /whatsapp/media` first: the `media_id` works for 24
              hours. A header image is JPEG, PNG or WebP, and a header
              document is PDF, Word (.docx), Excel (.xlsx) or plain text.
              A header file is at most 5 MB. The file becomes a public link,
              because WhatsApp fetches header media from one, and every send
              of the template shows it.
            properties:
              type:
                type: string
                enum:
                  - image
                  - document
              media_id:
                type: string
                description: >-
                  The `media_id` from `POST /whatsapp/media`, uploaded with the same type and
                  number.
          header_example:
            type: string
            description: Sample value for the header's `{{1}}`. Required when the header has one.
          body:
            type: string
            description: |
              The message text. Placeholders are numbered from `{{1}}` with no
              gaps, such as `Hi {{1}}, your order {{2}} has shipped.`
          body_examples:
            type: array
            items:
              type: string
            description: >-
              One sample value per body placeholder, in order. Required when the body has
              placeholders.
          footer:
            type: string
            description: Optional footer text, with no placeholders.
          buttons:
            type: array
            minItems: 1
            maxItems: 10
            items:
              type: object
              required:
                - type
                - text
              properties:
                type:
                  type: string
                  enum:
                    - quick_reply
                    - url
                    - phone_number
                text:
                  type: string
                  description: The button label.
                url:
                  type: string
                  description: Required for `url`. A fixed link, with no placeholder.
                phone_number:
                  type: string
                  description: Required for `phone_number`, in international format, such as `+919876543210`.
        example:
          name: order_update
          language: en_US
          category: utility
          body: Hi {{1}}, your order {{2}} has shipped.
          body_examples:
            - Ravi
            - A12
          footer: Reply STOP to opt out
          buttons:
            - type: url
              text: Track order
              url: https://shop.example/track
responses:
  '201':
    description: The template was created and is waiting for review.
    content:
      application/json:
        schema:
          type: object
          properties:
            id:
              type: integer
            name:
              type: string
            language:
              type: string
              nullable: true
              description: Language code as WhatsApp returns it.
            category:
              type: string
              enum:
                - UTILITY
                - MARKETING
                - AUTHENTICATION
              nullable: true
            status:
              type: string
              nullable: true
              description: |
                Review status as the provider returns it, lower-cased. A send
                accepts only `approved`.
            rejected_reason:
              type: string
              nullable: true
              description: Why WhatsApp rejected it, when it did.
            body_preview:
              type: string
            header:
              type: object
              nullable: true
              description: The template's header, or null when it has none.
              properties:
                type:
                  type: string
                  description: Header format, such as `TEXT`, `IMAGE`, `VIDEO` or `DOCUMENT`.
                has_file:
                  type: boolean
                  description: A media file is stored on the header.
            fields:
              type: array
              description: The values you fill in when you send this template.
              items:
                type: object
                description: One value a send must provide for this template.
                properties:
                  key:
                    type: string
                    description: The field name to send under `template.params`.
                  label:
                    type: string
                    description: A human name for the field.
                  kind:
                    type: string
                    enum:
                      - text
                      - url
                    description: '`text` is a body or text-header value. `url` is a URL button suffix.'
                  required:
                    type: boolean
                  example:
                    type: string
                    nullable: true
            buttons:
              type: array
              items:
                type: object
                description: One button on this template. Only the keys the button has are present.
                properties:
                  type:
                    type: string
                    description: Button type, such as `URL`, `QUICK_REPLY` or `PHONE_NUMBER`.
                  text:
                    type: string
                  url:
                    type: string
                  phone_number:
                    type: string
            synced_at:
              type: string
              nullable: true
              description: When this template was last pulled from the provider.
  '400':
    description: |
      `invalid_parameter`: the draft is not valid, and the message says what
      to change. `template_rejected`: WhatsApp refused the template's
      content, and the message gives WhatsApp's reason.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
  '401':
    description: Missing or invalid API key.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
        example:
          error: unauthorized
          error_description: Missing or invalid API key
          code: invalid_api_key
          request_id: req_6e2b9d4f1a38
  '403':
    description: |
      `feature_not_enabled` when your plan or role cannot use WhatsApp,
      `permission_denied` when the key's user cannot make changes, or
      `service_unavailable` when the account is on hold.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
        example:
          error: forbidden
          error_description: You do not have permission to make changes to WhatsApp.
          code: permission_denied
          request_id: req_9f2c1a4b7d3e
  '404':
    description: |
      `number_not_found`: the number is not yours. `media_not_found`: no
      upload of that type has that `media_id` on this number, or it is
      older than 24 hours.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
  '409':
    description: |
      `template_exists`: a template with this name is already on the number,
      in any language. `not_supported`: this number cannot create templates.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
  '500':
    description: Something went wrong on our side. Quote `ref` to support.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
        example:
          error: server_error
          error_description: >-
            Something went wrong on our side. Please try again shortly, or contact support with
            reference 9a1f3e8b02c4.
          ref: 9a1f3e8b02c4
          code: server_error
          request_id: req_9a1f3e8b02c4
  '502':
    description: |
      A provider problem: `send_failed` (the message reached nothing),
      `template_sync_failed` (the template list is unchanged),
      `template_create_failed` (no template was made),
      `template_delete_failed` (the template is unchanged),
      `upstream_error` (a calling change), as `502`.
    content:
      application/json:
        schema:
          type: object
          description: |
            The error envelope for every WhatsApp route. Some errors add keys:
            `fields` (the template parameters a send still needs), `ref` (a
            500's support reference) and `failed` (on `import_failed`).
          properties:
            error:
              type: string
              description: Machine-readable category, such as `invalid_request`.
            error_description:
              type: string
              description: Human-readable explanation.
            code:
              type: string
              description: Stable, specific reason, such as `window_closed`.
            request_id:
              type: string
              description: >-
                Correlates this response with the server log. Also sent as the `X-Request-Id`
                header.
            fields:
              type: array
              items:
                type: string
              description: >-
                On a template send missing parameters (`missing_fields`), the field keys you still
                need.
            ref:
              type: string
              description: On a `500`, the reference to quote to support.
            failed:
              type: array
              items:
                type: object
                properties:
                  phone_number_id:
                    type: string
                  message:
                    type: string
                    example: >-
                      This WhatsApp number is already connected to another account. Disconnect it
                      there first, then import it again. Contact support if you cannot access that
                      account.
              description: On `import_failed`, each number and why it could not be connected.
        example:
          error: bad_gateway
          error_description: The message could not be handed to WhatsApp. Nothing was sent or charged.
          code: send_failed
          request_id: req_3a9c6e1d8b52
```

**curl**

```bash
curl -X POST "https://omnidim.io/api/v1/whatsapp/numbers/{number_id}/templates" \
  -H "Authorization: Bearer $OMNIDIM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "order_update",
  "language": "en_US",
  "category": "utility",
  "body": "Hi {{1}}, your order {{2}} has shipped.",
  "body_examples": [
    "Ravi",
    "A12"
  ],
  "footer": "Reply STOP to opt out",
  "buttons": [
    {
      "type": "url",
      "text": "Track order",
      "url": "https://shop.example/track"
    }
  ]
}'
```