The SCG messaging API supports scheduled delivery of SMS messages at a specific moment in time. This enables the user to create & send SMS ahead of the intended delivery time.
This document describes how to use the SCG message_requests API method, specifically the field "scheduled_delivery_time" option in the request body to set the delivery time for a SMS message. It describes the field type: epoch time. For more information on epoch time follow the link https://www.epochconverter.com/
Requesting a scheduled SMS
Through the SCG Messaging API: The field "scheduled_delivery_time" requires the value for the required time to deliver the SMS to be in epoch format. As shown in this example:
- The epoch time is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT).
- Epoch time can be a timestamp in seconds (10-digit), milliseconds (13-digit) and microseconds (16-digit).
- the date command to convert from human date to epoch is :
$ date +%s -d"Jun 29, 2022 17:40:00"
1656546000
Here is an example Curl command to send a scheduled SMS at Jun 29, 2022 05:40:00 PM:
curl -L -X POST https://api.syniverse.com/scg-external-api/api/v1/messaging/message_requests \
-H "Content-Type: application/json" \
-H "Authorization: Bearer [TOKEN]" \
-d "{\"from\":\"channel:Bxn9SHBYhl89KnuDllO2L4\",\
\"scheduled_delivery_time\":1656546000,\
\"to\":[\"+5066173XXXX\"],\
\"body\":\"Test scheduled message using curl command 10 digit\"}"
You can see in the DR the message request’s “state” change from “SCHEDULED” to “SENT” in the scheduled time.
{
"topic": "SCG-Message",
"attempt": 1,
"event": {
"fld-val-list": {
"previous_state": "SCHEDULED",
"message_request_id": "A7gE4xn5JD17a1MvdnEwT2",
"message_id": "A7gE4xn5JD17a1MvdnEwT2",
"to_address": "+5066173XXXX",
"has_attachment": false,
"reason_description": "SUCCESS",
"application_id": 11407,
"reason_code": "200",
"sender_id_alias": "FVwXNFWghnXyBazsR1HxQ3",
"company-id": [company_id],
"sender_id_id": "FVwXNFWghnXyBazsR1HxQ3",
"external_message_request_id": "",
"new_state": "SENT",
"fragments_count": 1,
"from_address": "7777",
"mt_price": 0.024
},
"evt-tp": "message_state_change",
"timestamp": "2022-06-29T23:40:00.323Z"
},
"event-id": "uyrjt86vRnq2TR08c4xAwA"
}
Note:
Epoch timestamp: 1656567600 = June 29, 2022 5:40:00 PM GMT-06:00 = 2022-06-29T23:40:00.323Z
Scheduled messages can also be sent via the “Send message” option in the SCG Voice & Messaging console: Check the Scheduled message check box as shown here to enable the date and time for delivery:
In the OUTBOX you can find the request details:
0 Comments