Replace Twilio API Explorer with Bruno, an Open Source API Client

Users upgrading to Bruno API client on their laptops
December 13, 2023
Written by
Alex Chun
Twilion
Reviewed by
Paul Kamp
Twilion

Twilio provides straightforward communication REST APIs with great documentation. In addition, developers have long used Twilio’s API explorer to get started building applications. However, on December 15th, 2023 we will End Of Life the tool.

In this post, we will learn to use Bruno, an Open Source API client as an API Explorer replacement.

Why an API client?

With an API client, developers can make requests to our REST API, explore responses from Twilio’s servers, and copy code snippets for use in their applications. A developer can test operations such as buying a phone number, sending a text message, or making a phone call programmatically before writing a lot of code.

This process ensures that building powerful telephony applications is a seamless process, and gives developers confidence to integrate the right Twilio APIs into whatever application they are building.
In this blog post, I will show you how to send an SMS without coding using Bruno as the API client.

Prerequisites

  • Twilio Account: Set up a Twilio Account (if you don’t have one yet,sign up for a free Twilio Trial)
  • Phone Number: Note that most countries have differing registration requirements depending on number type. For some API operations, you’ll need to complete those requirements before exploring API calls.
  • Twilio OpenAPI Specification: Download Twilio’s OpenAPI Specifications and unarchive them into a working directory on your local computer. We will need to import this into Bruno.
  • Bruno - Download: Install the latest version of Bruno for your Operating System
  • Mobile Phone: A SMS-capable device to receive your test message

Set up Bruno

Import Twilio OpenAPI Specifications into a Bruno Collection

Open the Bruno Application. Navigate to Import Collection.

Import a Collection inside Bruno

Now, click Import Collection.

Import an OpenAPI spec from Twilio inside Bruno

Select OpenAPI V3 Spec in the opened dialog box.

Browse to your location where you extracted the Twilio OpenAPI Specifications. The Twilio OpenAPI Specification file twilio_api_v2010.json is located in the folder twilio-oai-<version> -> spec -> json -> twilio_api_v2010.json

Load an OpenAPI spec of Twilio&#x27;s API in Bruno


You will be prompted to add a location where you want the specs to be imported. Click Browse, and select a location on your computer.

Browse in Bruno to where to save an API spec

Configure Bruno to use Twilio APIs

Open up your Twilio Console

We will need the following information from the Home Screen

  • Account SID
  • Auth Token
  • My Twilio phone number

Remember, this number should be registered for A2P10DLC or Toll Free Verified, or otherwise fulfill the requirements of the number type in that number’s country.


Twilio credentials from the Twilio Console

Set up the Twilio Environment for Bruno

Now when you open Bruno, you will see Twilio APIs on the left hand side menu:

Selecting the Twilio API in Bruno

In the upper right corner of Bruno, drop down to Configure:

Configure a Collection in Bruno

Create the new environment.

Create a new Environment in Bruno

Give the environment a name so you know what Twilio account it is associated with:

Name a Bruno environment

Now, we will add 3 variables from the information we collected from our Twilio Console.

Add the following names with the respective values we collected by hitting the + Add Variable button

  • TWILIO_ACCOUNT_SID
  • TWILIO_FROM_NUMBER
  • TWILIO_AUTH_TOKEN  

Be sure to click “Secret” for the TWILIO_AUTH_TOKEN

Adding Twilio account credentials inside Bruno

Save our Environment!

Expand to Twilio API -> Api20100401Message -> POST CreateMessage in the opened Bruno Collection:

Expand CreateMessage inside Bruno

Select the environment we just created to use with this Bruno collection

Pick the Twilio Environment we created earlier

Send our first SMS

Navigate to the following in your Twilio API collection:

Twilio API -> Api20100401Message -> POST CreateMessage 

At a minimum, to send an SMS with Twilio API, the API requires:

  • Account SID - Already configured under auth
  • Auth Token - Already configured under auth
  • A From number - A Twilio Phone number you are sending the message from
  • A To number - where you want the message sent
  • A Body - What the messages is

We need to set up our Basic Authentication to use the Twilio credentials we set up in our Environment. Under the Auth Tab for CreateMessage, change the Username to {{TWILIO_ACCOUNT_SID}} and Password to reference the {{TWILIO_AUTH_TOKEN}} environmental variable.

Entering Twilio Account Credentials to CreateMessage in Twilio

Now, under the Body tab, you will see all the parameters available for the CreateMessage endpoint. We will keep only the required parameters to send the SMS. Those are:

  • To
  • From
  • Body

Using E.164 format, enter the number you wish to send an SMS to. For example, +14155551212.

Enter a &#x27;to&#x27; number in Bruno

We will use the {{TWILIO_FROM_NUMBER}} to send From, this will use the environment variable in {{}} to reference it as a variable.


Finally, input the message we want to send in “Body”: Hi, My First Twilio SMS

Add a message body in Bruno

Finally, update the POST url to include your account’s Account SIDWe are changing {AccountSid} to {{TWILIO_ACCOUNT_SID}} in the POST URL

Change the URL from:

Change the path based on an environment variable in Bruno


To:

Bruno using a path with an environment variable



Click the arrow (->) button to send the API request.

Send an API reqest using the arrow button in Bruno

You should now receive the message and see the Twilio Response.

Bruno displaying an API response from Twilio

Congratulations on sending your first message using Bruno as an API client!

What next?

Check Logs

If your message was not successful, check the Twilio Logs in your Twilio Console. Did Twilio receive the message?

Check the Monitor, Logs -> Messaging section.


View the messaging logs in the Twilio Console

Learn more about Messaging API

We only covered the basics with the CreateMessage endpoint. I’ll give you a few suggestions around where you might explore next:

Maybe you’d like to explore sending messages:
https://www.twilio.com/docs/messaging/api/message-resource#create-a-message-resource

Remember all the boxes we un-checked? This document explains what else you can do with the message endpoint.

https://www.twilio.com/docs/messaging/api/message-resource#create-a-message-resource

For example, let’s enable MediaUrl and send a picture. Check the checkbox and provide a MediaUrl, such as:
https://upload.wikimedia.org/wikipedia/commons/9/93/1%25_20-%25_20EEE2HHO.gif

Add a MediaUrl in Bruno to send an SMS with image link or MMS via Twilio

Conclusion

We’ve only scratched the surface in this post. I hope by having another tool to understand Twilio’s API, we’ve inspired you to explore building with Twilio.

As always, we can’t wait to see what you build.

Alex Chun is a Principal Solutions Engineer at Twilio.org. Alex Chun partners with social impact organizations to create tech solutions for communication workflows. His areas of interest are hotlines, technologies for helping climate changes, and animal rescues. He is currently working on solutions using Twilio technologies like Flex, Frontline, and WhatsApp. You can reach him at achun [at] twilio.com.