Lifesycle Callback
This document describes the data structure and field descriptions of the message lifecycle state callback interface. The system will use HTTP POST to send state information to the URL configured by the customer when the message state changes.
Callback Method
- Request Method:
POST - Content-Type:
application/json - Successful Response: HTTP 200 or 204 status code
- Failure Retry: If the customer does not return a successful status code, the system will automatically retry
Data Structure
1. Outer Structure (ReportLifecycles)
{
"total": 1,
"rows": [
{
// Array of ReportLifecycle objects
}
]
}
| Field Name | Type | Description | Required |
|---|---|---|---|
total |
int64 | Total number of records | Yes |
rows |
array | Array of lifecycle state data | Yes |
2. ReportLifecycle Object
Each element in the rows array has the following structure:
| Field Name | Type | Description | Required |
|---|---|---|---|
message_id |
string | Message ID | Yes |
to |
string | Recipient number | Yes |
server |
string | Service type | Yes |
channel |
string | Channel type | Yes |
itime |
int64 | Callback timestamp (in seconds) | Yes |
custom_args |
map[string]any | Custom parameters (parameters passed during sending) | No |
status |
object | Status details object | No |
3. Status Object
Detailed status information object:
| Field Name | Type | Description | Required |
|---|---|---|---|
message_status |
string | Message status, e.g., sent, sent_fail, delivered, delivered_fail, verified, etc. |
Yes |
status_data |
object | Status data object, see below | Yes |
billing |
object | Billing information object, see below | No |
error_code |
int | Error code, 0 indicates no error | Yes |
error_detail |
object | Error details object, see below | No |
kwai_extra |
object | Kwai-specific extended information, see below | No |
Note: The following fields are for internal statistics and will not be included in the callback to the customer:
- Internal statistical analysis fieldanalysis
4. StatusData Object
Basic data related to the status:
| Field Name | Type | Description | Required |
|---|---|---|---|
msg_time |
int64 | Message creation timestamp (in seconds) | Yes |
message_id |
string | Message ID | Yes |
current_send_channel |
string | Current sending channel name | Yes |
template_key |
string | Template configuration key | Yes |
business_id |
string | Business ID | Yes |
Note: The following fields contain sensitive information or are internal fields and have been filtered out and will not be included in the callback to the customer:
- Message content (sensitive information)message_content- Number of message parts (internal field)parts- Message type (internal field)msg_type- Protocol type (internal field)protocol_type- Supplier IDs (sensitive information)supplier_ids
5. Billing Object
Billing information (returned only when billing data is available):
| Field Name | Type | Description | Required |
|---|---|---|---|
cost |
float64 | Cost amount (up to 4 decimal places) | Yes |
currency |
string | Currency, fixed as "USD" | Yes |
Note: The following fields are internal billing fields and will not be included in the callback to the customer:
- Internal billing field (unit: ten-thousandth)cost10000- Sender cost (unit: ten-thousandth)sender_cost10000
6. ErrorDetail Object
Error details (returned only when an error occurs):
| Field Name | Type | Description | Required |
|---|---|---|---|
message |
string | Error message description | Yes |
channel_code |
string | Original error code returned by the channel | Yes |
channel_message |
string | Original error message returned by the channel | Yes |
7. KwaiExtra Object
Kwai-specific extended information (returned only for delivery status and Kwai customers):
| Field Name | Type | Description | Required |
|---|---|---|---|
delivered_time |
int64 | Delivery timestamp (in milliseconds) | Yes |
parts |
int | Number of billing parts | Yes |
duration |
int64 | Call duration (in seconds), only available for voice messages | No |
Message Status Description
Common message status values:
| Status Value | Description |
|---|---|
sent |
Sent to the channel |
sent_fail |
Sending failed |
delivered |
Delivered to the user's terminal |
delivered_fail |
Delivery failed |
verified |
Verified by the user (e.g., OTP code used) |
Callback Examples
Example 1: Message Successfully Delivered
{
"total": 1,
"rows": [
{
"message_id": "123456789",
"to": "+8613800138000",
"server": "sms",
"channel": "sms",
"itime": 1701234567,
"custom_args": {
"order_id": "ORDER123",
"user_id": "USER456"
},
"status": {
"message_status": "delivered",
"status_data": {
"msg_time": 1701234560,
"message_id": "123456789",
"current_send_channel": "CHANNEL_A",
"template_key": "verify_code",
"business_id": "1001"
},
"billing": {
"cost": 0.005,
"currency": "USD"
},
"error_code": 0
}
}
]
}
Example 2: Message Sending Failed
{
"total": 1,
"rows": [
{
"message_id": "123456790",
"to": "+8613800138001",
"server": "sms",
"channel": "sms",
"itime": 1701234568,
"status": {
"message_status": "sent_fail",
"status_data": {
"msg_time": 1701234561,
"message_id": "123456790",
"current_send_channel": "CHANNEL_B",
"template_key": "verify_code",
"business_id": "1001"
},
"error_code": 4001,
"error_detail": {
"message": "Invalid phone number",
"channel_code": "INVALID_NUMBER",
"channel_message": "The phone number format is invalid"
}
}
}
]
}
Example 3: Message Delivery Failed (with Billing Information)
{
"total": 1,
"rows": [
{
"message_id": "123456791",
"to": "+8613800138002",
"server": "sms",
"channel": "sms",
"itime": 1701234570,
"custom_args": {
"campaign": "new_year_promo"
},
"status": {
"message_status": "delivered_fail",
"status_data": {
"msg_time": 1701234562,
"message_id": "123456791",
"current_send_channel": "CHANNEL_C",
"template_key": "marketing",
"business_id": "1001"
},
"billing": {
"cost": 0.0045,
"currency": "USD"
},
"error_code": 5002,
"error_detail": {
"message": "Phone number unreachable",
"channel_code": "UNREACHABLE",
"channel_message": "Subscriber absent"
}
}
}
]
}
Example 4: Kwai Customer Voice Message Delivered
{
"total": 1,
"rows": [
{
"message_id": "123456792",
"to": "+8613800138003",
"server": "voice",
"channel": "voice",
"itime": 1701234575,
"status": {
"message_status": "delivered",
"status_data": {
"msg_time": 1701234565,
"message_id": "123456792",
"current_send_channel": "VOICE_CHANNEL_A",
"template_key": "voice_verify",
"business_id": "2001"
},
"billing": {
"cost": 0.012,
"currency": "USD"
},
"error_code": 0,
"kwai_extra": {
"delivered_time": 1701234575000,
"parts": 1,
"duration": 45
}
}
}
]
}
Notes
Field Return Rules
- All fields marked as
omitemptywill not appear in the returned JSON if their values are empty or zero. - Sensitive information and internal fields have been filtered or cleared before the callback.
- All fields marked as
Security
- Message content (
message_content) will not be included in the callback to the customer. - Sensitive information such as supplier IDs (
supplier_ids) has been filtered. - Internal billing fields (
cost10000,sender_cost10000) will not be included.
- Message content (
Receiving Requirements
- The customer's callback interface must respond within 5 seconds.
- Must return HTTP 200 or 204 status code to indicate successful receipt.
- If other status codes are returned or a timeout occurs, the system will automatically retry.
Retry Mechanism
- Automatic retries will be performed after a callback failure.
- Retry intervals will gradually increase.
- Data will be stored in Redis during the retry period.
Timestamp Description
itime: The timestamp of the callback occurrence, in seconds.msg_time: The timestamp of message creation, in seconds.delivered_time: Kwai-specific field, delivery timestamp, in milliseconds.
Custom Parameters
- The
custom_argsfield will return the custom parameters passed when sending the message as-is. - If no custom parameters were passed during sending, this field will not appear in the callback data.
- The
Error Code Reference
Common error code descriptions (refer to the error code document for specific error codes):
| Error Code | Description |
|---|---|
| 0 | No error, operation successful |
| 4001 | Invalid phone number format |
| 4002 | Phone number does not exist |
| 5001 | Channel rejected |
| 5002 | User unreachable |
| 6001 | Network timeout |
For more detailed error code descriptions, please refer to the separate error code document.
Change Log
- 2024-01: Initial version
- Added support for the
kwai_extrafield for Kwai customers - Filtered sensitive information fields to enhance security










