Skip to contentSkip to navigationSkip to topbar
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:

1
$ twilio phone-numbers:list
2
SID Phone Number Friendly Name
3
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1209242XXXX SIP testing
4
PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +1646887XXXX Congress hotline
5
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".

1
$ twilio phone-numbers:list --properties 'phoneNumber, smsUrl'
2
Phone Number SMS URL
3
+1209242XXXX https://very-secret.ngrok.io/sms
4
+1646887XXXX https://handler.twilio.com/twiml/EHxxxx
5
+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:

1
# Fetch all incoming phone numbers as json, and display as an array
2
# that only contains each sid and phone number.
3
$ twilio phone-numbers:list -o json \
4
| jq '.[] | {sid, phoneNumber, smsUrl, voiceUrl}'
5
6
{
7
"sid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
8
"phoneNumber": "+1209242XXXX",
9
"smsUrl": "https://very-secret.ngrok.io/sms",
10
"voiceUrl": "https://very-secret.ngrok.io/answer"
11
}
12
{
13
"sid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
14
"phoneNumber": "+1646887XXXX",
15
"smsUrl": "https://handler.twilio.com/twiml/EHxxxx",
16
"voiceUrl": "https://demo.twilio.com/welcome/voice/"
17
}
18
{
19
"sid": "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
20
"phoneNumber": "+1209337XXXX",
21
"smsUrl": "",
22
"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.

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

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.