# Templates

{% hint style="warning" %}
**Note**: Templates can be created and managed entirely through the Channel360 frontend.

Using the API is optional and only required if you are building your own frontend or need to automate template creation.

**This section can be skipped when getting started.**
{% endhint %}

{% content-ref url="../../channel360-guide/templates/template-creation" %}
[template-creation](https://docs.channel360.co.za/channel360-guide/templates/template-creation)
{% endcontent-ref %}

***

## A template consists of...

### 1. Meta Data

{% stepper %}
{% step %}

### name

The name of your template.

* Requests must have a unique name / language pair
* <mark style="color:blue;">`name`</mark> can only contain lowercase, underscore characters, and numbers
  {% endstep %}

{% step %}

### description

Give your template a description (like what it's for).
{% endstep %}

{% step %}

### language

The language the template is in, if the language of the template does not match the language chosen, META will reject the template. &#x20;

Supported Languages:  [META Documentation](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/supported-languages/)
{% endstep %}

{% step %}

### category

Each template can be one of three categories, each having their own rules&#x20;

* MARKETING
* UTILITY
* AUTHENTICATION
  {% endstep %}

{% step %}

### status

When a template is created, it will be given a PENDING status and then META will either APPROVE or REJECT the template. &#x20;

* PENDING
* APPROVED
* REJECTED

Reasons for Rejection: [META Documentation](https://developers.facebook.com/docs/whatsapp/message-templates/guidelines/)
{% endstep %}
{% endstepper %}

### 2. Components

A templates structure is determined by its components . The request can have up to four objects, either HEADER, BODY, FOOTER or BUTTONS.

{% hint style="warning" %}
AUTHENTICATION Templates have their own rules.  See link below.
{% endhint %}

{% content-ref url="templates/create-templates" %}
[create-templates](https://docs.channel360.co.za/api-usage/using-the-channel360-v1.1-api/templates/create-templates)
{% endcontent-ref %}

{% tabs %}
{% tab title="HEADER" %}

* Optional
* Maximum of 1 tag
* Must have a format of either TEXT, DOCUMENT, IMAGE, VIDEO
* Limited to 60 Characters
* The image format will require an example image url from <https://www.channel360.co.za>/api/templates/upload. The url must then again be used in campaign creation as a tag.
  {% endtab %}

{% tab title="BODY" %}

* Required
* Can have multiple tags
* Limited to 1024 characters
  {% endtab %}

{% tab title="FOOTER" %}

* Optional
* Limited to 60 characters
  {% endtab %}

{% tab title="BUTTONS" %}

* Optional
* Limited to 25 characters
* Maximum of 1 tag
  {% endtab %}
  {% endtabs %}

{% tabs %}
{% tab title="Header Tags " %}
Headers don't need an example property, you simply add the parameter and off you go:

```
{
   "type":"HEADER",
   "format":"TEXT",
   "text":"Hello {{1}}",
   "example":{
      "header_text":[
         "Pete"
      ]
   }
}
```

{% endtab %}

{% tab title="Body Tags" %}
Body requires an example:

```
{
   "type":"BODY",
   "text":"Is this your number {{1}}? We would love to give you a call!",
   "example":{
      "body_text":[
         [
            "0852345678"
         ]
      ]
   }
}

```

{% endtab %}

{% tab title="Button Tags" %}
Button requires an example:

```
 {
     "type": "BUTTONS",
     "buttons": [
     {
                "type": "URL",
                "text": "View Dashboard",
                "url": "https://channel360.co.za/organization/{{1}}",
                "example": [
                    "639700347749ed00181de224"
                ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### 3. Tags

Tags are used in conjunction with the component parameters. They are essentially a means to add dynamic data into the HEADER, BODY and BUTTONS.

{% hint style="info" %}

> Tags can be created for the HEAD, BODY and BUTTONS content types

* *index should start at 1 and increment up*
* *index of tag should match the order that you want to populate replacement tags for the HEAD / BODY / BUTTONS*
  {% endhint %}

## Tag Structure

```
head: [
    {
        index: number;
        type: string;
        value?: string;
        url?: string;
        prompt?: string;
        fields?: string[]; //used for csv fields or subscriber fields depending on type
    }
];
body: [
    {
        index: number;
        type: string;
        value?: string;
        url?: string;
        prompt?: string;
        fields?: string[]; //used for csv fields or subscriber fields depending on type
    }
];
```

## Tag Fields

<table><thead><tr><th width="177">Field</th><th>Description</th><th>Notes</th></tr></thead><tbody><tr><td>index</td><td>Indexed used to populate replacement tags in template</td><td>Head and body</td></tr><tr><td>type</td><td>Type of Tag (see below)</td><td>The head tags cannot be populated with a csv</td></tr><tr><td>value</td><td>Used to store the value for 'hard-coded/on-campaign-creation' fields</td><td></td></tr><tr><td>url</td><td>Used to specify the url for tag types ( csv | image, video)</td><td>The following endpoint should be used to upload any files required by templates: <mark style="color:blue;"><code>{{url}}/v1.1/templates/upload</code></mark> This endpoint returns a list of the uploaded files along with their public url which must be specified</td></tr><tr><td>prompt</td><td>Used to populate the prompt when assigning a value to this tag on campaign creation</td><td>Used for csv/subscriber fields</td></tr><tr><td>fields</td><td>Array of fields to be used for tag replacement</td><td></td></tr></tbody></table>

## Tag Types

<table><thead><tr><th width="166">Option</th><th width="263">Description</th><th>Notes</th></tr></thead><tbody><tr><td>csv</td><td>CSV Merge file uploaded to s3 and url saved against record</td><td>populate <mark style="color:blue;"><code>fields</code></mark> with the desired field + populate <mark style="color:blue;"><code>url</code></mark> with the <mark style="color:blue;"><code>key</code></mark> returned by <mark style="color:blue;"><code>{url}/v1.1/templates/upload</code></mark></td></tr><tr><td>hard-coded</td><td>Hard Coded value (setup at on template creation)</td><td>populate <mark style="color:blue;"><code>value</code></mark> field with string value</td></tr><tr><td>on-campaign-creation</td><td>On Campaign Creation</td><td>populate the <mark style="color:blue;"><code>value</code></mark> with the text you would like to use when passing the tags object on campaign creation</td></tr><tr><td>image</td><td>Image uploaded to s3 and url saved against record</td><td>populate <mark style="color:blue;"><code>url</code></mark> field with the <mark style="color:blue;"><code>location</code></mark> returned by <mark style="color:blue;"><code>{url}/v1.1/templates/upload</code></mark></td></tr><tr><td>video</td><td>Image uploaded to s3 and url saved against record</td><td>populate <mark style="color:blue;"><code>url</code></mark> field with the <mark style="color:blue;"><code>location</code></mark> returned by <mark style="color:blue;"><code>{url}/v1.1/templates/upload</code></mark></td></tr><tr><td>subscriber-field</td><td>Subscriber field to use for tag replacement</td><td>populate <mark style="color:blue;"><code>fields</code></mark> with the subscriber field you want to replace - currently available fields are as follows: <mark style="color:blue;"><code>mobileNumber, firstName, lastName</code></mark></td></tr></tbody></table>

## Upload endpoint.

This endpoint allows you to upload a media file for later use in your templates.

<mark style="color:yellow;">`POST`</mark> `https://www.channel360.co.za/v1.1/org/:orgId/templates/upload`

Body Parameters

| Field  | Type | Description                               |
| ------ | ---- | ----------------------------------------- |
| `file` |      | The file name of the media being uploaded |

## Ingest Template

This endpoint updates your list of templates with META's list of your templates.

<mark style="color:yellow;">`POST`</mark> `https://www.channel360.co.za/v1.1/org/{{orgId}}/whatsapp/templates/refresh`

#### **Path Parameters**

| Field | Description         |
| ----- | ------------------- |
| orgId | The Organization ID |

#### **Body Parameters**

| Field  | Description                               |
| ------ | ----------------------------------------- |
| `file` | The file name of the media being uploaded |

#### Response Example

```json
{
    "message": "Templates Successfully Synced",
    "data": [
        [],
        []
    ]
}
```

***

## Want to get your Template approved?

The link below specifies all that needs to be known about getting your templates approved.

### Get your template approved

{% embed url="<https://developers.facebook.com/docs/whatsapp/message-templates/guidelines/>" %}
Get started in&#x20;
{% endembed %}

{% hint style="warning" %}
WhatsApp has rules! We cannot just make any message we want and send them off to millions of people. It must meet the criteria. Only then can we send millions of messages.
{% endhint %}
