# Callback Delivery Report

&#x20;       ใช้สำหรับผู้ใช้งานต้องการทราบข้อมูลสถานะการส่งผ่าน (Delivery Report) จาก Operator โดยผู้ใช้ทำการระบุ Parameter ( **notifyUrl** และ **notifyContentType**) ที่การ request API [Send](https://apidoc.ants.co.th/thai-v1.0.0/api-sms-1/api-sms) ระบบจะทำการส่งข้อมูล ดังนี้

### Sequence Diagram

![](https://980245403-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M1Zi-GfP5csjMyyZS2D%2F-M2CC9W3mIm3frrviuYv%2F-M2D9DFjJILpdb1Yj-Rd%2Fcall2.png?alt=media\&token=bf8b20e8-2769-44b3-b0d3-a84f66ec604e)

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

| **หัวข้อ**         | **รายละเอียด**                                                                                                                  |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| HTTP Request (URL) | <https://api-service.ants.co.th/sms/callback>                                                                                   |
| HTTP Headers       | <p>Content-Type: application/json หรือ application/xml</p><p>Authorization: (Basic Auth) Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</p> |
| HTTP Methods       | POST                                                                                                                            |

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

| **ตัวแปร Parameter** | **ประเภทข้อมูล** | **รายละเอียด**                                |
| -------------------- | ---------------- | --------------------------------------------- |
| bulkId               | String           | รหัสการส่งในแต่ละครั้ง                        |
| details              | Array            | ชุดข้อมูลกการตอบกลับ                          |
| messageId            | String           | รหัสอ้างอิงของแต่ละหมายเลข ในการส่งแต่ละครั้ง |
| to                   | String           | หมายเลขที่ได้รับข้อความ                       |
| from                 | String           | Sender Name ที่ส่ง                            |
| text                 | String           | ข้อความที่ส่งหาหมายเลขผู้รับ                  |
| credit               | Decimal          | จำนวน credit ที่ใช้                           |
| sendDate             | String           | วันที่ระบบส่ง SMS                             |
| doneDate             | String           | วันที่ข้อความส่งถึงหมายเลขปลายทาง             |
| status               | Array            | ชุดข้อมูลสถานะ                                |
| code                 | String           | รหัสสถานะการตอบกลับ                           |
| name                 | String           | ชื่อสถานะการตอบกลับ                           |
| description          | String           | รายละเอียดสถานะการตอบกลับ                     |
| callbackData         | String           | ค่าที่ต้องการให้ส่งกลับ                       |

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

```
 {
        "bulkId": "898319fa-34f0-49b7-a3b0-4235cc716a1f",
        "details": [
                {
                    "messageId": "25501288135972440649",
                    "to": "66123456789",
                    "from": "ANTS",
                    "text": "เชิญชวนร่วมกิจกรรม วิ่งการกุศล ANTS มาราธอน",
                    "credit": 1.00,
                    "sendDate": "2019-05-27T14:39:40.273",
                    "doneDate": "2019-05-27T14:40:09.44",
                    "status": {
                        "code": "000",
                        "name": "DELIVERED",
                        "description": "Successfully sent to phone"
                    },
                    "callbackData":"ANTS Data"
                },
                {
                    "messageId": "25501288135972440650",
                    "to": "66112233445",
                    "from": "Verify",
                    "text": "เชิญชวนร่วมกิจกรรม วิ่งการกุศล ANTS มาราธอน",
                    "credit": 1.00,
                    "sendDate": "2019-05-27T14:39:49.383",
                    "doneDate": "2019-05-27T14:40:09.66",
                    "status": {
                        "code": "000",
                        "name": "DELIVERED",
                        "description": "Successfully sent to phone"
                    },
                     "callbackData":"ANTS Data"
                }
        ]
} 

```

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

```
<?xml version="1.0" encoding="utf-16"?>
<CALLBACK xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <bulkId>9f4b72ca-0e28-4a7f-a6ff-d6483a17f3fa</bulkId>
    <details>
        <detail>
            <messageId>25501288135972440649</messageId>
            <to>66123456789</to>
            <from>Verify</from>
            <text>เชิญชวนร่วมกิจกรรม วิ่งการกุศล ANTS มาราธอน</text>
            <credit>1.00</credit>
            <sendDate>2019-05-27T14:39:40.273</sendDate>
            <doneDate>2019-05-27T14:40:09.44</doneDate>
            <status>
                <code>000</code>
                <name>DELIVERED</name>
                <description>Successfully sent to phone</description>
            </status>
            <callbackData>ANTS Data</callbackData>
        </detail>
        <detail>
            <messageId>25501288135972440650</messageId>
            <to>66112233445</to>
            <from>Verify</from>
            <text>เชิญชวนร่วมกิจกรรม วิ่งการกุศล ANTS มาราธอน</text>
            <credit>1.00</credit>
            <sendDate>2019-05-27T14:39:49.383</sendDate>
            <doneDate>2019-05-27T14:40:09.66</doneDate>
            <status>
                <code>000</code>
                <name>DELIVERED</name>
                <description>Successfully sent to phone</description>
            </status>
            <callbackData>ANTS Data</callbackData>
        </detail>
    </details>
</CALLBACK>
```

{% endtab %}

{% tab title="Response" %}
Response ตอบกลับผู้ใช้งาน เป็น HTTP Status Code ซึ่งส่วนใหญ่สถานะ จะแสดงเป็น 200 OK และ 404 Not Found ถ้าค่าเป็น 200 OK แสดงว่าข้อมูลส่งถูกต้อง

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

```http
200 OK
```

{% endtab %}
{% endtabs %}
