Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Output formatting and filtering


All CLI command output is sent to stdout, and can be customized in terms of output values as well as format.


Default output format

default-output-format page anchor

By default, any output is formatted in a human-readable, columnar format like so:


_10
$ twilio phone-numbers:list
_10
SID Phone Number Friendly Name
_10
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1209242XXXX SIP testing
_10
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1646887XXXX Congress hotline
_10
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1209337XXXX DAVID'S SECRET CRUSH


Many list commands will allow you to specify a --properties option defining which columns you'd like to display. For example, to display only the Phone Number and SMS URL columns, you would pass --properties "phoneNumber, smsUrl".


_10
$ twilio phone-numbers:list --properties 'phoneNumber, smsUrl'
_10
Phone Number SMS URL
_10
+1209242XXXX https://very-secret.ngrok.io/sms
_10
+1646887XXXX https://handler.twilio.com/twiml/EHxxxx
_10
+1209337XXXX

Column names must match the camelCased JSON(link takes you to an external page) property names in the Twilio API for the resource. For example, you can find the possible column values for phone numbers by looking at the Incoming Phone Number API Reference

(information)

Info

The default list of properties varies by command, and is subject to change with each release.


Append the -o json flag to a command to change the output format to JSON. When you choose JSON, the command will send the entire API response to stdout as JSON.

You can then pipe this output to tools like jq(link takes you to an external page) to parse the JSON as necessary.

For example:


_23
# Fetch all incoming phone numbers as json, and display as an array
_23
# that only contains each sid and phone number.
_23
$ twilio phone-numbers:list -o json \
_23
| jq '.[] | {sid, phoneNumber, smsUrl, voiceUrl}'
_23
_23
{
_23
"sid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
_23
"phoneNumber": "+1209242XXXX",
_23
"smsUrl": "https://very-secret.ngrok.io/sms",
_23
"voiceUrl": "https://very-secret.ngrok.io/answer"
_23
}
_23
{
_23
"sid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
_23
"phoneNumber": "+1646887XXXX",
_23
"smsUrl": "https://handler.twilio.com/twiml/EHxxxx",
_23
"voiceUrl": "https://demo.twilio.com/welcome/voice/"
_23
}
_23
{
_23
"sid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
_23
"phoneNumber": "+1209337XXXX",
_23
"smsUrl": "",
_23
"voiceUrl": ""
_23
}

(warning)

Warning

The --properties flag does not modify command output when combined with -o json.

For example, twilio phone-numbers:list -o json --properties sid | jq . will return the entire, unmodified JSON response, not an array of objects containing sid.


Tab separated values output format

tab-separated-values-output-format page anchor

To change the output format to tab separated values (TSV), add -o tsv to a command.

This format is useful for loading information into spreadsheets, or for other machine processing. Like the default, columnar output format, you can use the --properties option to specify which columns you would like included.


_10
$ twilio phone-numbers:list -o tsv
_10
sid phoneNumber friendlyName
_10
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1209242XXXX SIP testing
_10
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1646887XXXX Congress hotline
_10
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1209337XXXX DAVID'S SECRET CRUSH


Rate this page: