Connect Cloudflare
Paste a Cloudflare API token that can read your account's billing, and its account ID, and Costfluent imports the account's usage-based charges daily by product family, line item and zone.
Costfluent reads your Cloudflare spend from the account's billable usage API, with an API token you create for it. One connection is one Cloudflare account, and the usage-based charges of every zone and product in it.
How Costfluent connects
Costfluent stores the API token encrypted and uses it for two calls on the account you name: the account's usage-based subscriptions, and their billable usage. The account ID you enter is the connection's identity, and the token is only ever used for that connection.
Cloudflare does not show a token's permissions to a token that can only read billing, so Costfluent cannot refuse a token that can do more. Create a token with only the Account, Billing, Read permission, on the one account you connect.
Prerequisites
- The Owner or Integration owner organization role in Costfluent.
- A Cloudflare account billed for usage on a self-serve plan. An Enterprise account billed by contract has no billable usage to read: upload its cost to a custom provider instead.
- A custom API token for Costfluent alone. In the Cloudflare dashboard, open "My Profile", then "API Tokens", and select Create Token. Create a custom token, give it the permission Account, Billing, Read, and include only the account you connect. Select Continue to summary, then Create Token, and copy the token before you leave that screen: Cloudflare does not show it again.
- The account ID, 32 characters of digits and the letters a to f. On the account's home page in the Cloudflare dashboard, open the search and enter "Copy account ID", or open a domain, scroll to the API section of its Overview page and copy the Account ID there, not the Zone ID beside it.
Connect
- Open Settings, then Integrations, select Cloudflare, and open the Connect tab.
- Select "Add API token", keep the suggested Display name or enter your own, and paste the token into API token and the account ID into Account ID. An account ID copied in capitals is sent in lowercase, as Cloudflare writes it.
- Select "Test connection" to see each check, or "Connect" to save.
Costfluent reads the account's usage-based subscriptions before storing anything, so a connection that saves can read your billing. A second connection of the same account is refused. If Cloudflare does not answer during that check, the connection is saved anyway and checked again automatically.
Data and freshness
Connecting imports as far back as your plan's backfill reaches, and at most six months (Manage connections), as long as Cloudflare reports usage that far back. Cloudflare updates the usage once a day, so each sync reads the running billing period and the one before it again. Amounts are in the account's billing currency.
A Cloudflare billing period starts on the account's billing day, the day of the month its subscription started, not on the first of the month. A calendar month in Costfluent and a Cloudflare invoice therefore cover different days.
Only self-serve usage-based charges are read. Plan subscriptions, such as Pro, Business or the Workers Paid base fee, are not included. An Enterprise contract's cost is not in this API either; Cloudflare's billing documentation describes no CSV export of it, so build a FOCUS CSV file from the invoice and upload it to a custom provider.
If a custom provider already holds the usage cost this connection reads, remove that custom provider once the connection has imported its months, or the cost is counted twice.
Reporting dimensions
- Service is the product family as Cloudflare names it, such as
WorkersorR2, and its Service category follows the family, such asComputefor Workers andStoragefor R2, orOtherfor a family without one. - SKU is the line item, such as
Workers StandardorR2 Storage. - Resource is the zone, by its name and ID; a charge that belongs to no zone has none.
- A charge Cloudflare reports for a period longer than a day is one cost, dated on the period's first day.
- The billing account is the Cloudflare account, and the billing period starts on its billing day.
Update or disconnect
After connecting
The Manage tab lists the connection by its display name, with its account ID under Account. Open the gear icon beside it to see whether the billing is still readable, which workspaces the connection feeds, and which months have been imported. Run checks runs the checks again on request.
Rotating or removing access
Cloudflare does not rotate the token for you. Create a new token the same way, select Update credentials on the connection page and paste it with the same account ID; then delete the old token in the Cloudflare dashboard, under "My Profile", then "API Tokens". Another account's ID is refused.
To retire the connection, remove it in Costfluent, then delete its token in the Cloudflare dashboard. Removing it erases the cost it imported (Remove a connection).
Troubleshooting
- A Cloudflare API token and the account ID are required. One of the two fields is empty. Paste both.
- A Cloudflare account ID is 32 lowercase hexadecimal digits, as the Cloudflare dashboard shows it under Account ID. The account ID field holds something else, such as the account's name or e-mail address. Copy the account ID from the account's home page or a domain's Overview page.
- Cloudflare refused this API token. Create an API token with the permission Account, Billing, Read and paste it; an expired or revoked token is refused too. The token is wrong, has expired or was deleted. Create a new token and paste it.
- This API token cannot read the billing of Cloudflare account ... Give it the permission Account, Billing, Read on that account, and check the account ID. The message names the account ID and Cloudflare's error. The token lacks the permission, is limited to another account, or the account ID is wrong, for example a zone ID. Edit the token's permissions in the Cloudflare dashboard or check the account ID, then select Run checks.
- Cloudflare reports no usage-based billing for this account: its billable usage covers Pay-as-you-go accounts only, and fixed-fee plans are not included. Upload this account's costs as a custom provider CSV instead. The account has no self-serve usage-based subscription, as an Enterprise account billed by contract. Upload its cost to a custom provider.