Connect Cloudflare

Connect Cloudflare usage-based charges with a Billing Read account token and see credits and unpaid debt.

Connect Cloudflare

Bring Cloudflare's usage-based charges (Workers, R2, D1, Workers AI and more) into CostGlass with a read-only account API token.

Where in CostGlassSettings → Cloud Accounts → Cloudflare
PlanDepends on your plan's connection limit
Who can do thisA Cloudflare account administrator, and an owner or admin in CostGlass
Time neededAbout 5 minutes
In short
  • You create an Account API token with a single permission, Account → Billing → Read, and paste it with your 32-character Account ID.
  • CostGlass reads Cloudflare's Billable Usage API, which is in alpha. It covers usage-based charges on self-serve (pay-as-you-go) accounts only.
  • Fixed-fee plans such as Pro or Business, and Enterprise contract accounts, are not in that feed, so a connected account can legitimately show no spend.
  • CostGlass says so when nothing comes back. It never invents a figure.
  • The card can also show your remaining Cloudflare credit and any unpaid invoices.
  • You can connect several Cloudflare accounts. Each account can be connected once.

What is and is not covered

Be clear about this before you connect, because it decides whether you will see numbers.

Cloudflare billingShown in CostGlass?
Usage-based charges on a self-serve (pay-as-you-go) account: Workers, R2, D1, Workers AI, Vectorize, Images, Stream and similarYes
Fixed-fee plan subscriptions (for example a Pro or Business plan)No. They are not in the feed.
Enterprise contract accountsNo. They are not in the feed.
A free account with no usage-based productsNothing to show. It connects and reports that no usage was found.
Alpha API
Cloudflare describes its Billable Usage API as alpha and says it is not yet claiming full conformance with the FOCUS billing standard. CostGlass stores what Cloudflare sends and never fills in the rest, so the data may change as Cloudflare develops the API.
Before you begin
  • A Cloudflare account where you can create Account API tokens.
  • Your Account ID (see below).
  • An owner or admin account in CostGlass, and room in your plan for another connection.

Step by step

1
Create a billing-read token
In the Cloudflare dashboard open Manage Account → Account API Tokens → Create Token and choose Create Custom Token. Add one permission: Account → Billing → Read. Nothing else is needed and CostGlass never asks for write access. Create the token and copy it straight away; Cloudflare shows it once. Use an Account token, not a user token, and create it for the account you want to connect.
2
Copy your Account ID
On Account Home open the ⋯ menu next to the account name and choose Copy account ID. It is exactly 32 characters made of the digits 0-9 and the letters a-f.
3
Connect it in CostGlass
Go to Settings → Cloud Accounts → Cloudflare. Optionally change Account Display Label, paste the 32-character value into Account ID, paste the token into API Token and click Connect Cloudflare. It reads Verifying & Syncing... while it works. To add another account later the button reads Connect Another Account.
Cloud Accounts → Cloudflare.
Note
The Connect button stays disabled until the Account ID looks valid (32 hexadecimal characters). CostGlass checks this before it makes any request, so a mistyped or malicious value cannot be sent to Cloudflare.

What CostGlass checks when you connect

CostGlass asks Cloudflare for the account's billable-usage information. That one call proves the token is valid, has Billing → Read on that account, and that the Account ID is right. If any of that is wrong you see a message and nothing is stored. The token is saved only in CostGlass's encrypted secrets store.

You then see one of two results:

ResultWhat you seeMeaning
Usage foundA "Cloudflare Successfully Connected!" panel, then the card with a record count.Usage-based charges were read.
No usage foundA warning panel, "Cloudflare connected, no usage found yet", with Cloudflare's own answer.The token is valid, but Cloudflare returned no usage-based billing. The account stays connected and is picked up automatically once Cloudflare reports usage.

About the “covered” flag

Cloudflare's information call includes a field called covered, which its documentation does not define. A non-Enterprise account has been seen to report covered=false and still have a valid token. For that reason CostGlass never treats it as a yes or no. It always tries to read usage, and decides from what comes back. The "no usage found" message quotes what Cloudflare said (for example "covered=false, 0 subscription(s)") and lists the possible reasons, without claiming which one applies to you.

What data you will see

  • Cost per Cloudflare product, split by zone (your domain) where Cloudflare gives one, so you can see which zone a charge belongs to. In CostGlass the zone appears as the resource.
  • Daily figures where Cloudflare reports daily charges, plus monthly totals for each complete calendar month.
  • The current month is shown month to date. A monthly total is written only for a calendar month the fetched data fully covers, so a partial sync cannot overwrite a correct full month.
  • A rough product category for each service (for example Workers is Compute, R2 is Storage, D1 is Databases, Workers AI is AI and Machine Learning). This is CostGlass's mapping, not Cloudflare's.
  • The first sync looks back through up to 14 of your Cloudflare billing periods; later syncs refresh the latest three.
  • What is actually billed is used as the cost. A product that billed nothing stores nothing.

Cloudflare's billing period starts on an anchor day of your own, but CostGlass reports in calendar months to match every other cloud, so a figure for a month may be built from parts of two Cloudflare billing periods. Costs show up in Cost Explorer and Reports next to your other clouds.

Credits and unpaid-debt badges

Each sync also reads two small pieces of account information, so the Cloudflare card can show financial signals alongside spend. They are best effort: if one fails the sync still succeeds, and they show even for an account that has no usage yet.

Credit badge
Shown when the account has a credit. It reads like "Credit US$50.00 of US$100.00 · 50% used · 276 days left". Hover for the dates the credit is valid and, when Cloudflare provides it, the date it is projected to run out.
Unpaid badge
Shown when Cloudflare reports unpaid invoices. It reads like "Unpaid US$123.45 · status". Hover to see how many invoices and the status Cloudflare gives.
Billing history is deliberately not imported
Cloudflare's billing-history feed also holds fixed-fee plan charges, but it does not document its transaction types or whether refunds are negative. Turning it into cost figures would mean guessing and could double count usage, so CostGlass does not read it. This means fixed-fee plan spend stays missing from CostGlass.

Syncing, several accounts, disconnecting

  • CostGlass syncs every six hours. Click Sync Now on the Cloudflare tab to sync all your connected Cloudflare accounts now.
  • Each account appears as its own card. One Cloudflare account can only be connected once to your organisation, but you can connect several different accounts.
  • Disconnect asks you to confirm, stops syncing and deletes the stored token. Cost data already collected is kept.

Questions people ask

It connected but shows no spend. Is something broken?
Probably not. If the account only has a free or fixed-fee plan, or is an Enterprise contract account, the usage feed has nothing to report. Once you use a usage-based product on a self-serve account, CostGlass picks it up.
Where do my Pro or Business plan charges go?
They are not in the usage feed, so CostGlass does not show them yet.
Can I use a user API token?
Use an Account API token created for the account you want to connect, with Account → Billing → Read.
Can I connect the same account twice?
No. You will get a message that it is already connected.
My token is rejected.
Check it has Billing → Read on this account, that it has not expired and that the Account ID belongs to the same account.

Related guides