List usage events
const url = 'http://localhost:8080/v1/usage-events?limit=50&offset=0';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
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/usage-events?limit=50&offset=0' \ --header 'Authorization: Bearer <token>'Lists the usage events of this account and mode, newest first by
timestamp. The filters combine; total counts every matching
event. The rows carry no origin and no billing_. Needs a
secret key; a usage-only key cannot call it.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Only this customer’s events (hc_, the Hardcount ID, not your external ID).
Only this meter’s events (hc_).
Comma-separated key=value pairs matched against the event’s
dimensions; every pair must match. Values that read as JSON
booleans or numbers match typed values (“cached=true”,
“attempt=2”); everything else matches as a string. A malformed
pair is refused with 422. Example:
model=gpt-4o,.
Only events at or after this time. RFC 3339, or a date (YYYY-MM-DD) meaning 00:00:00 UTC.
Only events before this time, exclusive. RFC 3339, or a date (YYYY-MM-DD) meaning 23:59:59.999999 UTC that day, so the day is included.
Rows per page, from 1 to 100. Default 50. Any other value, one that
is not a whole number, or limit sent twice is a 422 with
param: limit. It is never clamped.
Rows to skip, 0 or more. Default 0. A negative value, one that is
not a whole number, or offset sent twice is a 422 with
param: offset.
Responses
Section titled “Responses”Event list
object
One usage event: a quantity of one meter’s usage, for one customer,
at one time. Returned by POST / and
POST /, and listed by
GET /. An event counts toward the billing period
its timestamp falls in.
object
The event’s ID (hc_).
The account the event belongs to.
The customer the event was recorded for (hc_): the
customer whose external_ you sent as
external_.
The meter the event counts toward (hc_): the meter whose
event_ you sent.
Exact quantity as a decimal string (e.g. “1.5”).
The dimension values sent with the event. Absent when none were sent.
object
The key the event was sent with. Hardcount keeps one event per key in each account and mode (live or test), with no expiry: an event sent later with the same key is not stored again, however long after. Absent on an event stored without a key.
When the usage happened. It decides which billing period the
event counts toward. An event sent without timestamp is
stamped with the time Hardcount received it. An event that is
not a backfill may be at most 5 minutes ahead of that time. There is no limit on how far
back it goes, but an event in a period whose invoice is already
built is stored and not billed (see billing_).
How the event arrived. api: POST /, the batch
route or the LiteLLM integration. backfill:
POST /, or released held usage.
Absent on the rows of GET /, which does not
return it.
What serving this event cost you at your provider, in US cents as
a decimal string (e.g. “0.45”), set when the event arrived: from
your provider cost rates, or the cost LiteLLM reported for the
call (see provider_). Absent when no rate matched
or the cost was too large to store, and when the source is
not_.
Where provider_ came from: table (your provider
cost rates), observed (the cost LiteLLM reported for the
call), or not_: the event lacks a provider or
token_ dimension, or has neither model nor model_,
so no rate can apply. Absent when the event has those
dimensions but no rate matched.
What Hardcount found when the event arrived. It checked the event against the customer’s subscriptions, the plans and prices in force, and the invoices already built at that moment. Sent only on the answer that wrote the event; the event is stored all the same.
A status that is present was true at that moment:
after_: the event’s time is already invoiced. Bill the event with a one-off invoice if it should be charged.close not_: a billing period not invoiced yet holds the event’s time, but its plan has no price for this meter.on_ plan outside_: no active subscription of the customer bills the event’s time. For example, it has none, or the time is before one starts, or after one ends or its scheduled cancel.subscription no_: the plan that bills the event’s time prices this meter, but no price of that plan takes the event’sprice dimensions. A price takes an event whose dimensions include all of the price’sdimension_labels. A price’s labels are text, so a number or a true/false value in the event never matches: the numbermatch 1does not match the string"1".
No billing_ means Hardcount found no reason then. It is not a
promise that the event will be billed. Hardcount checks only the
customer’s current billing periods: time after a period end whose
invoice is not built yet is not checked. A later change can change
the outcome either way: a subscription created or changed, a
scheduled cancel undone, or a price added. The invoice is the final
answer.
Two cases can make a present status wrong: a price change whose save began before a billing period started and finished after the request read the prices, and a subscription change saved while the request is in flight. Absent on a replay and on a read.
How many rows match the request’s filters, on every page, not only this one. The audit log and the customer list’s search and name or email sort say where they stop counting.
Example
{ "data": [ { "id": "hc_evt_db6eh6qq3gpgqfoq5c3k", "tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00", "customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g", "meter_id": "hc_mtr_dajr122q3gpgqfoq5c10", "quantity": "350", "dimensions": { "model": "gpt-4o", "provider": "openai", "token_type": "output" }, "idempotency_key": "req-7f3a9c-out", "timestamp": "2026-10-12T14:03:07Z", "provider_cost_cents": "0.35", "provider_cost_source": "table" }, { "id": "hc_evt_db6eh6qq3gpgqfoq5c3g", "tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00", "customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g", "meter_id": "hc_mtr_dajr122q3gpgqfoq5c10", "quantity": "1200", "dimensions": { "model": "gpt-4o", "provider": "openai", "token_type": "input" }, "idempotency_key": "req-7f3a9c", "timestamp": "2026-10-12T14:03:07Z", "provider_cost_cents": "0.3", "provider_cost_source": "table" } ], "total": 4210}No valid credential: the API key or session is missing, wrong,
expired or revoked. With no API key and no valid session cookie, the
message starts with missing credentials. A wrong, expired and
revoked key all get the same message, invalid or expired API key.
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 or expired API key", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}The credential is valid but may not call this route. A usage-only
key (hc_) can only send usage, read a customer’s live
credit balance and call GET /; use a secret key. The message names the permission the key
lacks. A browser request that would change data (POST, PUT, PATCH
or DELETE) from a page on another site gets this 403 too, with the
message cross-site request blocked.
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": "forbidden", "message": "insufficient permissions: this key type does not have customer:read access", "request_id": "req_dbjg652q3gpgqfoq5cd0" }}validation_: a from or to that cannot be parsed, to before from, or a limit or offset out of range (param names the field); or a malformed dimensions pair (no param).
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": "invalid_request_error", "code": "validation_error", "message": "must be RFC3339 (e.g. 2026-01-01T00:00:00Z) or YYYY-MM-DD", "request_id": "req_dbjg652q3gpgqfoq5cd0", "param": "from" }}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