Announcing MessageBird API on StdLib: Add SMS to Your Application in One Line of Code

Keith Horwood
Standard Library
Published in
8 min readMar 1, 2018

--

Hey everyone! Keith here from StdLib. It’s been a busy 2018 so far, and I’m super excited to announce something big we’ve been working on: we’re thrilled to introduce the MessageBird API on StdLib, initially rolling out for US and Canadian numbers. It’s been a fun journey to get here, and we think you’ll enjoy seamlessly adding SMS functionality (for customer communication, two-factor authentication and more) into your app using the world’s fastest global communication platform, MessageBird, with a simple, functional API on StdLib.

MessageBird + StdLib = ❤

StdLib and MessageBird, a Great Fit

StdLib’s vision has always been to provide a global platform for API development and publishing, where we’re turning APIs into simple, accessible components and integrations. Using new serverless architecture, it’s our goal to turn these APIs into first-class citizens of your development environment by abstracting away and replacing layers upon layers of outdated tooling.

Our partnership with MessageBird represents the first major enterprise step towards this vision since the launch of our platform. We knew from day one that in order to succeed we needed to become a valuable part of business-critical workflows and applications. Messaging is a huge part of customer communication, and MessageBird is best-in-business at providing this functionality — they work directly with global brands like Uber, Heineken and Domino’s and with a recent $60M fundraise from Accel Partners, have firmly cemented themselves as a force to be reckoned with.

Without further ado, we’re humbled and excited to introduce you to the MessageBird API powered by StdLib.

Using the MessageBird API powered by StdLib

If you’re a software developer by trade, StdLib has a great command line tool you can use to perform all of the steps listed here. However, you needn’t be a software veteran to start using MessageBird’s API on StdLib! You can claim a phone number and start sending messages directly from your web browser.

Step 1: Visit MessageBird’s Business Profile on StdLib

Simply visit https://stdlib.com/@messagebird in your browser. You should see a profile page that looks like the following:

MessageBird’s Profile on StdLib

This is MessageBird’s StdLib Profile. The green checkmark next to their name indicates they’re a trusted Enterprise partner and their APIs meet our platform’s standard for quality. A list of available APIs published by MessageBird are on the right. If you don’t see any, try clicking the API Library header first.

In order to get started, the first step is to initialize your first phone number, but first we’ll have to agree to the MessageBird terms of service. To do this, find the messagebird.numbers API on the right hand side of the screen and click on the name.

Find this API, and click on it. The version may be different since time of this publication — not a problem.

Step 2: Accept the Terms of Service for MessageBird APIs

Great, you found your way around StdLib profiles! (You even can create your own if you’d like — it’ll be generated when you create an account.) Now it’s time to initialize your first phone number, but first we’ll need to accept a Terms of Service (ToS). You should be on a page that looks like the following:

The API Reference Page for messagebird.numbers

This is the messagebird.numbers API reference page. If you can’t find this page, simply click here https://stdlib.com/@messagebird/lib/numbers/# to visit it.

From here, we can see a list of available API methods. (These are just things you can do with phone numbers!) Before we get started, you’ll notice a big orange notification (see above) indicating you need to accept a Terms of Service in order to use this API.

Why a Terms of Service?

Every API and Service Provider has terms they may need you to agree on before using their API (things like, in MessageBird’s case, “don’t send spam” and “don’t send messages to people that haven’t agreed to accept them”). StdLib provides an easy, automated way to set up a ToS and have developers and customers (like you right now!) agree to them.

Click the “click here” button to accept the Terms of Service

Upon clicking the link, you should be prompted to sign up for a StdLib account:

Registration Popup for StdLib

If you don’t see this — don’t worry! You’re likely already signed in. If you have an account already, hit the Already Registered? link in the bottom left. Otherwise, continue with Registration.

Once registered (or logged in), you should be prompted with a Terms of Service for MessageBird’s APIs. Follow the on-screen instructions to accept. When complete, you should see the following on the API page:

You’re all set!

Great! Now we can use all of MessageBird’s APIs. Let’s initialize that first number!

Step 3: Initialize your first Phone Number

Awesome. We’ve now accepted the MessageBird API ToS and we have a StdLib account to boot! Please make sure you’re on the numbers API Reference page before continuing: https://stdlib.com/@messagebird/lib/numbers/#

