> For the complete documentation index, see [llms.txt](https://docs.cartat.net/cartat-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cartat.net/cartat-api/whatsapp-official-api/templates/create-template-document.md).

# Create template document

```http
POST /template/
Authorization: Bearer <cartat_api_token>
Content-Type: application/json
```

Use a `DOCUMENT` header when the template needs an approved document example. Upload the document first with `POST /template/media`, then use the returned media handle in the template request.

### Example

```json
{
  "name": "invoice_document",
  "category": "UTILITY",
  "language": "en_US",
  "components": [
    {
      "type": "HEADER",
      "format": "DOCUMENT",
      "example": {
        "header_handle": ["uploaded_document_handle"]
      }
    },
    {
      "type": "BODY",
      "text": "Hi {{customer_name}}, your invoice document is attached.",
      "example": {
        "body_text_named_params": [
          {
            "param_name": "customer_name",
            "example": "John"
          }
        ]
      }
    }
  ]
}
```

### Required validation

| Field                                | Rule                                                              |
| ------------------------------------ | ----------------------------------------------------------------- |
| `name`                               | Required and must contain only letters, numbers, and underscores. |
| `category`                           | Required. Use `AUTHENTICATION`, `UTILITY`, or `MARKETING`.        |
| `components[].format`                | Required for headers. Use `DOCUMENT`.                             |
| `components[].example.header_handle` | Required for document headers.                                    |
