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.
Currently, only Node.js 18 is supported. Please upgrade if you are using an older version of Node.js.
To install the CLI on macOS using Homebrew, run:
_10brew tap twilio/brew && brew install twilio
Refer to the CLI install documentation for more installation methods.
Once the CLI has finished installing, run twilio --version
(or twilio -v
) to verify your installation. You'll see similar output to this:
_10$ twilio --version_10twilio-cli/5.0.0 darwin-x64 node-v14.19.0
In order for the 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:
_10twilio 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 the CLI. This secure API Key and your settings will be stored locally as a profile.
Refer to the profiles guide if you would like to use multiple accounts or profiles with the Twilio CLI on the same machine.
Autocomplete allows you to type part of a command, parameter, or flag, and the Twilio CLI will either automatically complete the command or display suggestions for you. If you have autocomplete enabled, you can prompt the CLI for these suggestions by pressing the Tab
key.
Enable autocomplete by running the appropriate command for your shell:
_10twilio autocomplete bash
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.
The best way to learn about what you can do with the CLI is to run the command:
_10twilio
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.
_26$ twilio_26Unleash the power of Twilio from your command prompt. Visit https://twil.io/cli for documentation._26_26VERSION_26 twilio-cli/5.0.0 darwin-x64 node-v14.19.0_26_26USAGE_26 $ twilio [COMMAND]_26_26TOPICS_26 api advanced access to all of the Twilio APIs_26 config manage Twilio CLI configurations_26 debugger Show a list of log events generated for the account_26 email sends emails to single or multiple recipients using Twilio SendGrid_26 feedback provide feedback to the CLI team_26 phone-numbers manage Twilio phone numbers_26 plugins list available plugins for installation_26 profiles manage credentials for Twilio profiles_26_26COMMANDS_26 autocomplete display autocomplete installation instructions_26 feedback provide feedback to the CLI team_26 help display help for twilio_26 login create a new profile to store Twilio Account credentials and configuration_26 plugins list installed plugins_26 update update the twilio CLI
See something that looks interesting? Just try running it:
_10twilio 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:
_10twilio 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
oder -h
to the command like so:
_10twilio api:core:messages:list --help
_10twilio 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
oder -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:
_10twilio api:core:messages:list
_10twilio api core messages list
_10twilio phone-numbers:list
_10twilio api core messages create \_10 --from "+15017122661" \_10 --to "+15558675310" \_10 --body "I sent this from my terminal 😎"
Now that you've been introduced to the Twilio CLI, where should you go from here?
Please view our examples for some inspiration of what you can do with the Twilio CLI.
Refer to our general usage guide to read more about a variety of CLI features:
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 are already a number of plugins available for you to extend your CLI.
Finally, we'd love to hear from you. Any time you have feedback you'd like to send us, run:
_10twilio feedback