What you’re looking for is the initialize method. You can find it by scrolling down the page, or clicking initialize from the sidebar on the left.

Click “initialize” on the left or scroll down.

We now see the documentation for the numbers.initialize API. We’ll use this to claim our first number. But… wait a second. The documentation says Intended to be used after checking available numbers with the “available” method! Let’s head there first by clicking “available” on the left.

We should see a screen that looks roughly like this (you can also get here by clicking https://stdlib.com/@messagebird/lib/numbers/#available):

The documentation for the “available” API

From here, we can see a code example and a big green button on the right that says Run Function. See the dropdown to the right of the “Run Function” button? There first thing we’ll want to do is select a Library Token. If you’re logged in (you should be!), clicking on the dropdown should yield something like this:

Select one of your Library Tokens (there may only be one!)

Select a Library Token, and hit the Run Function button. You’ll be greeted with an output like the following:

A list of available numbers

Don’t lose this! Pick a number that you like (out of the ones shown), and copy it to your clipboard. Now you’ll want to go back to the numbers.initialize API and paste your number the the number field in the documentation.

If you can’t find the numbers.initialize API, simply click here: https://stdlib.com/@messagebird/lib/numbers/#initialize.

Enter in your Copied Number

Enter in your chosen number from the result of the numbers.available API above. Click Run Function, ensuring that the correct Library Token is selected from the Dropdown on the right (Unauthenticated won’t work!).

NOTE: If you run into an error, there’s a chance somebody else may have claimed your number first. Try again with a different number from numbers.available.

Congratulations! You have now received your first FREE number with the MessageBird API on StdLib. Additional numbers can be claimed for $0.99 from the numbers.claim API.

Step 4: Send your first SMS message

Sending an SMS message is now ultra simple. We’ve already used the StdLib documentation and web interface to (1) agree to a ToS, (2) read documentation, (3) run code examples, (4) use the result of previous API calls. You’re practically a pro at this!

We’ll need to navigate to the messagebird.sms API in order to send messages. You can do this by clicking it from the MessageBird API Library if you feel like testing your navigational skills, or you can simply click the following link: https://stdlib.com/@messagebird/lib/sms/.

The first thing you’ll notice is that you’ve already accepted the ToS for this API! Yes, multiple APIs can share the same ToS making authorization super simple. Nothing more to do here.

You’ve accepted this ToS already! It’s the same as the previous API.

The messagebird.sms API is fairly straightforward. Find the create method on the left and scroll to it:

The messagebird.sms.create documentation

You may notice the Pricing — $0.005 per request section in the docs. Yes, it costs $0.005 to send a text message with MessageBird — but don’t worry! Your account has been topped up with $5.00 in credits just for registering. That means you can send 1,000 messages for free!

Scroll a little further down to see the code examples and inputs for the function:

Enter in the recipient phone number and message body

Please note: sending messages with this API does not require you to specify an originator number, you’ll see it defaults to null, which means “nothing” — a number will be automatically selected if you don’t specify anything. Just put in a recipient number and a message body, hit Run Function (make sure a Library Token is selected from the dropdown), and voila!

The result of your messagebird.sms.create API call

On our phone we should get a brand new text message…

Padmé: lol new phone who dis?

That’s it!

You’ve now used the MessageBird API on StdLib to initialize a phone number and send a text message! Incorporating the API into your application is now trivial; simply copy the code examples from the right side of the documentation pages to use this API in any environment: Node.js, JavaScript, Ruby, Python or Shell (Command Line).

We hope you enjoy! If you have questions, feel free to reach out to me directly — keith [at] stdlib [dot com] or follow us on Twitter, @StdLibHQ or @keithwhor. You can also explore more of the StdLib documentation to build your own APIs and internal tools.

StdLib is a serverless platform for API publishing — automating local building, testing, deployment, hosting, documentation, SDK publishing, billing, rate limiting and more. Use StdLib to build and manage internal APIs or publish your own developer APIs. If you’d like to add your own API as part of our Enterprise Partnership program, get in touch — enterprise@stdlib.com.

Follow us on Twitter, @StdLibHQ and @keithwhor! We’re growing quickly, please don’t hesitate send us an e-mail at careers@stdlib.com if you’d be interested in joining our team.

--

--