How to schedule SMS using SCG Messaging API

 

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" format can be Epoch or ISO timestamp.

 

ISO timestamp

An example of an scheduled message via curl command:

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\":"2023-04-26T20:05:00.000Z",\
\"to\":[\"+5066173XXXX\"],\
\"body\":\"Test scheduled message using curl command and ISO timestamp\"}"

 

Epoch

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 milliseconds (13-digit).
  • A date command to convert from human date to epoch is:
    • $date +%s -d"2023-04-26T20:38:21.000Z"
    • $1682541501

As SCG need 13 digits Epoch we add 000 to finally send 1682541501000

Here is a curl command example to send a scheduled SMS at April 26, 2023 20:38:21 Z:

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\":1682541501000,\
\"to\":[\"+5066173XXXX\"],\
\"body\":\"Test scheduled message using curl command 13 digit\"}"

 

You can see the message’s “state” as “SCHEDULED”.

{
"application_id": 28886,
"company_id": [companyID],
"created_date": 1682541426344,
"last_updated_date": 1682541426344,
"version_number": 1,
"id": "zn32JIu61bIyhT1nqBcAX5",
"message_request_id": "zn32JIu61bIyhT1nqBcAX5",
"direction": "MT",
"customer_sender_id": "FVwXNFWghnXyBazsR1HxQ3",
"from_address": "7777",
"to_address": "+5066173XXXX",
"state": "SCHEDULED",
"body": "Test scheduled message 13 dig",
"attachments": [],
"scheduled_delivery_time": 1682541501000,
"channel_id": "Bxn9SHBYhl89KnuDllO2L4",
"type": "SMS",
"destination_country": "CRI",
"sender_id_alias": "FVwXNFWghnXyBazsR1HxQ3",
"fragments_info": [
{
"fragment_id": "jfecrcxl9kcTBlmp8a5za2",
"fragment_state": "CREATED"
}
],
"consent_requirement": "NONE",
"standalone": true,
"request_body": "Test scheduled message 13 dig",
"contact_delivery_address_priority": [],
"from": "channel:Bxn9SHBYhl89KnuDllO2L4",
"mediaURL_attachIds": [],
"to": "+50661731855",
"sender_id_sort_criteria": [],
"request_start_time": 1682541426319,
"fragmentMessageType": "SMS_MESSAGE"
}

Note:

Epoch timestamp: 1682541501 = Apr 26, 2023 2:38:21 PM GMT-6 = 2023-04-26T20:38:21.000Z

 

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:

Scheduled_SMS_checkbox.png

 

 

In the OUTBOX you can find the request details:

Scheduled_SMS_checkbox.png

 

 

 

Was this article helpful?
0 out of 0 found this helpful

0 Comments

Please sign in to leave a comment.