Can you set a hard spending limit on Twilio?
Not as a dollar cap. A usage trigger is a webhook that notifies your app when usage crosses a threshold, checked about once a minute; stopping traffic is up to the code it calls. When a prepaid balance reaches zero, Twilio suspends the account and its subaccounts, which blocks all usage while recurring charges like phone numbers keep billing.
| Control | Applies to | What happens | Gap |
|---|---|---|---|
| Usage triggers | One account, daily, monthly or yearly | Calls your webhook at a threshold | Notifies only; your code has to act |
| Zero balance | The account and its subaccounts | Suspends the account and blocks all usage | Stops everything at once; numbers keep billing |
| Voice dialing permissions | Countries, per account | Blocks calls to high-risk and toll-fraud numbers | Set once; doesn't react to spend |
| Subaccount suspension | One subaccount | Stops its calls and messages | Needs the parent's credentials or a Main key |
| Costbrake brake | The account's voice permissions or one subaccount | Blocks high-risk voice or suspends the subaccount | An admin starts it |
Costbrake alerts when an hour costs over 3 times its 7-day usual and at least $5 more. How to set up Twilio usage alerts before a bill spikes covers usage triggers, and How to stop Twilio SMS pumping and toll fraud covers geo permissions.
What Costbrake reads from Twilio
Costbrake reads today's usage records per top-level category, like calls and SMS, and every 6 hours the billed amounts per day. Usage records can lag a few minutes behind real traffic. An account billed in another currency shows those amounts as dollars without conversion.
Usage records are per account. Costbrake leaves subaccounts out so nothing counts twice, so add each subaccount you want tracked as its own connection, with a key created in that subaccount.
Which Twilio key does Costbrake need?
A Restricted API key with only Billing, Usage Records, Read (/twilio/billing/usage/read), plus your Account SID. Restricted keys are created in the Console under API keys and auth tokens, in the United States region. Copy the key SID and the secret, which is shown once.
With agent setup, a coding agent that has your Auth Token or a Main key creates the Restricted key through Twilio's API and sends it without printing the secret.
The brakes need a second key, added in the Costbrake dashboard. A Standard key can block high-risk voice destinations. Suspending subaccounts needs a Main key, because Standard keys can't access Twilio's Accounts resource.
How the Twilio brakes work
- An admin turns on the killswitch for the connection and adds a Standard or Main key.
- Costbrake lists the account's high-risk voice destinations as one target, plus each subaccount when the key can see them.
- The admin picks a target and a brake, then types the connection's name to confirm.
- Costbrake turns off high-risk special and toll-fraud calling in every country where it was on, or sets the subaccount to suspended.
- Undo turns calling back on for exactly those countries, or sets the subaccount back to active.
A subaccount can inherit the main account's dialing permissions or have its own. One with its own permissions keeps them when the voice brake runs on the main account.
What Costbrake can't do on Twilio
- Stop spend on its own. Alerts are automatic; a brake always waits for an admin.
- Change SMS geo permissions, which Twilio doesn't allow through the API.
- Suspend the main account. Costbrake only suspends subaccounts.
- End calls already in progress, or stop phone number fees.
If your Twilio credentials leak, see What to do in the first hour after an API key leaks.
Questions and answers
Does Twilio have a spending limit?
Not as a dollar cap you set. Usage triggers notify a webhook when usage crosses a threshold, and Twilio suspends an account when its prepaid balance reaches zero. Costbrake adds spike alerts and two brakes an admin can run.
What does Block high-risk voice destinations change?
It turns off calling to high-risk special and toll-fraud numbers in every country where they were allowed, through Twilio's voice dialing permissions. Calls to low-risk numbers keep working, and Undo turns calling back on for exactly the countries that changed.
Why does suspending a Twilio subaccount need a Main key?
Twilio's Standard API keys can't access the Accounts resource, which is where a subaccount's status changes. A Main key has full access, the same as using the Account SID and Auth Token.
Does a suspended Twilio subaccount stop billing?
Its new calls and messages stop, but calls already in progress don't end and its phone numbers keep billing monthly. Twilio bills all subaccount usage to the main account's balance.
How often does Costbrake check Twilio usage?
Every 5 minutes on Pro and Team, every 2 minutes for 2 hours after a spike alert, and every hour on Free. Twilio's usage records can lag a few minutes behind real traffic.
Does Costbrake stop Twilio spend on its own?
No. Alerts go out automatically, but a brake only runs when an admin of your Costbrake workspace picks a target and types the connection name to confirm.
Sources
Updated