How to get your Cloudflare Containers API usage, balance and spend programmatically
What the Cloudflare Containers API exposes
| Signal | Cloudflare Containers |
|---|---|
| Balance | No |
| Spend history | Yes. POST /client/v4/graphql, containersUsageAdaptiveGroups (cpuTimeSec, allocatedMemory, allocatedDisk, txBytes by date) |
| Cost breakdown | No |
| Plan and quota | Yes |
| Cost on each response | No |
| Rate-limit headers | None |
| Credential | API key |
| Key permission | Account > Account Analytics > Read, and nothing else. Read-only; use a dedicated token you can revoke. |
Call it yourself
Credential. A Cloudflare API token (not the Global API key) and your account ID. The account ID isn't secret; Argus asks for it beside the token. Optionally enter the day of the month your billing cycle starts.
Daily container usage (also the token and account check)
curl https://api.cloudflare.com/client/v4/graphql -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" -H "Content-Type: application/json" --data '{"query":"query($a:String!,$from:Date!,$to:Date!){viewer{accounts(filter:{accountTag:$a}){containersUsageAdaptiveGroups(limit:1000,filter:{date_geq:$from,date_leq:$to},orderBy:[date_ASC]){dimensions{date} sum{cpuTimeSec allocatedMemory allocatedDisk txBytes}}}}}","variables":{"a":"'$CLOUDFLARE_ACCOUNT_ID'","from":"2026-10-07","to":"2026-10-21"}}'{
"data": {
"viewer": {
"accounts": [
{
"containersUsageAdaptiveGroups": [
{
"dimensions": { "date": "2026-10-20" },
"sum": {
"allocatedDisk": 172800000000000,
"allocatedMemory": 22118400000000,
"cpuTimeSec": 3742.18,
"txBytes": 8471239
}
}
]
}
]
}
},
"errors": null
}Trimmed to the fields Argus reads. Values are examples.
Gotchas
- Use containersUsageAdaptiveGroups for cost. containersMetricsAdaptiveGroups measures your own workload and leaves out the micro VM sandbox, so it understates the bill.
- Memory and disk are byte-seconds, CPU is seconds. Argus divides memory by 2^30 (GiB-seconds) and disk by 10^9 (GB-seconds) to match the pricing units.
- Not yet confirmed against a live response: whether memory is divided by 2^30 (GiB) or 10^9 (GB), and whether allocatedDisk and txBytes exist on every account. If Cloudflare rejects those two fields, Argus prices memory and CPU only, and disk and egress are left out of the spend and the plan view until they are readable.
- Use either a connected token or events for an account, not both. They share one connection: the polled spend, net of the monthly allowances, is the total and nothing is added twice, but events are priced before the allowances, so their itemized costs can add up to more than that total.
- Memory is $0.0000025 per GiB-second, CPU $0.000020 per vCPU-second, disk $0.00000007 per GB-second, egress $0.025 per GB in North America and Europe. Billing is in 10 ms steps.
- The Workers Paid plan includes 25 GiB-hours of memory, 375 vCPU-minutes, 200 GB-hours of disk and 1 TB of egress a month across the whole account. Argus prices only the excess over those, so an account inside its allowances shows $0.00.
- Allowances reset on your billing cycle, which isn't readable with an Analytics token. Without a start day Argus uses the calendar month, so cycle-boundary days can land a few days off until you set it.
- Argus prices all egress at the North America and Europe rate. Oceania, Korea, Taiwan and other regions cost more per GB but have smaller allowances.
- api.cloudflare.com serves every Cloudflare product, so there is no hostname match. Send events with provider cloudflare_containers and units vcpu_seconds, gib_seconds, gb_seconds and gb; Argus prices them at the list rates, before allowances.
- Workers requests, Durable Objects and logs for the same app are billed separately and aren't included.
- Today's bucket is preliminary and excluded from burn until the day closes.
How Cloudflare Containers charges
Containers on Workers: billed per vCPU-second of active CPU, GiB-second of provisioned memory, GB-second of provisioned disk and GB of egress, in 10 ms steps, after the monthly allowances that come with the $5 Workers Paid plan.
| Plan | Monthly price |
|---|---|
| Workers Paid | $5 |
At zero. Postpaid: past an allowance, usage keeps running and bills at the overage rate. Workers requests, Durable Objects and logs for the same app bill separately.
Or let Argus track it
Paste the key once. Argus keeps the ledger, and your coding agent reads it through the MCP server.
- Pulls Cloudflare Containers's daily cost buckets every hour for month-to-date spend and a projected month-end total.
- Tracks the plan: the allowance, what's used this period, the reset date, and when you cross into overage.
- With the SDK or the ingest API, send events with provider cloudflare_containers and usage units. Argus prices them at Cloudflare Containers's list rates.
- Emails you on low balance, days to zero, a spend spike, or projected overage.
- Hands all of it to your coding agent over MCP, so it can ask what a run cost or how much runway is left without leaving the editor.
> what has cloudflare_containers cost today, and how long until it runs out?
get_overview → cloudflare_containers: mtd spend, burn per day, days to zero
get_request_costs { "provider": "cloudflare_containers", "limit": 25 }
get_advisories → credits_low, spend_spike, rate_limit_low …Questions
- Does Cloudflare Containers have an API for its balance?
- Cloudflare reports Containers usage, not dollars. The GraphQL Analytics API's containersUsageAdaptiveGroups dataset returns CPU seconds, memory byte-seconds, disk byte-seconds and bytes transmitted per day. Argus prices that at Cloudflare's published rates after your monthly allowances.
- Can I get Cloudflare Containers spend per day from the API?
- Yes, from POST /client/v4/graphql, containersUsageAdaptiveGroups (cpuTimeSec, allocatedMemory, allocatedDisk, txBytes by date), in daily buckets.
- What happens when Cloudflare Containers credits run out?
- Postpaid: past an allowance, usage keeps running and bills at the overage rate. Workers requests, Durable Objects and logs for the same app bill separately.
- What key does Argus need for Cloudflare Containers?
- A Cloudflare API token (not the Global API key) and your account ID. The account ID isn't secret; Argus asks for it beside the token. Optionally enter the day of the month your billing cycle starts.
Related
Pricing and limits verified 2026-10-21 against developers.cloudflare.com/containers/pricing (rates, allowances, 10 ms billing, instance types), developers.cloudflare.com/analytics/graphql-api/tutorials/querying-container-metrics (dataset, sum fields, units; the dataset matches the dashboard usage estimates), developers.cloudflare.com/analytics/graphql-api/getting-started/authentication/api-token-auth (Account > Account Analytics > Read), Customer billing page, Oct 7 to Nov 6 2026 cycle (memory 95.35k GiB-s billed 5.35k over a 90k GiB-s allowance), observed 2026-10-21. Endpoints are the ones the Argus Cloudflare Containers connector calls.
Connect a provider key, point Claude Code or Cursor at the Argus MCP server, and ask what the last run cost.