# Preview Message

&#x20;       ใช้สำหรับนับจำนวนข้อความก่อนส่ง SMS จริงได้ เพื่อตรวจสอบจำนวนข้อความและเครดิตทั้งหมด รวมทั้งจำนวนตัวอักษรที่ส่งโดยไม่มีค่าใช้จ่าย ซึ่งช่วยให้ผู้ใช้สามารถปรับ แก้ไข และประมาณการค่าใช้จ่ายก่อนส่งจริงได้อย่างแม่นยำมากยิ่งขึ้น

### Sequence Diagram

![รูปภาพ Sequence Diagram (API Preview)](/files/-M1yujvhuswNJ8lkfhlu)

{% tabs %}
{% tab title="Request" %}
**ผู้ใช้งานสามารถเริ่มสร้าง HTTP ตามรายละเอียดดังนี้**

| **หัวข้อ**         | **รายละเอียด**                                                                                             |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| 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                                                                                                       |

**ผู้ใช้งานต้องระบุ Request body ด้วย Parameter ดังนี้**

| **Parameter** | **ประเภทข้อมูล** | **รายละเอียด**                        |
| ------------- | ---------------- | ------------------------------------- |
| message       | String           | ข้อความที่ต้องการจะส่งหาหมายเลขผู้รับ |

**ตัวอย่าง Request JSON**

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

{% endtab %}

{% tab title="Response" %}
**Response ตอบกลับผู้ใช้งาน ดังนี้**

| ชุดข้อมูลผลลัพธ์ | ประเภทข้อมูล | รายละเอียด                                         |
| ---------------- | ------------ | -------------------------------------------------- |
| originalMessage  | String       | ข้อความดั้งเดิมที่ผู้ใช้ส่งเข้ามาเพื่อดูผล preview |
| credit           | Number       | จำนวนข้อความที่จะถูกใช้ในการส่ง                    |
| character        | String       | จำนวนตัวอักษรที่จะถูกส่ง                           |

**ตัวอย่าง Response JSON**

```
{
"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/thai-v1.0.0/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.
