Twilio Cli Reference

作者 twilio8aba46fb65dc无许可证收录于 2026年10月8日更新于 2026年10月8日

Twilio CLI reference for managing Twilio resources from the terminal. Covers installation, credential profiles, phone number provisioning, sending SMS and email, webhook configuration, local development with a tunneling service, debugging with watch and logs, serverless deployment, and plugin ecosystem. Use when the developer asks to "just do it", "set this up", "run a command", mentions "CLI", "command line", or "terminal", or when an AI agent can execute a task directly instead of writing application code.

AI 生成的概览

使用 Twilio CLI 在终端管理 Twilio 资源的参考文档。

功能
该技能是一份 Twilio CLI 参考文档,涵盖安装、身份验证与凭据配置文件、电话号码开通、发送短信和电子邮件、Webhook 配置、本地隧道、调试与监控、无服务器部署、插件以及区域路由。它提供命令示例,并说明凭据优先级、输出格式和 CLI 限制。它产出的是指导内容而非可执行产物,不包含脚本。
适用场景
当开发者或智能体希望直接在终端执行 Twilio 操作而不编写应用代码时使用,例如开通号码、发送消息、配置 Webhook 或部署无服务器函数。它也适用于排查 CLI 行为、配置文件或区域设置问题。
运行要求
需要安装 Twilio CLI(Homebrew、Scoop、apt 或 npm),并拥有 Twilio 账户及通过登录、配置文件或环境变量提供的凭据。部分功能需要额外插件、单独安装的隧道服务(如 ngrok),以及用于电子邮件的 SENDGRID_API_KEY。需要网络访问;该技能不附带脚本。

Overview

The Twilio CLI lets you manage Twilio resources, send messages, configure webhooks, and deploy serverless functions directly from the terminal. AI coding agents can use CLI commands to provision resources and test integrations without writing application code.

Install:

PlatformCommand
macOSbrew tap twilio/brew && brew install twilio
Windowsscoop bucket add twilio-scoop https://github.com/twilio/scoop-twilio-cli && scoop install twilio-cli
Linux (apt)See twilio-cli/getting-started/install for repo setup, then apt install twilio
npmnpm install -g twilio-cli

Update: brew upgrade twilio / scoop update twilio-cli / npm install -g twilio-cli@latest


Authentication & Profiles

bash
# First-time login — creates a local API key stored as a profiletwilio login
# Named profiles for multiple accountstwilio profiles:create --account-sid ACxxx --auth-token xxx --profile staging# Avoid --auth-token as a plain argument — it will be stored in shell history. Use TWILIO_AUTH_TOKEN env var instead.twilio profiles:listtwilio profiles:use staging
# Run a single command against a different profiletwilio api:core:messages:list -p production
# Subaccount accesstwilio api:core:messages:list --account-sid ACxxx_SUBACCOUNT

Credential priority: explicit -p/--account-sid flag > env vars (TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) > active profile.


Phone Numbers

bash
# Search available numbers (US local, area code 415)twilio api:core:available-phone-numbers:local:list --country-code US --area-code 415
# Purchase a numbertwilio api:core:incoming-phone-numbers:create --phone-number "+14155551234"
# List owned numberstwilio phone-numbers:list
# Set webhooks on a numbertwilio phone-numbers:update +14155551234 \  --sms-url "https://example.com/sms" \  --voice-url "https://example.com/voice"

Send SMS

bash
twilio api:core:messages:create \  --from "+14155551234" \  --to "+14155556789" \  --body "Your order has shipped."
# List recent messagestwilio api:core:messages:list --to "+14155556789" --limit 10

Send Email (SendGrid)

Requires SENDGRID_API_KEY environment variable.

bash
# Configure defaultstwilio email:set --from "[email protected]" --subject "Default Subject"
# Send emailtwilio email:send \  --to "[email protected]" \  --subject "Invoice attached" \  --text "Please find your invoice." \  --attachment ./invoice.pdf
# Pipe output as email bodyps aux | twilio email:send --to "[email protected]" --subject "Process list"

Webhook Development

bash
# Set webhook URLs on a numbertwilio phone-numbers:update +14155551234 --sms-url "https://your-tunnel-url.example.com/sms"
# Emulate webhook events locally (requires plugin)twilio plugins:install @twilio-labs/plugin-webhooktwilio webhook:invoke http://localhost:3000/sms --type sms

Local development: The CLI rejects localhost URLs directly. Tunneling services such as ngrok are not bundled with twilio-cli. install one separately, then set the public tunnel URL as your webhook.

** ngrok is NOT included in the CLI — install separately: npm install -g ngrok or via https://ngrok.com

  • Start tunnel: ngrok http 3000, then use the provided URL for webhook
    configuration

Debugging & Monitoring

