Skip to content
Hardcount
Run it locally
Pre-1.0 · one maintainer · Stripe and cards only · no SDKs (client libraries) yet · no production users yet. Docs describe v0.12.0 (30 Nov 2026) · What’s new →

Get a customer's public cost dashboard

GET
/v1/public/cost-dashboard/{token}
curl --request GET \
--url http://localhost:8080/v1/public/cost-dashboard/example

Public: 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 /v1/customers/{id}/rotate-cost-dashboard-token.

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_period.source no_subscription: 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.

token
required
string

The cost-dashboard token, hc_pcd_ and 64 hex characters.

The customer’s usage, cost and credit for the current billing period.

Media typeapplication/json
object
customer_id
required

The customer the token belongs to.

string
tenant_id
required

The account the customer belongs to.

string
livemode
required

False for a test-mode customer: show a test-mode notice.

boolean
billing_period
required

The period the usage covers.

object
start
required

Start of the period. The zero time 0001-01-01T00:00:00Z when source is no_subscription.

string format: date-time
end
required

End of the period, exclusive. The zero time when source is no_subscription.

string format: date-time
source
required

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_subscription: 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.

string
Allowed values: subscription no_subscription
subscriptions
required

One entry per plan of each active subscription.

Array<object>
object
id
required

The subscription’s ID.

string
plan_name
required

The plan’s name.

string
currency
required

The plan’s currency, such as USD.

string
current_period_start
required

Start of the subscription’s current billing period.

string format: date-time
current_period_end
required

End of the subscription’s current billing period, exclusive.

string format: date-time
usage
required

One entry per meter the customer’s plans price.

Array<object>
object
event_name
required

The event_name usage events send for the meter.

string
meter_name
required

The meter’s display name.

string
unit
required

The meter’s unit, such as tokens.

string
currency
required

The currency of the plan that priced the meter’s usage. Empty ("") when the meter has no usage this period.

string
total_quantity
required

The usage the prices took this period, as a decimal string.

string
total_amount_cents
required

What the usage costs, in the currency’s minor unit (cents for USD).

integer format: int64
prices
required

One row per price that took usage this period.

Array<object>
object
dimension_match

The labels the price takes. Absent for a price that takes every event.

object
key
additional properties
string
quantity
required

The usage this price took, as a decimal string.

string
amount_cents
required

What this price bills, in the currency’s minor unit (cents for USD).

integer format: int64
unit_amount_decimal

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_cents.

string
totals
required

One entry per currency present in usage.

Array<object>
object
currency
required

The currency, such as USD.

string
amount_cents
required

The usage cost in this currency, in its minor unit (cents for USD).

integer format: int64
projected_total_cents
required

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.

integer format: int64
credits
required

The customer’s credit position, one entry per currency, ordered by currency. balance_cents 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_usage_cents is the usage no invoice has billed yet that will be invoiced in that currency, and estimated_remaining_cents is the balance minus that, never below zero. These three are the same figures GET /v1/credits/balance/{customer_id}/live returns. It is an estimate: tax, base fees billed at period end and unpaid invoices are not subtracted.

Array<object>
object
currency
required

The currency of this entry.

string
balance_cents
required

The credit balance in this currency, in its minor unit (cents for USD).

integer format: int64
unbilled_usage_cents
required

Usage no invoice has billed yet, in minor units.

integer format: int64
commit_remaining_cents
required

What is left of the customer’s prepaid commit, in minor units.

integer format: int64
promotional_remaining_cents
required

What is left of promotional credit, in minor units.

integer format: int64
estimated_remaining_cents
required

The balance minus unbilled usage, never below zero, in minor units.

integer format: int64

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.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

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.

string
param

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.

string

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_RATE_LIMIT_GENERAL_PER_MIN), and 1,000 a second on the usage routes (HARDCOUNT_RATE_LIMIT_INGEST_PER_SEC). The dashboard sessions of one account share one limit per mode. The routes under /v1/auth and /v1/bootstrap (sign-in, password reset, invite accept, setup) count per client address, by default 100 a minute (HARDCOUNT_RATE_LIMIT_AUTH_PER_MIN). The public invoice, payment-update and cost-dashboard pages allow 60 a minute per client address.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

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.

string
param

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.

string

Example

{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "too many requests — please retry after the rate limit resets",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}
Retry-After
integer
Example
12

Seconds to wait before the next request can pass, rounded up to a whole second and at least 1.

X-RateLimit-Limit
integer
Example
1000

How many requests the limit allows in its period (a minute, or a second on the usage routes).

X-RateLimit-Remaining
integer
Example
0

How many requests are left in the current period.

X-RateLimit-Reset
integer format: int64
Example
1793870460

When 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