# Preview Message

&#x20;       You can check the amount of credits before actual sending SMS; this API function allows you easily calculate the total credits spending, also adjusting the message text to be aligned with cost.

### Sequence Diagram

![Sequence Diagram (API Preview)](https://1969967505-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1Zi-GfP5csjMyyZS2D%2F-M1yIhsflTgm2ZSSzXX-%2F-M1yujvhuswNJ8lkfhlu%2Ftt.png?alt=media\&token=19fce48a-8770-4ea4-9644-0d59b51daa84)

{% tabs %}
{% tab title="Request" %}
**You can start creating HTTP request as this following:**

| Header             | Description                                                                                                |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| HTTP Request (URL) | <https://api-service.ants.co.th/sms/preview>                                                               |
| HTTP Headers       | <p>Content-Type: application/json</p><p>Authorization: (Basic Auth) Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</p> |
| HTTP Methods       | POST                                                                                                       |

#### :exclamation: You must input at least 1 parameter. In this case; there is only "message"

| **Parameter** | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| message       | String | tText of the message that would be used to send. |

**The request will look like**

```
{
"message": "Let's see how many characters will remain unused in this message."
}
```

{% endtab %}

{% tab title="Response" %}
**Response**&#x20;

| Parameter       | Type   | Description                                                                                            |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| originalMessage | String | Original message that would like to preview                                                            |
| credit          | Number | SMS credit usage.                                                                                      |
| character       | String | How many characters are left ‘unspent’ in the message and if the message fits in one or more messages. |

**The JSON response will look like:**

```
{
"originalMessage": "Let's see how many characters will remain unused in this message.",
"credit":  "1.00",
"character": 65
}
```

{% endtab %}
{% endtabs %}
