Get a customer's public cost dashboard
const url = 'http://localhost:8080/v1/public/cost-dashboard/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 http://localhost:8080/v1/public/cost-dashboard/examplePublic: no API key. The hc_pcd_ token in the URL is the only
credential, so you can embed the page or fetch it from your own app.
Make the token with
POST /.
The answer holds the customer’s usage and cost for the current billing period and its credit balance. It never holds the customer’s name, email, external ID or billing profile, your provider costs, or usage that no price takes.
A token with the wrong prefix or no customer gets 401, the same answer
for both. A customer with no active subscription gets 200
with billing_ no_: subscriptions,
usage and totals are empty, and credits still lists the credit
balance.
Limited to 60 requests a minute per IP address. The limit is shared with the hosted invoice and payment-update pages.
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The cost-dashboard token, hc_pcd_ and 64 hex characters.
Responses
Section titled “Responses”The customer’s usage, cost and credit for the current billing period.
object
The customer the token belongs to.
The account the customer belongs to.
False for a test-mode customer: show a test-mode notice.
The period the usage covers.
object
Start of the period. The zero time
0001-01-01T00:00:00Z when source is
no_.
End of the period, exclusive. The zero time when
source is no_.
Check this before you show the period.
subscription: the period runs from the earliest
start to the latest end of the current billing
periods of the customer’s active subscriptions.
no_: the customer has no active
subscription; subscriptions,
usage and totals are empty (credits is not),
and start and end hold the zero time, not a real
range.
One entry per plan of each active subscription.
object
The subscription’s ID.
The plan’s name.
The plan’s currency, such as USD.
Start of the subscription’s current billing period.
End of the subscription’s current billing period, exclusive.
One entry per meter the customer’s plans price.
object
The event_ usage events send for the meter.
The meter’s display name.
The meter’s unit, such as tokens.
The currency of the plan that priced the meter’s
usage. Empty ("") when the meter has no usage
this period.
The usage the prices took this period, as a decimal string.
What the usage costs, in the currency’s minor unit (cents for USD).
One row per price that took usage this period.
object
The labels the price takes. Absent for a price that takes every event.
object
The usage this price took, as a decimal string.
What this price bills, in the currency’s minor unit (cents for USD).
Price per unit, as a decimal string of
cents, not dollars: “0.0003” is 0.0003 cents
per unit ($3.00 per 1M units). Multiplied by
quantity, it gives cents, like
amount_.
One entry per currency present in usage.
object
The currency, such as USD.
The usage cost in this currency, in its minor unit (cents for USD).
The metered cost of the current billing period so far,
in minor units. It adds up every entry of totals,
whatever its currency, so use totals when there is
more than one. Recurring base fees are not included.
The customer’s credit position, one entry per currency,
ordered by currency. balance_ is the ledger
balance in that currency, less any grant past its expiry
date that is not yet written off: credit is drawn down
when an invoice is issued, so it does not move with
usage. unbilled_ is the usage no invoice
has billed yet that will be invoiced in that currency,
and estimated_ is the balance minus
that, never below zero. These three are the same figures
GET / returns.
It is an estimate: tax, base fees billed at period end
and unpaid invoices are not subtracted.
object
The currency of this entry.
The credit balance in this currency, in its minor unit (cents for USD).
Usage no invoice has billed yet, in minor units.
What is left of the customer’s prepaid commit, in minor units.
What is left of promotional credit, in minor units.
The balance minus unbilled usage, never below zero, in minor units.
Example
{ "customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g", "tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00", "livemode": false, "billing_period": { "start": "2026-10-01T00:00:00Z", "end": "2026-11-01T00:00:00Z", "source": "subscription" }, "subscriptions": [ { "id": "hc_sub_dauq502q3gpgqfoq5c2g", "plan_name": "Pro", "currency": "USD", "current_period_start": "2026-10-01T00:00:00Z", "current_period_end": "2026-11-01T00:00:00Z" } ], "usage": [ { "event_name": "tokens", "meter_name": "Tokens", "unit": "tokens", "currency": "USD", "total_quantity": "12500000", "total_amount_cents": 3750, "prices": [ { "quantity": "12500000", "amount_cents": 3750, "unit_amount_decimal": "0.0003" } ] } ], "totals": [ { "currency": "USD", "amount_cents": 3750 } ], "projected_total_cents": 3750, "credits": [ { "currency": "USD", "balance_cents": 5000, "unbilled_usage_cents": 3750, "commit_remaining_cents": 0, "promotional_remaining_cents": 5000, "estimated_remaining_cents": 1250 } ]}The token has the wrong prefix or matches no customer. Rotate the token to get a working link.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
The id of the request that produced this answer
(req_…). It is normally the same value as the
Hardcount-Request-Id response header. On an answer
replayed for a repeated Idempotency-Key, the body is the
first request’s, so this is the first request’s id, while
the Hardcount-Request-Id header holds the new request’s
id.
The request field or query parameter the error is about. Sent only when the error names one.
A request body may hold only the fields its operation
lists, spelled and cased as listed. Any other field, or one
the server sets (such as id), is refused with 422 and
param naming it. An operation with no request body lists
no fields: send no body, {} or null. The Stripe and
Postmark webhooks and the LiteLLM callback take their
sender’s body as it comes.
Example
{ "error": { "type": "authentication_error", "code": "unauthorized", "message": "invalid cost-dashboard token", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}Too many requests. Wait for the number of seconds in Retry-After,
then retry. The answers that pass the limit carry the
X-RateLimit-* headers too.
Each API key has its own limit, by default 1,000 requests a minute
(HARDCOUNT_), and 1,000 a second on the
usage routes (HARDCOUNT_). The dashboard
sessions of one account share one limit per mode. The routes under
/ and / (sign-in, password reset, invite
accept, setup) count per client address, by default 100 a minute
(HARDCOUNT_). The public invoice,
payment-update and cost-dashboard pages allow 60 a minute per client
address.
The body of an error answer. error. is the broad class,
error. is the exact reason for your code to branch on, and
error. is a sentence for a person. Quote
error. when you ask for help.
object
What went wrong.
object
One of invalid_, authentication_,
rate_ or api_. Every error the API
answers has this shape, including an unknown path (404,
code route_) and a method the path does not take
(405, code method_, with an Allow header).
The few exceptions are listed in
Errors.
The exact reason, such as validation_, not_,
already_, invalid_ or a more specific code
the operation lists. Branch on this, not on message.
What went wrong, written for a person to read.
The id of the request that produced this answer
(req_…). It is normally the same value as the
Hardcount-Request-Id response header. On an answer
replayed for a repeated Idempotency-Key, the body is the
first request’s, so this is the first request’s id, while
the Hardcount-Request-Id header holds the new request’s
id.
The request field or query parameter the error is about. Sent only when the error names one.
A request body may hold only the fields its operation
lists, spelled and cased as listed. Any other field, or one
the server sets (such as id), is refused with 422 and
param naming it. An operation with no request body lists
no fields: send no body, {} or null. The Stripe and
Postmark webhooks and the LiteLLM callback take their
sender’s body as it comes.
Example
{ "error": { "type": "rate_limit_error", "code": "rate_limited", "message": "too many requests — please retry after the rate limit resets", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}Headers
Section titled “Headers”Example
12Seconds to wait before the next request can pass, rounded up to a whole second and at least 1.
Example
1000How many requests the limit allows in its period (a minute, or a second on the usage routes).
Example
0How many requests are left in the current period.
Example
1793870460When the whole limit is available again, as Unix seconds. One
request may pass sooner; Retry-After says when.
Stuck, or found a bug? Ask in Discussions · Open an issue