Menu

Command-Line Interface (CLI) Quickstart

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. Learn more about beta product support.

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.

Currently, Node.js 14+ is supported. Please upgrade if you are using an older version.

Install twilio-cli

Install using Homebrew

To install twilio-cli on macOS using Homebrew, run:

brew tap twilio/brew && brew install twilio

Install using Scoop

To install twilio-cli on Windows using Scoop, run PowerShell as an administrator and:

  1. Add the twilio-cli Bucket:
    scoop bucket add twilio-scoop https://github.com/twilio/scoop-twilio-cli
  2. Install the app:
    scoop install twilio

Install using apt

To install twilio-cli on distributions such as Debian, Ubuntu, Linux Mint, and more using Advanced Package Tool (apt), run the following:

wget -qO- https://twilio-cli-prod.s3.amazonaws.com/twilio_pub.asc \
  | sudo apt-key add -
sudo touch /etc/apt/sources.list.d/twilio.list
echo 'deb https://twilio-cli-prod.s3.amazonaws.com/apt/ /' \
  | sudo tee /etc/apt/sources.list.d/twilio.list
sudo apt update
sudo apt install -y twilio

Run the Docker image

To run the twilio-cli as a Docker image with an interactive bash shell, run:

docker run -it --rm twilio/twilio-cli bash

Consult the dedicated twilio-cli Docker documentation for more details on usage.

Disclaimer

It’s strongly recommended to use one of the other installation methods if possible. An installation by npm does not auto-update, and uses your system’s version of Node.js, which may be older than the version Twilio develops twilio-cli against.

Install using npm

To globally install twilio-cli so that it can be used from any directory, use:

npm install -g twilio-cli

Refer to the twilio-cli install and update documentation for more installation methods.

Once twilio-cli has finished installing, run twilio version (or twilio -v) to verify your installation. You'll see similar output to this:

$ twilio version
twilio-cli/5.0.0 darwin-x64 node-v14.19.0

Login to your Twilio account

In order for twilio-cli to access your Twilio account and execute commands on your behalf, you need to log in and provide your Twilio credentials. This can be done by running:

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 and used to issue authenticated requests as you use twilio-cli. This secure API Key and your settings will be stored locally as a profile.

Refer to the general usage guide if you would like to use multiple accounts or profiles with twilio-cli on the same machine.

Install CLI autocomplete (bash or zsh only)

Autocomplete allows you to partially enter a parameter, command, or option, and either automatically complete the command or display suggestions for you. If you have autocomplete enabled, you can prompt twilio-cli for these suggestions by pressing the completion key (usually Tab in most shells).

Enable command autocomplete for twilio-cli by running the appropriate command for your shell:

twilio autocomplete bash
twilio autocomplete zsh

Follow the resulting instructions, and either restart your shell or open a new one to finish installing command autocomplete.

If suggestions are not appearing, double-check that you restarted your shell or opened a new instance since installing.

Exploring twilio-cli

The best way to learn about what you can do with twilio-cli is to just run the command:

twilio

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

$ twilio
Unleash the power of Twilio from your command prompt. Visit https://twil.io/cli for documentation.

VERSION
  twilio-cli/5.0.0 darwin-x64 node-v14.19.0

USAGE
  $ twilio [COMMAND]

TOPICS
  api            advanced access to all of the Twilio APIs
  config         manage Twilio CLI configurations
  debugger       Show a list of log events generated for the account
  email          sends emails to single or multiple recipients using Twilio SendGrid
  feedback       provide feedback to the CLI team
  phone-numbers  manage Twilio phone numbers
  plugins        list available plugins for installation
  profiles       manage credentials for Twilio profiles

COMMANDS
  autocomplete  display autocomplete installation instructions
  feedback      provide feedback to the CLI team
  help          display help for twilio
  login         create a new profile to store Twilio Account credentials and configuration
  plugins       list installed plugins
  update        update the twilio CLI

See something that looks interesting? Just try running it:

twilio api -h

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 or -h to the command like so:

twilio api:core:messages:list --help
twilio api:serverless:v1:services:create -h

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

Spaces can optionally be used instead of colons when entering commands. These two commands are functionally identical:

twilio api:core:messages:list
twilio api core messages list

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 twilio-cli, where should you go from here?

More examples

Please visit our examples page for more examples of the various things you can do with twilio-cli.

Explore plugins

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 are already a number of plugins available for you to extend your CLI.

General usage guide

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 by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Thank you for your feedback!

Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!

Step 1

Get link

Get a free personal referral link here

Step 2

Give $10

Your user signs up and upgrade using link

Step 3

Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more