# Create WhatsApp template

URL: https://docs.dixa.io/openapi/dixa-api/beta/whatsapp-templates/postwhatsapptemplates

Create a new WhatsApp template. The template body is limited to 1024 characters.

## POST /beta/whatsapp/templates

- Server: https://dev.dixa.io
- Auth: `Authorization: <API token>` header

### Request example

Text template:

```bash
curl -X POST 'https://dev.dixa.io/beta/whatsapp/templates' \
  -H 'Authorization: <API token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "order_confirmation",
  "language": "en",
  "templateType": {
    "body": "Your order {{1}} has been confirmed.",
    "_type": "Text"
  },
  "category": "UTILITY",
  "variables": {
    "1": "12345"
  }
}'
```

Text template without variables:

```bash
curl -X POST 'https://dev.dixa.io/beta/whatsapp/templates' \
  -H 'Authorization: <API token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "office_closed",
  "language": "en",
  "templateType": {
    "body": "Our office is closed today.",
    "_type": "Text"
  },
  "category": "UTILITY"
}'
```

Media template:

```bash
curl -X POST 'https://dev.dixa.io/beta/whatsapp/templates' \
  -H 'Authorization: <API token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "shipping_update",
  "language": "en",
  "templateType": {
    "body": "Your package {{1}} has shipped and will arrive on {{2}}.",
    "mediaUrl": "https://example.com/brand-logo.jpg",
    "_type": "Media"
  },
  "category": "MARKETING",
  "variables": {
    "1": "PKG-9876",
    "2": "2026-08-01"
  }
}'
```

### Response examples

#### 201 The created WhatsApp template

```json
{
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}
```

#### 400

```json
{
  "message": "Decoding failure in request"
}
```

#### 404 An entity in this request could not be found

```json
{
  "message": "The requested resource could not be found"
}
```

#### 500 Internal failure during request processing

```json
{
  "message": "There was an internal server error while processing the request"
}
```

## OpenAPI definition

The operation and the schemas used, from the full spec at https://docs.dixa.io/openapi-specs/dixa-beta.yaml. Request and response examples are above.

```yaml
openapi: 3.0.3
info:
  title: Dixa API
  version: beta
servers:
  - url: https://dev.dixa.io
security:
  - ApiKeyAuth: []
paths:
  /beta/whatsapp/templates:
    post:
      tags:
        - WhatsApp Templates
      summary: Create WhatsApp template
      description: Create a new WhatsApp template. The template body is limited to
        1024 characters.
      operationId: postWhatsappTemplates
      requestBody:
        description: The WhatsApp template to create
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTemplateInput"
        required: true
      responses:
        "201":
          description: The created WhatsApp template
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateWhatsappTemplateOutput"
        "400":
          description: ""
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/BadRequest"
        "404":
          description: An entity in this request could not be found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/NotFound"
        "500":
          description: Internal failure during request processing
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ServerError"
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: Authorization
      in: header
  schemas:
    CreateTemplateInput:
      title: CreateTemplateInput
      type: object
      required:
        - name
        - language
        - templateType
        - category
      properties:
        name:
          description: Template name; may only contain lowercase letters, digits, and
            underscores
          type: string
        language:
          description: "Supported language codes: ar, bg, hr, cs, da, nl, en, et, fi, fr,
            de, el, he, hu, it, ja, ko, lv, lt, nb, pl, ro, ru, sr, sk, sl, es,
            sv, th, tr, uk, pt_PT, zh_CN, zh_TW, zh_HK"
          type: string
        templateType:
          $ref: "#/components/schemas/TemplateTypeInput"
        category:
          description: "values: [UTILITY, MARKETING]"
          type: string
        variables:
          $ref: "#/components/schemas/Map_String"
          description: "Sample values for the template's placeholders (e.g. {\"1\":
            \"John\"}), submitted to WhatsApp as example content during template
            approval. Omit for a template whose body has no placeholders."
    TemplateTypeInput:
      title: TemplateTypeInput
      description: Template body and type; use Text for text-only messages, Media for
        messages with an attachment
      oneOf:
        - $ref: "#/components/schemas/Media"
        - $ref: "#/components/schemas/Text3"
    Media:
      title: Media
      type: object
      required:
        - body
        - mediaUrl
      properties:
        body:
          description: Template body text; maximum 1024 characters
          type: string
        mediaUrl:
          type: string
    Text3:
      title: Text
      type: object
      required:
        - body
      properties:
        body:
          description: Template body text; maximum 1024 characters
          type: string
    Map_String:
      title: Map_String
      type: object
      additionalProperties:
        type: string
    CreateWhatsappTemplateOutput:
      title: CreateWhatsappTemplateOutput
      type: object
      required:
        - data
      properties:
        data:
          $ref: "#/components/schemas/CreateTemplateOutput"
    CreateTemplateOutput:
      title: CreateTemplateOutput
      type: object
      required:
        - id
      properties:
        id:
          type: string
    BadRequest:
      title: BadRequest
      type: object
      required:
        - message
      properties:
        message:
          type: string
    NotFound:
      title: NotFound
      type: object
      required:
        - message
      properties:
        message:
          type: string
    ServerError:
      title: ServerError
      type: object
      required:
        - message
      properties:
        message:
          type: string
```
