Spend Management is now available in Beta for any pay-as-you-go (PayGo) customer, initially covering Workers and Durable Objects. It lets you set spending thresholds and have Cloudflare pause activity automatically once a limit is reached, rather than only notifying you after the fact. Usage notifications and budget alerts have existed on paid plans for some time, but as the company puts it, informing is not the same as controlling. The feature sits alongside AI Gateway spend limits, which already supports per-user and per-model budgets for Workers AI and other AI providers on requests routed through the gateway, so compute and AI inference costs can be managed together.

Configuring limits and reading the dashboard

Spend Management can be driven from the dashboard, the cf CLI, or the REST API. In the dashboard, the path is Manage Account > Billing > Spend limits, where you enable the products you want to control and then define a spending limit, a notification recipient email, and one or more alert thresholds.

workers spending controls.png
Enabling Spend management for Durable Objects

With a recipient email set, notifications go out when evaluated spend hits a threshold or the limit itself. Reaching the limit triggers a blocking policy and the product is paused automatically.

Email notification when the spending limit is reached

The dashboard shows current billing-cycle costs per supported product in near real time (under 10 minutes) and lets you manage settings and thresholds. Its overview panel lists which products have thresholds and limits configured; the illustrated example shows Workers triggering two alerts before hitting the hard limit.

Overview of products using Spend Management

One detail worth noting: the billing cycle begins with the paid subscription, not with a Worker deployment or the creation of a spending cap. A subscription starting October 10 generally runs October 10 to November 10 rather than following the calendar month. An audit log records who changed a limit and when, and when a cap was reached.

The API documentation lives in the Developer Documentation; here is the same operation via the API:

curl --fail-with-body --request POST \
  "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/billing/spend-policies" \
  --header "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "Workers spending cap",
    "product_id": "workers",
    "enabled": true,
    "threshold_cents": 10000,
    "action": "usage_block",
    "notification_email": "[email protected]"
  }'

and via cf, the CLI for the entire Cloudflare API:

cf billing spend-policies list
cf billing spend-policies create
cf billing spend-policies get
cf billing spend-policies update
cf billing spend-policies delete
cf billing spend-policies audit list
cf billing spend-policies activity list

cf billing spend-policies create --body '{
  "name": "Workers spending cap",
  "product_id": "workers",
  "enabled": true,
  "threshold_cents": 10000,
  "action": "usage_block",
  "notification_email": "[email protected]"
}'

What a cap actually stops

After a cap is enforced, new invocations of that product are rejected. Only customer-code invocations that incur costs are paused: in Workers, Cron Triggers and Queue consumer invocations stop, while static assets continue to be served. Service can be restored in three ways:

  • Raise the limit above the current cycle’s accumulated spend.
  • Disable or delete the blocking policy.
  • Wait for the next billing cycle, when the existing block expires.

Inside the metering and rating pipeline

From an invocation anywhere on the distributed network to a globally applied blocking decision, the system spans multiple teams, changes to existing systems, and new systems built from scratch. A bird's-eye view of a capped billable event:

The life of a capped billable event

Two-stage aggregation near the source

Invocations produce usage measurements — requests, CPU time, execution duration, or storage operations, depending on the product. Shipping all of that raw data to the rating engine would not scale, so collection and aggregation happen as close to the source as possible in a two-stage pipeline, and the engine sees accumulated usage rather than individual events.

How we collect, parse, and aggregate data before sending it to the rating engine

The first stage reduces raw-event volume near parsing to one-minute windows: each metering parser converts raw events into usage measurements and combines matching measurements into typically one-minute buckets. Several records can still describe the same account and time window. A separate service then merges those partial aggregates using the same grouping rules over typically five-minute windows, cutting volume further before the Usage Engine sees it. Consolidated aggregates are also archived, providing a durable dataset for later analytics and reconciliation.

Account-partitioned usage processing

The Usage Engine turns aggregated measurements into usage records — standardized records carrying account, usage window, metric, quantity, and dimensions — effectively mapping product-specific meters onto supported usage metrics. Processing is partitioned by account so that an account’s usage and subscription information meet in one place, letting it maintain accumulated usage and apply included allowances without coordinating across pricing processors on every update.

Account-partitioned processing in the Usage Engine

Different partitions run in parallel, spreading work across accounts while keeping each account’s pricing state together. Each partition keeps local state for fast access and a durable write-ahead logging (WAL) changelog on disk, which yields less cross-partition coordination, consistent pricing as usage updates share the same allowance and accumulated-spend state, independent spend calculation per partition, and recoverability: replacement processors can rebuild and resume after failures. Usage metrics are then fed into the Rating Engine.

Rating: usage plus subscription plus pricing

The Rating Engine answers a single question: given what an account has consumed, its subscription, and its pricing, how much has it spent so far?

High-level overview of the Rating Engine, the brains of Spend Management

It combines three inputs: usage records (quantities such as requests and CPU milliseconds), subscription information (billing period and plan changes), and pricing rules (rates, included allowances, billing rounding). Because usage and subscription updates arrive as independent streams, ordering cannot be assumed, and the system must recover from processing failures or missing subscription data, such as a failed webhook. Usage that arrives before the subscription information needed to price it is retained as pending and revisited when that information appears, so temporary delays do not turn unpriced usage into free usage.

A product catalog database defines usage metrics — allowances, rates, and rounding rules — and is used with the account’s subscription information to track accumulated spend. One million CPU milliseconds does not necessarily mean an extra charge: the included CPU allowance is applied first and only the excess is priced, and pricing operates on accumulated usage rather than rounding and charging per request. Two steps follow: policy evaluation, deciding whether warning or blocking thresholds have been reached, and reporting, which surfaces estimated usage charges in the dashboard via APIs and sends email alerts through Cloudflare Email Service when needed.

Enforcement stays off the request path

The Rating Engine never sits in the request path and does not reject requests itself. The policy service sends the cap to the runtime configuration service and to Quicksilver, Cloudflare’s internal key-value store built for fast global replication and low-latency access at planet scale, which propagates it to all nodes asynchronously.

When the cap reaches Quicksilver, the runtime picks it up during its periodic refresh and begins rejecting capped invocations or operations. Enforcement therefore relies on local state, and requests never wait on the Rating Engine. Reusing the existing runtime account-limit architecture keeps rating out of the request path while distributing caps across the global network.

Roadmap

Coverage

Workers and Durable Objects are only the start; many other Cloudflare products and primitives should become measurable and cappable in the near future. The system was built so products can onboard in an easy, familiar way, so the catalog is expected to grow.

Latency

Near real time of under 10 minutes is the current benchmark, and the company says it intends to shrink the gap between measurement and enforcement, hopefully to under a minute.

Budgets by application and by agent

Spend is currently measured by products and primitives, but other dimensions are being explored. A developer might want to monitor the cost of a specific application — say, a Worker script that also uses primitives such as R2 or Workers AI — and pause that application rather than disabling the underlying primitives across all customer applications. AI agents are another target: rogue agents entering unconstrained recursive reasoning loops can generate thousands of dollars in costs from high-frequency, expensive API calls and cause denial-of-service issues on databases and other services. AI Gateway already lets you give an agent a budget for AI requests routed through it, but a task can also consume compute, database, and storage resources, and the goal is to budget that broader resource use across products. Calls from agents will be taggable, with the pipeline carrying that metadata from the runtime through to the Rating Engine, so spend can be attributed and an application or agentic task paused across products without interrupting unrelated applications.

Further information is in the billing developer documentation.