Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Twilio CLI Quickstart

BETA


This Twilio product is currently available as a beta release. Some features are not yet implemented and others may be changed before the product is declared as Generally Available. Beta products are not covered by a Twilio SLA.

See this article for more information on beta product support.

The Twilio CLI allows you to manage your Twilio resources from your terminal or command prompt. Let’s get it installed and take a quick tour. Follow the installation instructions for your specific platform below.

Install Twilio CLI

One of the easiest ways to install the CLI on Mac OS X is to use Homebrew. If you don't already have it installed, visit the Homebrew site for installation instructions and then return here.

Once Homebrew is installed, simply run the following command to install the CLI:

brew tap twilio/brew && brew install twilio

Updating

If you already installed the CLI with brew and want to upgrade to the latest version, run:

brew upgrade twilio

Before we can install, we need to make sure you have Node.js installed (version 8 or above). To see if you have node installed, try running this command:

node -v

If your system reports v8.0.0 or above, you can skip the next step.

Installing Node.js on Windows

Using the Windows Installer (.msi) is the recommended way to install Node.js on Windows. You can download the installer from the Node.js download page.

Installing Twilio CLI

The CLI is installed with npm (Node Package Manager), which comes with Node.js. To install the CLI run the following command:

npm install twilio-cli -g

Note the -g option is what installs the command globally so you can run it from anywhere in your system.

Updating

If you already installed the CLI with npm and want to upgrade to the latest version, run:

npm install twilio-cli@latest -g

Before we can install, we need to make sure you have Node.js installed (version 8 or above). Even if you already installed Node yourself, the CLI works best when you install it using nvm. Here's how to get nvm installed on most Linux systems:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

Please visit the nvm installation instructions for additional options and troubleshooting steps. Once you have nvm installed, run the following to install and use the most recent LTS release of Node.js:

nvm install --lts
nvm use <insert version reported from above>

Installing other Twilio CLI prerequisites for Linux

Depending on your distribution, you will need to run one of the following commands:

  • Debian/Ubuntu: sudo apt-get install libsecret-1-dev
  • Red Hat-based: sudo yum install libsecret-devel
  • Arch Linux: sudo pacman -S libsecret

Installing Twilio CLI

The CLI is installed with npm (Node Package Manager), which comes with Node.js. To install the CLI run the following command:

npm install twilio-cli -g

Note the -g option is what installs the command globally so you can run it from anywhere in your system.

Updating

If you already installed the CLI with npm and want to upgrade to the latest version, run:

npm install twilio-cli@latest -g

Login to your Twilio account

In order to access your Twilio account, you need to provide your Twilio credentials to the CLI. This can be done by running this command:

twilio login

You will be prompted for your Account SID and Auth Token, both of which you can find on the dashboard of your Twilio console. This will create an API Key for you that will be stored securely for future use. Visit general usage to learn more about using multiple profiles.

Install CLI autocomplete (bash or zsh only)

If you are running bash or zsh on Mac OS X or Linux, you can run one of the two commands below (as appropriate for the shell you are using):

twilio autocomplete bash

or

twilio autocomplete zsh

Follow the instructions provided to install command auto-complete for the CLI into your shell.

Make sure you restart or open a new shell after you complete the step to install autocomplete.

Exploring Twilio CLI

The best way to learn about what you can do with the CLI is to simply run the command:

twilio

When you do, you will get a list of the various topics and commands you can run. Topics are just groupings for more topics and commands, just like the folder structure on your file system.

> twilio
unleash the power of Twilio from your command prompt

VERSION
  twilio-cli/1.3.6 darwin-x64 node-v10.16.0

USAGE
  $ twilio [COMMAND]

COMMANDS
  api            advanced access to all of the Twilio APIs
  autocomplete   display autocomplete installation instructions
  feedback       provide feedback to the CLI team
  help           display help for twilio
  login          add credentials for an existing Twilio profile
  phone-numbers  manage Twilio phone numbers
  plugins        list installed plugins
  profiles       manage credentials for Twilio profile

See something that looks interesting? Just try running it:

twilio api

Since “api” is a topic, you will actually be shown more topics and commands that are contained within that topic. Let’s say in the process of exploring, you stumbled upon this command:

twilio api:core:messages:list

If you run that command, it will list all of your SMS messages, which may be a lot. How can you filter them? Or, more generally, how can you discover what options a given CLI command provides? The answer is to add “--help” to the command like so:

twilio api:core:messages:list --help

If you type a command, you might get an error if you haven’t provided all of the required options. This is another situation where adding “--help” to the command can give you more information.

Examples

List your phone numbers

twilio phone-numbers:list

Send a text message

twilio api:core:messages:create \
  --from "+15017122661" \
  --to "+15558675310" \
  --body "I love you 3000"

More examples

Please visit our Examples page for a gallery of more examples.

What’s next?

Now that you’ve been introduced to the CLI, where should you go from here?

Explore plugins

The Twilio CLI can be extended via plugins. You can publish your own for the community or make them private for your own (or your clients') business workflows. There's already a number of plugins available for you to extend your CLI.

General usage guide

Refer to our general usage guide to read more about a variety of CLI features:

More examples

We have a whole page full of examples of the various things you can do with the Twilio CLI.

Send us feedback

Finally, we’d love to hear from you. Any time you have feedback you’d like to send us, just run:

twilio feedback
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.