Public API data formats
How the Costfluent Public API writes money, dates, currencies and IDs, and how a write is made conditional on the version you read.
The OpenAPI document declares each field's format. This page explains the ones an integration has to handle with care.
Money
Every amount of money is a decimal string, never a JSON number, so no client sums binary floats that drift:
Code
- Responses write every amount with exactly eight decimals, a point and no exponent.
- Requests send an amount the same way, with up to eight decimals:
"1250.5"and"1250.50000000"are the same amount. A JSON number, an exponent or a thousands separator is refused with400. - A budget amount is kept to the cent, so a budget amount with more than two decimals is refused rather than rounded.
- Compare amounts by value, not as text:
"49"and"49.00000000"are equal. - Percentages, ratios such as allocation coverage, exchange rates and usage quantities stay JSON numbers.
- A cost data row's
quantity(measure=usageorcount) is a JSON number. A usage or count report's data keeps its figures in thecostandtotalCostfields as decimal strings, and itssummary.measuresays they are a quantity or a count, in no currency. - A cost alert's
thresholdValueis a decimal string whether it is an amount or a percentage, as itsthresholdTypesays.
Dates and months
- A date is
YYYY-MM-DD, such asstartDate,endDateand a custom integration'schargePeriodStart. A charge period is a day, so a time is refused. - A window of days is a
startDateand anendDate, both included, so March isstartDate=2026-03-01andendDate=2026-03-31. Cost data, allocation coverage, the allocation rule preview, exchange rates and business metric values take a window this way, and coverage answers it the same way. - The audit log filters moments, not days: its
fromis included and itstois not, so one interval'stocan be the next one'sfromwithout listing an entry twice. - A forecast month is
YYYY-MM. - A timestamp, such as
createdAt, is an ISO 8601 date and time.
Currencies
A currency is an upper-case three-letter ISO 4217 code, such as EUR or GBP.
IDs
Every Costfluent object is addressed by a prefixed ID, such as wsp_ for a workspace, bud_ for a budget, crp_ for a cost report, seg_ for a segment and prv_ for an integration. The prefix says what the ID names, and the API refuses an ID of the wrong kind. Treat the rest as opaque.
A batch of costs sent to a custom integration answers with a batchId beginning with cbt_: a receipt for that batch, not an upload you can read back.
Conditional updates
Reading an app, a budget, a business metric, a cost alert, a cost report or its report schedule, a dashboard or one of its widgets, a folder, an integration, a saved filter, a team, a virtual tag or a workspace answers with an ETag header, the version of the object it returned. Send it back as If-Match on the PUT, PATCH or DELETE that changes the object, and on a cost alert's pause and resume, a report schedule's activate and deactivate, and the saved-filter of a dashboard or folder:
Code
When someone changed the object after your read, the write is refused with 412 and precondition_failed, and nothing changes: read it again, then decide. Without If-Match, the last write wins.
How it behaves
- A create and an update answer with the object's new
ETagtoo. A list carries no versions. - A segment and an allocation rule have no read of their own, so take their
ETagfrom the create or update that answered them. If-Match: *applies the write whatever the version.- The
ETagis opaque: compare it, never read meaning into it. - A cost alert's version also changes each time it is evaluated, because its
lastEvaluatedAtchanges with it. - The Terraform provider sends the
ETagof its last read or write with every update and deletion, so an edit made in Costfluent between a plan and its apply stops the apply instead of being overwritten. Plan again to see the edit, then apply.
Retrying a create
Every POST that creates an object, and a batch of costs sent to a custom integration, takes an Idempotency-Key header: a value you choose for that one request, such as a UUID, at most 255 printable ASCII characters. Send the same request again under the same key, after a timeout or a dropped connection, and it is answered with the first response instead of creating a second object:
Code
- A replay answers the first status,
Locationand body, withIdempotent-Replayed: true, for 24 hours after the first request. After that the key is forgotten, and the request creates again. - A key belongs to your organization and the operation it was first sent to. Sent again with another body, path or query, or by another token, it is refused with
422andidempotency_key_reused, and nothing is created: send that request under a new key. - A copy sent while the first is still running waits for it and answers its response. If the first runs on for more than 30 seconds, the copy answers
409andconcurrency_conflict; retry it. - A key is kept only for a create that succeeded. A refused request, such as one that fails validation, gives its key back, so the corrected request can use it.
- Without the header, every request creates, as before.
- No replay answers a secret. A webhook created without a signing secret is given one, which only the first answer returns, as
signingSecret; a replay leaves it out. In every answer'sconfig, a webhook's signing secret and a Slack or Teams incoming-webhook URL come back as***, and a webhook'surlas its scheme and host followed by/***. - The Go SDK and the Terraform provider send a new key with every create and reuse it on their own retries.