> For the complete documentation index, see [llms.txt](https://apidoc.ants.co.th/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidoc.ants.co.th/api-sms-1/preview.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
