Twilio integration

Twilio spend alerts and fraud brakes

Costbrake reads Twilio's usage records for today every 5 minutes on Pro and Team, and every 2 minutes for 2 hours after a spike alert. An admin can block calls to high-risk and toll-fraud numbers in every country at once, or suspend a subaccount, and Undo restores either.

Twilio's own usage triggers call a webhook at a threshold, and a prepaid account is suspended when its balance reaches zero. The Free plan checks hourly with email alerts; brakes come with Pro at $12 a month and Team at $39 a month (see pricing).

Twilio at a glance

Reads
Today's usage records per category, and billed amounts per day
Key
A Restricted key with only Usage Records read, plus the Account SID; brakes need a Standard or Main key
Setup
Paste the key, or let a coding agent create the Restricted key
Free plan
Checks every hour, email alerts, no brakes
Pro and Team
Checks every 5 minutes, Slack, Discord and webhook alerts, brakes
Spike checks
Every 2 minutes for 2 hours after a spike alert
Brakes
Block high-risk voice destinations, Suspend subaccount

Brakes

2 brakes for Twilio

An admin picks a brake, confirms it, and can undo it later. Brakes come with Pro and Team.

  • Admin confirms

    Block high-risk voice destinations

    Turns off calling to high-risk special and toll-fraud numbers in every country where it is on, while normal calls keep working.

    UndoTurns high-risk and toll-fraud calling back on for exactly the countries Costbrake changed.

    SMS geo permissions can't be changed through Twilio's API, so this brake covers voice only.

  • Admin confirms

    Suspend subaccount

    Suspends one subaccount, so it can't make or receive calls or send and receive messages until it is reactivated; the main account is never touched.

    UndoSets the subaccount back to active.

    Calls already in progress don't end when a subaccount is suspended, and its phone numbers keep billing monthly.

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.

ControlApplies toWhat happensGap
Usage triggersOne account, daily, monthly or yearlyCalls your webhook at a thresholdNotifies only; your code has to act
Zero balanceThe account and its subaccountsSuspends the account and blocks all usageStops everything at once; numbers keep billing
Voice dialing permissionsCountries, per accountBlocks calls to high-risk and toll-fraud numbersSet once; doesn't react to spend
Subaccount suspensionOne subaccountStops its calls and messagesNeeds the parent's credentials or a Main key
Costbrake brakeThe account's voice permissions or one subaccountBlocks high-risk voice or suspends the subaccountAn 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

  1. An admin turns on the killswitch for the connection and adds a Standard or Main key.
  2. Costbrake lists the account's high-risk voice destinations as one target, plus each subaccount when the key can see them.
  3. The admin picks a target and a brake, then types the connection's name to confirm.
  4. Costbrake turns off high-risk special and toll-fraud calling in every country where it was on, or sets the subaccount to suspended.
  5. 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

Start with 14 days of Pro, free

Catch the next Twilio spike before the invoice.

14 days of Pro, then Free for 2 accounts. No card needed.