Skip to main content
This guide covers common patterns for automating workflows with the Telnyx CLI — output formats, filtering, and integration with scripts and CI/CD pipelines.

Output Formats

The CLI supports multiple output formats for different use cases.

Table Format (Default)

Human-readable table output, best for interactive use:
telnyx number list
PHONE NUMBER    STATUS   CONNECTION           TAGS
+15551234567    active   My Voice App         production, us-west
+15559876543    active   Messaging Profile    staging

JSON Format

Machine-readable output for scripting and automation:
telnyx number list --json
[
  {
    "phone_number": "+15551234567",
    "status": "active",
    "connection_id": "conn_123",
    "tags": ["production", "us-west"]
  }
]

Filtering JSON with jq

Combine with jq for powerful filtering:
# Get just phone numbers
telnyx number list --json | jq -r '.[].phone_number'

# Filter by tag
telnyx number list --json | jq '.[] | select(.tags[] == "production")'

# Count active numbers
telnyx number list --json | jq '[.[] | select(.status == "active")] | length'

Pagination

Many list commands support pagination:
# Limit results
telnyx number list --limit 10

# Paginate through results
telnyx number list --limit 50 --page-token <token>

# Get all results (careful with large datasets)
telnyx message list --limit 250
The CLI will show a next_page_token when more results are available.

Filtering

Most list commands support filtering options:
# Filter numbers by status
telnyx number list --status active

# Filter messages by direction
telnyx message list --direction outbound

# Filter by date range
telnyx message list --created-after 2024-01-01 --created-before 2024-01-31

# Combine filters
telnyx call list --direction outgoing --status active --from +15551234567

Global Flags

These flags work with all commands:
FlagDescription
--profile <name>Use a specific auth profile
--jsonOutput in JSON format
--helpShow help for the command
--versionShow CLI version

Environment Variables

VariableDescription
TELNYX_API_KEYAPI key (overrides config file)
TELNYX_PROFILEDefault profile name
TELNYX_CONFIG_DIRCustom config directory

Scripting Examples

Bash: Bulk SMS Send

#!/bin/bash
# send-bulk-sms.sh

FROM="+15551234567"
NUMBERS=("15559876543" "15551112222" "15553334444")
MESSAGE="Your appointment is confirmed for tomorrow."

for number in "${NUMBERS[@]}"; do
  telnyx message send --from "$FROM" --to "+$number" --text "$MESSAGE"
  echo "Sent to +$number"
  sleep 0.5  # Rate limiting
done

Bash: Export Numbers to CSV

#!/bin/bash
# export-numbers.sh

echo "phone_number,status,connection_id,tags" > numbers.csv

telnyx number list --json | jq -r '.[] | [.phone_number, .status, .connection_id, (.tags | join(";"))] | @csv' >> numbers.csv

echo "Exported to numbers.csv"

Bash: Monitor Account Balance

#!/bin/bash
# check-balance.sh

THRESHOLD=100

balance=$(telnyx billing balance --json | jq -r '.balance')
balance_int=${balance%.*}

if [ "$balance_int" -lt "$THRESHOLD" ]; then
  echo "⚠️  Low balance warning: \$$balance"
  # Send alert, etc.
else
  echo "✓ Balance OK: \$$balance"
fi

GitHub Actions: Deploy Notification

name: Deploy Notification

on:
  deployment:
    types: [completed]

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Install Telnyx CLI
        run: npm install -g @telnyx/api-cli

      - name: Send SMS notification
        env:
          TELNYX_API_KEY: ${{ secrets.TELNYX_API_KEY }}
        run: |
          telnyx message send \
            --from "${{ vars.TELNYX_NUMBER }}" \
            --to "${{ vars.ONCALL_NUMBER }}" \
            --text "✅ Deployment complete: ${{ github.repository }}@${{ github.sha }}"

Interactive Mode

Some commands offer interactive wizards for complex operations:
# 10DLC setup wizard
telnyx 10dlc wizard

# Interactive auth setup
telnyx auth setup

Dry Run Mode

Test destructive operations before executing:
# Preview what would be deleted
telnyx number delete +15551234567 --dry-run

# Preview bulk operations
telnyx 10dlc assign +15551234567 <campaign-id> --dry-run

Next Steps