Daily and period unit economics for one business metric
const url = 'https://example.com/api/v1/unit-economics/daily?metric=example';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://example.com/api/v1/unit-economics/daily?metric=example'Merges exact daily BilledCost with one imported business metric. A day is covered only when both a cost total (of any sign) and a positive quantity exist. Period cost and quantity aggregate covered days only. unitCost is derived in Go as cost / quantity rounded to scale 18, round-half-away-from-zero, then rendered as a decimal string with trailing zeros trimmed. A rendered “0” means the exact quotient rounds to zero at scale 18. Ratios are derived on read and never stored.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Exact imported business metric name.
Inclusive first UTC calendar day; defaults to unbounded.
Inclusive last UTC calendar day; defaults to unbounded.
Optional three-letter uppercase billing currency whose costs to merge with the business metric. Omit to use the alphabetically-first currency in the range.
Responses
Section titled “Responses”Daily gaps and covered-only period unit economics.
object
Cost-side BillingCurrency: the currency query parameter when provided, otherwise the alphabetically-first currency in the range, or “” when the range is empty.
All billing currencies with cost rows in the requested range, sorted ascending. This is the source for a currency selector and is [] (never null) when the range is empty.
Union of cost and metric days, day-ascending.
object
Exact daily cost when a cost bin exists; any sign is retained.
Exact daily business quantity when a metric bin exists.
Present only for a covered day. cost / quantity rounded to scale 18 with round-half-away-from-zero, trailing zeros trimmed. “0” is a meaningful rounded result and is not omitted.
object
Number of days carrying both cost and positive quantity.
Exact cost sum over covered days only.
Exact quantity sum over covered days only.
Covered-period cost / quantity at scale 18, round-half-away-from-zero; absent when coveredDays is zero.
Example
{ "metric": "requests served", "currency": "USD", "currencies": [ "EUR", "USD" ]}Missing or empty metric, an invalid start/end date, or an invalid currency shape.
The named business metric has never been imported.
A cost or business-metric store query failed.