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 →

List usage events

GET
/v1/usage-events
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_status. Needs a secret key; a usage-only key cannot call it.

customer_id
string

Only this customer’s events (hc_cus_…, the Hardcount ID, not your external ID).

meter_id
string

Only this meter’s events (hc_mtr_…).

dimensions
string

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,token_type=input.

from
string

Only events at or after this time. RFC 3339, or a date (YYYY-MM-DD) meaning 00:00:00 UTC.

to
string

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.

limit
integer
default: 50 >= 1 <= 100

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.

offset
integer
0

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.

Event list

Media typeapplication/json
object
data
required
Array<object>

One usage event: a quantity of one meter’s usage, for one customer, at one time. Returned by POST /v1/usage-events and POST /v1/usage-events/backfill, and listed by GET /v1/usage-events. An event counts toward the billing period its timestamp falls in.

object
id
required

The event’s ID (hc_evt_…).

string
tenant_id

The account the event belongs to.

string
customer_id
required

The customer the event was recorded for (hc_cus_…): the customer whose external_id you sent as external_customer_id.

string
meter_id
required

The meter the event counts toward (hc_mtr_…): the meter whose event_name you sent.

string
quantity
required

Exact quantity as a decimal string (e.g. “1.5”).

string
dimensions

The dimension values sent with the event. Absent when none were sent.

object
key
additional properties
any
idempotency_key

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.

string
timestamp
required

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_status).

string format: date-time
origin

How the event arrived. api: POST /v1/usage-events, the batch route or the LiteLLM integration. backfill: POST /v1/usage-events/backfill, or released held usage. Absent on the rows of GET /v1/usage-events, which does not return it.

string
Allowed values: api backfill
provider_cost_cents

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_cost_source). Absent when no rate matched or the cost was too large to store, and when the source is not_applicable.

string
provider_cost_source

Where provider_cost_cents came from: table (your provider cost rates), observed (the cost LiteLLM reported for the call), or not_applicable: the event lacks a provider or token_type dimension, or has neither model nor model_raw, so no rate can apply. Absent when the event has those dimensions but no rate matched.

string
Allowed values: table not_applicable observed
billing_status

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_close: the event’s time is already invoiced. Bill the event with a one-off invoice if it should be charged.
  • not_on_plan: a billing period not invoiced yet holds the event’s time, but its plan has no price for this meter.
  • outside_subscription: 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.
  • no_price: the plan that bills the event’s time prices this meter, but no price of that plan takes the event’s dimensions. A price takes an event whose dimensions include all of the price’s dimension_match labels. A price’s labels are text, so a number or a true/false value in the event never matches: the number 1 does not match the string "1".

No billing_status 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.

string
Allowed values: after_close no_price not_on_plan outside_subscription
total
required

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.

integer

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.

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 or expired API key",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The credential is valid but may not call this route. A usage-only key (hc_ingest_…) can only send usage, read a customer’s live credit balance and call GET /v1/whoami; 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.

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": "forbidden",
"message": "insufficient permissions: this key type does not have customer:read access",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

validation_error: 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).

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": "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_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