How do I set up a Messaging API account in the Bandwidth App?

Follow

Jessica Murray

Updated

In order to send messages with Bandwidth, you need the following pieces of information located in the Bandwidth App:

Username and password

These are the credentials you use to log into the Bandwidth App.

credentials.png

Account ID

Account ID is the number next to your account name. You can find it on the Account Overview page or in the top-left corner in the Bandwidth App.

account-id.png

Sub-account ID

In the side navigation bar, select Account and click Sub-Accounts. Select the Sub-account you want to use and enter the ID found next to its name into the Postman form. If you don't have a Sub-account, please follow these steps to create one.

sub-account.png

Messaging API Token and Secret

Bandwidth APIs use BASIC HTTP authentication. You'll need to have your Account ID, Token, and Secret to make API calls. You may already have a Token and Secret that you can enter into the Postman form, but if you need a new set of credentials, perform the following steps:

  1. In the side navigation bar, select Applications and click Applications. In the top-right corner of the page, click API Credentials.

create-application.png

  1. Click Create New to generate a new token and secret pair. They won't be visible after you leave this screen, so please store them securely for your use. You can return to this screen to add or delete token and secret pairs at anytime.

tokens-and-secrets.png

Create and associate an application with a Location

  1. Follow these steps to create you Messaging API application.
  2. To associate this application with phone number, you need to associate a Location with it first. If you have an existing Location, click Associate a Location with this application link. Otherwise, click Create a location and follow these steps.

associated-locations.png

Order a phone number

  1. Follow these steps to order a phone number that you can use to send text messages. Once your order has been completed, you'll land on the New Number Order Details page. 
  2. Scroll down the page until you see the number you ordered and click Copy to Clipboard to grab it. This is the number you'll use to send and receive messages with your application.mceclip6.png

Fill in the Postman Collection's environment variables

Have you downloaded Postman or have the ability to make an API request? Postman is an app for easy RESTful API exploration. In this guide, we'll use it to send messages using our new application.

Once you’ve downloaded Postman and created an account (if you don’t already have one), complete the Postman Collection environment variables:

  1. Select Collections to view the collection in Postman.
  2. Click the three dots highlighted in the screenshot below and select Edit.

ui5.png

  1. You'll see a window pop-up as shown in the screenshot below. Navigate to the Variables tab.

ui6.png

  1. Fill in the information under the Current Value fields. Postman will use these variables to fill in the relevant fields of your request. Once the variables are filled in, select Update.
    • accountId: Your account ID
    • apiToken: Your Bandwidth messaging Token
    • apiSecret: Your Bandwidth messaging Secret
    • messagingApplicationId: Your Bandwidth messaging application ID

Send a message

At this point you should have completed the following:

  • Downloaded Postman and filled out the Postman Collection form with your individual credentials, and potentially created a Sub-account and Location in this step.
  • Created an application.
  • Ordered phone number(s).

Let’s head over to Postman and see what it looks like to actually send a message:

  1. Open Postman and select Collections.
  2. Use the drop-down to open the Bandwidth Messaging Collection and click Send Text Messages.send_message.png
  3. Select POST Send Text Message and then click into the Authorization tab.
    • The Authorization will be pulled from your environment variables as added earlier in the guide.
    • Your Account ID and messaging Application ID will also be filled from the environment variables.
    • The value should read as inherit auth from parent

mceclip0.png

Now let’s move over to the Body tab in Postman.

  1. Enter the following information:
    • From: The number we ordered in the previous section of the guide
    • To: The number you’re sending the message to
    • Text: Update with the message you want to send
    • ApplicationID: The automatically generated value found in the Application ID field of your application in the Bandwidth App.
  2. Click Send. You should see a Status of 202 Accepted and a message completed to the receiving party.

Message parameters

Parameter

Mandatory

Description

from

Yes

One of your phone numbers the message should come from (must be in E.164 format, like +19195551212).

to

Yes

The phone number the message should be sent to (must be in E.164 format, like +19195551212).

text

Yes

The contents of the text message (must be 2048 characters or less).

applicationId

Yes

The ID of the application your from number is associated with in the Bandwidth App.

Related links

Article is closed for comments.