Send SMS/MMS

This example shows you how to send an outbound SMS or MMS message to a mobile phone.

Graphic

Postman

Receive Incoming Messages

To recieve incoming text messages and multimedia messages. You must have the phonenumber assigned to an application with a valid messagingCallbackUrl. Learn how to configure incoming messages in this guide.

Example: Send a SMS

// find your credentials http://ap.bandwidth.com/docs/security/
// Replace from number with a Bandwidth Phone Number on your account
curl -v -X POST https://api.catapult.inetwork.com/v1/users/{userId}/messages \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
    -d '{"from": "+12525089000", "to": "+15035555555", "text": "Hello there from Bandwidth!"}'
// install sdk: npm install node-bandwidth

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"
};

//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);
});
var message = await client.Message.SendAsync(new MessageData {
    From = "+19195551212",
    To = "+19195551213",
    Text = "Thank you for susbcribing to Unicorn Enterprises!"
});
message = Message.create(client, {
    :from => "+19195551212",
    :to => "+19195551213",
    :text => "Thank you for susbcribing to Unicorn Enterprises!"
})

Example: Send a MMS (Picture Messaging)

// find your credentials http://ap.bandwidth.com/docs/security/
// Replace from number with a Bandwidth Phone Number on your account
curl -v -X POST https://api.catapult.inetwork.com/v1/users/{user-id}/messages \
    -u {token}:{secret} \
    -H "Content-type: application/json" \
    -d '{"from": "+12018994225", "to": "+12223334444", "text": "Hello there from Bandwidth!", "media":["https://s3.amazonaws.com/bwdemos/logo.png"]}'
// install sdk: npm install node-bandwidth

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: "Test",
    media: ["https://s3.amazonaws.com/bwdemos/logo.png"]
};

//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);
});
var message = await client.Message.SendAsync(new MessageData {
    From = "+19195551212",
    To = "+19195551213",
    Text = "Thank you for susbcribing to Unicorn Enterprises!",
    Media = new[] {"https://api.catapult.inetwork.com/v1/users/<user-id>/media/image-1.jpg"},
    CallbackUrl = "http://my.callback.url"
});
message = Message.create(client, {
    :from => "+19195551212",
    :to => "+19195551213",
    :text => "Thank you for susbcribing to Unicorn Enterprises!",
    :media => ["https://api.catapult.inetwork.com/v1/users/<user-id>/media/image-1.jpg"],
    :callback_url => "http://my.callback.url"
})

results matching ""

    No results matching ""