> For the complete documentation index, see [llms.txt](https://bitel.gitbook.io/bitel/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bitel.gitbook.io/bitel/sms/template-sms.md).

# Template SMS

Send SMS using predefined templates

In order to use predefined templates, register a template in your panel. once the template has been reviewed you can use the template using the following API

## Template SMS

<mark style="color:green;">`POST`</mark> `https://api.bitel.rest/api/v2/sms/template`

#### Request Body

| Name        | Type   | Description                                     |
| ----------- | ------ | ----------------------------------------------- |
| PhoneNumber | string | The target phone number                         |
| Params      | array  | The parameters to replace variables in template |
| TemplateId  | number | The id of the template in Bitel panel           |

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

```javascript
{
  "result": {
    "id": "5c6f6f7984d440d3a02663857447205a",
    "gatewayNumber": "10009909",
    "phoneNumber": "0912*******",
    "message": "Truth: Bitel is awesome",
    "requestDate": 1564573464,
    "status": 0,
    "statusText": "Waiting",
    "partCount": 1,
    "price": 0.0 // price is 0 because the message is waiting
  },
  "error": null
}
```

{% endtab %}
{% endtabs %}

#### Sample Request

```javascript
{
	"phoneNumber": "0912*******",
	"params": ["Bitel", "is", "awesome"],
	"templateId": 1234
}
```

#### Sample Response

```javascript
{
  "result": {
    "id": "5c6f6f7984d440d3a02663857447205a",
    "gatewayNumber": "10009909",
    "phoneNumber": "0912*******",
    "message": "Truth: Bitel is awesome",
    "requestDate": 1564573464,
    "status": 0,
    "statusText": "Waiting",
    "partCount": 1,
    "price": 0.0 // price is 0 because the message is waiting
  },
  "error": null
}
```

{% hint style="info" %}

#### **Getting SMS Status**

In order to get the detail of a request, including the delivery status, price  and more please refer to [**Sms Status**](/bitel/sms/sms-detail.md)  API.
{% endhint %}

#### Error Codes

| Code                | Description                                                                                                          |
| ------------------- | -------------------------------------------------------------------------------------------------------------------- |
| InvalidRequest      | Submitted data is invalid or missing, most likely the phone number                                                   |
| TemplateFormatError | The template variables don't match the given parameters, usually the number of parameters is less than the variables |
| InvalidTemplate     | The template doesn't exist                                                                                           |
| TemplatePending     | The template hasn't yet been reviewed                                                                                |
