Development

Control And Time Your SMS Campaigns With A Flexible API

Having multiple options when scheduling your messages is a major factor in engaging communication practices.

April 27 2017

Optimize your marketing processes and inform customers about the latest promotions at the right time using the scheduling and validity period, but then go a step further. Use rescheduling and update the message status to make your business even more responsive to customer demands. Scheduling, along with other actions can be set via the Infobip portal web interface or with our SMS API.

Keeping customers well informed and satisfied can be accomplished through various channels, but if your preferred channel is SMS, you already know how important it is to develop a good marketing campaign and schedule messages to be delivered at the most appropriate time for customers.

Rescheduling bulk messages with SMS API

If you’re already using Infobip’s SMS API for sending out campaigns to your customers, these methods will give you more control over messages you send. You'll be able to revise their delivery schedule, message status and set the validity period.

To change the message sending time, you can easily use rescheduling. Rescheduling (and canceling) bulk messages is supported when an advanced SMS request contains only one message per bulk and the message "bulkId" is unique. If you don’t provide a "bulkId" through the initial SMS send request, the system will create a unique ID for you and include it as a "bulkId" in the response. The ID can be used later on, when you need to retrieve delivery information, change status, date or time of message delivery. Also, it is important to notice that multiple messages in one bulk send request can’t be updated, because each message may contain a different delivery date and time and have a different status.

To start rescheduling messages, you will need to put a JSON request with a "bulkId":

PUT /sms/1/bulks?bulkId=a6e6bf50-ade1-4dd5-8900-d5b3bb18c0cc HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json
{
    "sendAt": "2021-08-25T16:00:00.000+0000"
}

The response on this request would be:

{
  "bulkId": "a6e6bf50-ade1-4dd5-8900-d5b3bb18c0cc",
  "sendAt": "2021-08-26T16:00:00.000+0000"
}

2015-07-07T17:00:00.000+01:00 is the date and time format for SMS scheduling and rescheduling.

Updating message status

Updating the message status can sometimes come in handy - it can be used for pausing, resuming and/or canceling scheduled messages.

The "PENDING" status can be updated to: "PAUSED" and "CANCELED", while "PAUSED" can be updated to "PENDING" or "CANCELLED".

"PENDING" and "PAUSED" statuses can be changed as many times as you want before the message starts to process or, to be more precise, when the scheduled time is up and the message has been sent. But, if the message status is changed to "CANCELED", the message can’t be rescheduled or updated with a new status, so it would remain undelivered.

Updating the status can be done easily. If you want to update the status of message to "PAUSED", you can do it with a simple JSON request:

PUT /sms/1/bulks/status?bulkId=a6e6bf50-ade1-4dd5-8900-d5b3bb18c0cc HTTP/1.1
Host: api.infobip.com
Authorization: Basic b25lYXBpOnRoZUJveA==
Content-Type: application/json

{
    "status": "PAUSED"
}

With a JSON response:

{
  "bulkId": "a6e6bf50-ade1-4dd5-8900-d5b3bb18c0cc",
  "status": "PAUSED"
}

Setting up the validity period

Except rescheduling and updating the message status, the validity period can be very useful. It can be set while sending a fully featured textual message. It can be set for a maximum period of 48 hours, and if you put a longer period we automatically set it to 48 hours.

For setting up the validity period you need to post a JSON request:

POST /sms/1/text/advanced HTTP/1.1
Host: api.infobip.com
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Content-Type: application/json

{
   "messages":[
      {
         "from":"InfoSMS",
         "destinations":[
            {
               "to":"41793026727",
            },
            {
               "to":"41793026731"
            }
         ],
         "text":"The time-traveling is just too dangerous. Better that I devote myself to study the other great mystery of the universe: women!",
         "validityPeriod": 1440
      }
   ]
}

With a response

HTTP/1.1 200 OK
Content-Type: application/json

{
  "bulkId": "a6e6bf50-ade1-4dd5-8900-d5b3bb18c0cc",
  "messages": [
    {
      "to": "41793026727",
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 7,
        "name": "PENDING_ENROUTE",
        "description": "Message sent to next instance"
      },
      "smsCount": 1,
      "messageId": "239a1bed-91d0-4454-a437-6663938465aa"
    },
    {
      "to": "41793026731",
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 7,
        "name": "PENDING_ENROUTE",
        "description": "Message sent to next instance"
      },
      "smsCount": 1,
      "messageId": "77a6e601-c12d-4a66-8e16-d8ec8c5fbc03"
    }
  ]
}

Keep in mind that the validity period is listed in minutes. After you set the period, the message sending won’t be allowed after that period expires.

These are just some of our tips to get your business going and keep your customers happy. To learn more about integrations and different engagement channels visit our developer hub.

Start controlling your messages

Learn more