Automate workflows with the Telnyx CLI using output formats, filtering, and JSON parsing — patterns for shell scripts, cron jobs, and CI/CD pipelines.
This guide covers common patterns for automating workflows with the Telnyx CLI — output formats, filtering, and integration with scripts and CI/CD pipelines.
Use --transform to extract specific fields using GJSON syntax:
# Get first phone numbertelnyx phone-numbers list --format json --transform "data.0.phone_number"# Get all phone numbers as arraytelnyx phone-numbers list --format json --transform "data.#.phone_number"# Filter by statustelnyx phone-numbers list --format json --transform 'data.#(status=="active")#'
Most list commands support filtering via individual --filter.* flags:
# Filter numbers by statustelnyx phone-numbers list --filter.status active# Filter by country (note: kebab-case, not snake_case)telnyx available-phone-numbers list --filter.country-code US# Multiple filterstelnyx phone-numbers list --filter.status active --filter.country-iso-alpha2 US# Filter with featurestelnyx available-phone-numbers list --filter.country-code US --filter.features sms
Filter flag names use kebab-case (e.g., --filter.country-code, not --filter.country_code).