# 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)](/files/-M1yujvhuswNJ8lkfhlu)

{% 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidoc.ants.co.th/api-sms-1/preview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
