Send SMS/MMS with Delivery Receipts

Delivery Receipts (DLR) add two new states to the messaging lifecyle – delivered and not delivered. When a message is sent, it is sent by the SMPP gateway to the SMSC with the delivery receipt value set. The SMSC will return the final disposition of the message as determined by the carrier. Values returned include the following:

Error Code SMSC Description Bandwidth API Description Expose the error
0 Message Delivered to Carrier Message delivered to carrier Yes
187 Spam Detected – Statistical Statistical spam detected Yes
188 Spam Detected -Keyword Keyword spam detected Yes
189 Spam Detected Spam detected Yes
482 Loop Detected Loop detected Yes
600 Destination Carrier Queue Full Destination carrier could not accept messages Yes
610 submit_sm or submit_multi failed Message submission failed Yes
620 Destination App Error Destination application error Yes
630 NACK Message not acknowledge Yes
700 Invalid Service Type Invalid service type No
720 Invalid Destination Address Invalid destination number Yes
740 Invalid Source Address Invalid source number Yes
999 Unknown Error Unknown error Yes

The app platform will send a new event on delivery receipt based on the value of the new messages parameter, receiptRequested. The event will initially only be delivered on failure, but will, eventually allow an event for every receipt on every message.

Messages Resource

Property Type Description Default Values
receiptRequested string (1 – 16) Controls how delivery receipt events are delivered. The default value, no, will result in no delivery receipt events being generated. The value of yes will result in delivery receipts on failure, e.g. if the message is not delivered by the stage carrier. The value of all results in an per message, when the delivery receipts is available no none,all, error
State Remains unchanged
Delivery State Delivered/Not-Delivered
Delivery Code
Delivery Description

Example: Send SMS with delivery receipt

curl -v -X POST https://api.catapult.inetwork.com/v1/users/{userId}/ \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
        -d \
    '
    {
        "to": "+18284467788",
        "from": "+19197124466",
        "text": "Watch out for the construction on I-25 and Hwy 52",
        "receiptRequested" : "all",
        "callbackUrl" : "http://yourserver.com/message/dlr"
    }'
//NodeJS

var Bandwidth = require("node-bandwidth");

var client = new Bandwidth({
    userId    : "YOUR_USER_ID", // <-- note, this is not the same as the username you used to login to the portal
    apiToken  : "YOUR_API_TOKEN",
    apiSecret : "YOUR_API_SECRET"
});
var message = {
    from: "+19195551212",  // <-- This must be a Bandwidth number on your account
    to: "+191955512142",
    text: "Hello World",
    receiptRequested: "all",
    callbackUrl: "http://requestb.in",
    tag: Date.now().toString()
};

//Use Promises
client.Message.send(message)
.then(function(message) {
    console.log("Message sent with ID " + message.id);
})
.catch(function(err) {
    console.log(err.message);
});

//Use callbacks
client.Message.send(message, function(err, message) {
    if (err) {
        console.log(err);
        return;
    }
    console.log("Message sent with ID " + message.id);
});
//Download the .net sdk from ap.bandwidth.com/docs/helper-libraries/net

using System;
using System.Threading.Tasks;
using Bandwidth.Net;
using Bandwidth.Net.Api;

public class Program
{
  //API credentials which can be found on your account page at https://catapult.inetwork.com/pages/login.jsf
  private const string UserId = "u-userID"; //{user_id}
  private const string Token = "t-token"; //{token}
  private const string Secret = "secret"; //{secret}

  public static void Main()
  {
    try
    {
      RunAsync().Wait();
    }
    catch (Exception ex)
    {
      Console.Error.WriteLine(ex.Message);
      Environment.ExitCode = 1;
    }
  }

  private static async Task RunAsync()
  {
    var client = new Client(UserId, Token, Secret);

    await client.Message.SendAsync(new MessageData
    {
      From = "+19195551212",
        To = "+191955512142",
        Text = "Test",
        ReceiptRequested = MessageReceiptRequested.All,
        CallbackUrl = "http://requestb.in"
    });

  }
}

Callback events will be sent on each state transition.

{
    "eventType":"sms",
    "direction":"out",
    "messageId": "m-kv54fk7x66fakdnb5owdk4y",
    "messageUri": "https://api.catapult.inetwork.com/v1/users/<user-id>/messages/m-kv54fk7x66fakdnb5owdk4y",
    "from":"+13233326955",
    "to":"+13865245000",
    "text":"Example",
    "applicationId":"a-25nh2lj6qrxznkfu4b732jy",
    "time":"2012-11-14T16:13:06.076Z",
    "state":"not-delivered",
    “errorcode”:”720”,
    “error”:”Invalid Service Type”
}

results matching ""

    No results matching ""