bash
# Debug logging on any command (logs to stderr)twilio api:core:messages:create --from +14155551234 --to +14155556789 --body "test" -l debug
# Real-time monitoring (requires plugin)twilio plugins:install @twilio-labs/plugin-watchtwilio watch                    # stream debugger alerts, calls, messages in real time
# Output formattingtwilio api:core:messages:list -o json             # JSON outputtwilio api:core:messages:list -o tsv              # tab-separatedtwilio api:core:messages:list --properties sid,status,direction  # select columnstwilio api:core:messages:list --limit 200         # override default 50-record cap

Serverless Deployment

bash
twilio plugins:install @twilio-labs/plugin-serverless
# Create a new Functions projecttwilio serverless:init my-project --template blankcd my-project
# Local developmenttwilio serverless:start          # serves functions at localhost:3000
# Deploy to Twiliotwilio serverless:deploy

Plugins

bash
twilio plugins:install <package>twilio plugins:listtwilio plugins:remove <package>
PluginWhat it does
@twilio-labs/plugin-serverlessDevelop and deploy Twilio Functions and Assets
@twilio-labs/plugin-dev-phoneTest SMS/Voice without a real phone
@twilio-labs/plugin-watchReal-time monitoring of debugger alerts, calls, messages
@twilio-labs/plugin-tokenGenerate client-side SDK tokens (Voice, Chat, Video)
@twilio-labs/plugin-assetsUpload static resources
@twilio-labs/plugin-webhookEmulate webhook events for local testing
@twilio-labs/plugin-flexCreate, build, deploy Flex plugins

Regional & Edge Routing

bash
# Login to a specific regiontwilio login --region au1 --edge sydney
# Set edge globallytwilio config:set --edge=sydney
# Or via env varsexport TWILIO_REGION=au1export TWILIO_EDGE=sydney

Supported: au1/sydney, ie1/dublin, jp1/tokyo. Each region uses a different Auth Token from your US1 credentials. Find yours in the Twilio Console under API keys & tokens, selecting your target region.


Configuration

bash
twilio config:list                          # show all settingstwilio config:set --edge=sydney             # set default edgetwilio config:set --require-profile-input   # prompt before using active profile

Config stored at ~/.twilio-cli/config.json.

Syntax notes:

  • Commands use spaces by default, using colon also works: twilio api core messages create = twilio api:core:messages:create
  • twilio [COMMAND] --help for any command's options
  • Multi-line: use \ for line continuation

CANNOT

  • Default list limit is 50 records — always pass --limit for larger result sets.
  • API timeout is 30 seconds — long-running operations may fail silently.
  • Cannot use localhost URLs for webhooks — use a tunneling service, such as ngrok, installed separately.
  • No autocomplete on Windows — only bash/zsh supported.
  • ** ngrok is not bundled with twilio-cli**, install separately
  • Cannot send Twilio Email (comms API) via CLI — twilio email:send uses SendGrid only. For Twilio Email, use the REST API directly.

Next Steps

  • Account setup and API keys: twilio-account-setup, twilio-iam-auth-setup
  • Webhook architecture and signature validation: twilio-webhook-architecture
  • Debugging and observability: twilio-debugging-observability
  • Send SMS via API/SDK: twilio-send-message
  • SendGrid email setup: twilio-sendgrid-account-setup

来源与署名

来源:twilio/ai位于skills/twilio/twilio-cli-reference提交8aba46f

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架

更多来自 twilio/ai 的技能

Twilio Voice Twiml

twilio

使用 TwiML 构建 Twilio 语音通话逻辑,涵盖核心动词、SDK 生成方式和 IVR 示例。

Software Development2026年10月8日

Twilio Isv Sms Best Practices

twilio

面向 ISV 的多租户 Twilio SMS 构建指南,涵盖 A2P 与免付费号码注册、子账户及常见陷阱。

Software Development2026年10月8日

Twilio Security Compliance Hipaa

twilio

指导为 HIPAA 合规配置 Twilio 账户,涵盖 BAA、HIPAA 项目指定、合格服务及各产品要求。

Security2026年10月8日

Twilio Reliability Patterns

twilio

Handle rate limits, retries, and failures when building on Twilio at scale. Covers 429 exponential backoff with jitter, per-number throughput limits, StatusCallback resilience, thin-receiver pattern, and fallback chains. Use this skill whenever sending messages or making calls at volume, or when building production-grade Twilio integrations.

待分类2026年10月8日

Twilio Organizations Setup

twilio

Set up and manage Twilio Organizations for centralized account and user governance. Covers the Organization > Account > Subaccount hierarchy, roles (Owner/Admin/Standard), managed vs independent accounts, domain registration, SSO enforcement, SCIM provisioning, and Organization merging. Use this skill when managing multiple Twilio accounts or users across teams.

待分类2026年10月8日

Twilio Numbers Senders

twilio

指导在开发前选择合适的 Twilio 号码类型和发送方,涵盖合规计划、吞吐量和可用性。

Communication2026年10月8日