How do I set up a Messaging API account in the Bandwidth App?
FollowIn 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.
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.
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.
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:
- In the side navigation bar, select Applications and click Applications. In the top-right corner of the page, click API Credentials.
- 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.
Create and associate an application with a Location
- Follow these steps to create you Messaging API application.
- 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.
Order a phone number
- 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.
- 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.
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:
- Select Collections to view the collection in Postman.
- Click the three dots highlighted in the screenshot below and select Edit.
- You'll see a window pop-up as shown in the screenshot below. Navigate to the Variables tab.
- 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:
- Open Postman and select Collections.
- Use the drop-down to open the Bandwidth Messaging Collection and click Send Text Messages.
-
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
Now let’s move over to the Body tab in Postman.
-
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.
- 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. |
Article is closed for comments.