You can specify an HTTP URL to receive SMS delivery reports. When you send a text message using the SendSms or SendBatchSms operation, the platform pushes the delivery report to that URL. You must then accept the pushed message and respond in the required format.
Usage notes
To receive SMS delivery reports over HTTP, enable the HTTP batch push mode for Status Report Receiving and configure a Receiving Address in the Short Message Service console. For more information, see Delivery receipt configuration.
Parameter description
The parameters are in a JSON array format. Delivery receipts do not distinguish between single and batch messages. A single request may contain multiple delivery reports.
Protocol description
Parameter | Description |
Request protocol | HTTP |
Request format | application/json |
Encoding | UTF-8 |
Parameter example
[
{
"phone_number" : "1381111****",
"send_time" : "2017-01-01 00:00:00",
"report_time" : "2017-01-01 00:00:00",
"success" : true,
"err_code" : "DELIVERED",
"err_msg" : "The user received the message successfully.",
"sms_size" : "1",
"biz_id" : "12345********",
"out_id" : "67890**"
}
]Field description
Name | Type | Description |
phone_number | String | The mobile phone number. |
send_time | String | The time when the message was sent. |
report_time | String | The time the status was reported. |
success | Boolean | Indicates whether the message was successfully received. Valid values:
|
err_code | String | The status report code. |
err_msg | String | The description of the status report. |
sms_size | String | The length of the text message. For more information about how the length of a text message is calculated, see SMS sending rules. |
biz_id | String | The ID of the delivery receipt, which is also the sending serial number. This is the BizId field in the response that is returned after you call the SendSms or SendBatchSms operation. If you send messages in a batch, the same BizId is returned. You can view the batch sending records. The BizId is unique for each request batch under the same Alibaba Cloud account.
|
out_id | String | The user-defined serial number. |
Response description
After your HTTP URL receives the request, you must respond in the following format.
Response example
{
"code" : 0,
"msg" : "Received successfully"
}Field description
Name | Type | Required | Example | Description |
code | Number | Yes | 0 | Acknowledgement code. The system only checks if the code is a number and does not validate its content. |
msg | String | No | Accepted successfully | Description. |
If the HTTP status code is 200, the request is successful. If the HTTP status code is not 200 or a timeout occurs, the system retries the push.
If a system error or consumption failure occurs, return an HTTP 50X status code.
Push retries
If a push fails, the system retries after 1 minute, 5 minutes, and 10 minutes. If the push still fails after these three attempts, the system does not retry.
Report receiving example
@PostMapping("/resMsg")
public JSONObject resMsg(@RequestBody JSONArray array) {
// TODO: You must process the delivery receipt message. This example only prints the receipt information.
System.out.println(array.toJSONString());
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "Received successfully");
return json;
}