# Create template

Creates a template.

```http
POST https://api.pozy.ai/v1/whatsapp/templates
```

- Area: WhatsApp / WhatsApp
- Auth: Authorization: Bearer pz_live_...

## Request body

Content type: `application/json`

- `accountId`, string, required
- `name`, string, required: Matches `^[a-z][a-z0-9_]*$`
- `category`, string, required: One of `AUTHENTICATION`, `MARKETING`, `UTILITY`
- `language`, string, required
- `parameter_format`, string: One of `POSITIONAL`, `NAMED`, `positional`, `named`
- `components`, array of object: At least 1 item
  - one of: Whats App Header Component
    - `type`, string, required: One of `header`
    - `format`, string, required: One of `text`, `image`, `video`, `gif`, `document`, `location`
    - `text`, string
    - `example`, object
      - `header_text`, array of string
      - `header_text_named_params`, array of object
        - `param_name`, string, required: Matches `^[a-z0-9_]+$`
        - `example`, string, required
      - `header_handle`, array of string (URL): At least 1 item. Up to 1 items
  - one of: Whats App Body Component
    - `type`, string, required: One of `body`
    - `text`, string, required
    - `add_security_recommendation`, boolean
    - `example`, object
      - `body_text`, array of array of string
      - `body_text_named_params`, array of object
        - `param_name`, string, required: Matches `^[a-z0-9_]+$`
        - `example`, string, required
  - one of: Whats App Footer Component
    - `type`, string, required: One of `footer`
    - `text`, string
    - `code_expiration_minutes`, integer: At least 1
  - one of: Whats App Buttons Component
    - `type`, string, required: One of `buttons`
    - `buttons`, array of object, required: At least 1 item
      - `type`, string, required: One of `quick_reply`, `url`, `phone_number`, `otp`, `copy_code`, `flow`, `mpm`, `catalog`
      - `text`, string
      - `url`, string (URL)
      - `example`, any
      - `phone_number`, string
      - `otp_type`, string: One of `copy_code`, `one_tap`, `zero_tap`
      - `autofill_text`, string
      - `package_name`, string
      - `signature_hash`, string
      - `flow_id`, string
      - `flow_name`, string
      - `flow_json`, string
      - `flow_action`, string
      - `navigate_screen`, string
  - one of: Whats App Carousel Component
    - `type`, string, required: One of `carousel`
    - `cards`, array of object, required: At least 2 items. Up to 10 items
      - `components`, array of object, required: At least 1 item
        - one of: Whats App Header Component
          - `type`, string, required: One of `header`
          - `format`, string, required: One of `text`, `image`, `video`, `gif`, `document`, `location`
          - `text`, string
          - `example`, object
            - `header_text`, array of string
            - `header_text_named_params`, array of object
              - `param_name`, string, required: Matches `^[a-z0-9_]+$`
              - `example`, string, required
            - `header_handle`, array of string (URL): At least 1 item. Up to 1 items
        - one of: Whats App Body Component
          - `type`, string, required: One of `body`
          - `text`, string, required
          - `add_security_recommendation`, boolean
          - `example`, object
            - `body_text`, array of array of string
            - `body_text_named_params`, array of object
              - `param_name`, string, required: Matches `^[a-z0-9_]+$`
              - `example`, string, required
        - one of: Whats App Buttons Component
          - `type`, string, required: One of `buttons`
          - `buttons`, array of object, required: At least 1 item
            - `type`, string, required: One of `quick_reply`, `url`, `phone_number`, `otp`, `copy_code`, `flow`, `mpm`, `catalog`
            - `text`, string
            - `url`, string (URL)
            - `example`, any
            - `phone_number`, string
            - `otp_type`, string: One of `copy_code`, `one_tap`, `zero_tap`
            - `autofill_text`, string
            - `package_name`, string
            - `signature_hash`, string
            - `flow_id`, string
            - `flow_name`, string
            - `flow_json`, string
            - `flow_action`, string
            - `navigate_screen`, string
  - one of: Whats App Limited Time Offer Component
    - `type`, string, required: One of `limited_time_offer`
    - `limited_time_offer`, object, required
      - `text`, string, required: 1 to 16 characters
      - `has_expiration`, boolean
- `library_template_name`, string
- `library_template_body_inputs`, object
- `library_template_button_inputs`, array of object
  - `type`, string: One of `quick_reply`, `url`, `phone_number`
  - `url`, object
    - `base_url`, string
  - `phone_number`, string
- `message_send_ttl_seconds`, integer

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/whatsapp/templates" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9",
  "name": "Acme",
  "category": "AUTHENTICATION",
  "language": "en"
}'
```

```ts
const res = await fetch("https://api.pozy.ai/v1/whatsapp/templates", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9",
    name: "Acme",
    category: "AUTHENTICATION",
    language: "en"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/whatsapp/templates",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "name": "Acme",
        "category": "AUTHENTICATION",
        "language": "en",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `success`, boolean
- `template`, object
  - `id`, string
  - `name`, string
  - `status`, string
  - `category`, string
  - `language`, string
  - `message_send_ttl_seconds`, integer

```json
{
  "success": true,
  "template": {
    "id": "6bfebd43ddc270f6d2c56fc5",
    "name": "Acme",
    "status": "active",
    "category": "string",
    "language": "en",
    "message_send_ttl_seconds": 1
  }
}
```
