A Durable Objects alarm loop cost one developer $10,811 overnight. Another hit $36,000 from 81 paying users. For years, Cloudflare Workers on the pay-as-you-go plan had no mechanism to stop the bleeding — billing alerts could email you, but they couldn’t pull the plug. Today that changes.
Cloudflare shipped Spend Management in beta, an opt-in feature that lets PayGo customers set hard spending caps on Workers and Durable Objects. Hit your limit and Cloudflare blocks that product’s operations until the billing period resets or you raise the cap. It’s available via dashboard, CLI, or REST API — no manual workarounds required.
Two Modes, One Feature
When you configure a spend policy, you choose between two actions: usage_block, which hard-stops the product when the cap is hit, or notify, which sends email alerts without interrupting usage. You can set multiple alert thresholds — say, notify at 50% and 80% — so you’re not caught off guard when the hard block finally triggers. Workers and Durable Objects are separate products with separate caps; a $50 Workers limit doesn’t count your Durable Objects spend and vice versa.
Why Now? Because AI Agents Changed the Math
The old billing horror story was a misconfigured Durable Object alarm running in a loop. The 2026 version is worse: an AI agent making repeated Workers AI inference calls at $0.011 per 1,000 Neurons can multiply a bill by 100x in a single afternoon. Cloudflare’s own community forum has a feature request titled “Hard spending/usage caps for the age of AI agents” — it went up months ago and has been collecting upvotes ever since. This feature is a direct answer to that moment. Workers Spend Management integrates with the existing AI Gateway spend limits, giving you a layered cost defense: AI Gateway handles per-model and per-user inference budgets, Workers handles the compute that runs those calls.
How to Set It Up
The fastest path is the cf CLI:
cf billing spend-policies create \
--name 'Workers monthly cap' \
--product-id workers \
--enabled true \
--threshold-cents 2000 \
--action usage_block
That command sets a $20 hard cap on Workers for the current billing period. For Durable Objects, swap --product-id durable_objects. Through the dashboard, the path is Billing > Spend limits. The REST API is available too if you need to automate this across multiple accounts. Spend Management also logs every change — who set a limit, when it was raised, when it triggered — in an audit panel under the same Billing section. Full CLI reference is in the Cloudflare billing CLI docs.
Know the Gaps Before You Rely on It
This is a beta covering two products. Workers AI, Workers KV, R2, D1, and Queues are not included. If the billing incident that sent you here involved a D1 write loop or runaway KV usage, you’re not covered yet. Cloudflare says more products are coming, but “coming soon” shouldn’t be the basis of your cost management strategy. Keep monitoring non-covered products manually — ServerlessHorrors.com is a sobering reminder of what unmonitored serverless can do.
Cloudflare Just Lapped AWS, Azure, and GCP
None of the major serverless platforms — AWS Lambda, Azure Functions, Google Cloud Functions — offer a first-class native spending cap for their compute products. AWS lets you configure billing alarms that fire SNS notifications, but actually stopping a runaway Lambda requires a custom function to throttle itself. It’s DIY all the way down. Cloudflare now has an API-driven spending cap that any developer can configure in under two minutes. That’s not a marginal improvement; it’s a category difference.
Bottom Line
Spend Management should have existed the day Durable Objects hit general availability. It didn’t, and the official Cloudflare announcement doesn’t dwell on that — but the billing horror story forum threads are the receipts. Better late than never, and the timing isn’t bad either, arriving just as AI-driven Workers workloads are turning runaway loop risk into a daily concern. Enable it today. Don’t wait for a $36,000 month to decide whether you needed it.

