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 a customer's credit grants

GET
/v1/credits/grants/{customer_id}
curl --request GET \
--url http://localhost:8080/v1/credits/grants/hc_cus_dakhnk2q3gpgqfoq5c0g \
--header 'Authorization: Bearer <token>'

The customer’s credit grants. For each grant: how much was granted, how much is drawn, how much is left, and when it expires. The answer also gives what is left in each currency, split by kind: commit (credit the customer paid for), promotional (free credit) and other (older entries and adjustments). Send include_exhausted=true to also list grants with nothing left, for history. Each grant’s consumed_cents also counts credit no invoice used: expired_cents, the part that expired unused; retired_cents, commit credit taken back when the invoice that funded it was refunded by a credit note; and deducted_cents, the part a deduction (a negative adjustment by a dashboard user or an API key) drew from this grant. The credit invoices actually used is consumed_cents - expired_cents - retired_cents - deducted_cents.

customer_id
required
string

The customer’s ID (hc_cus_…).

Example

hc_cus_dakhnk2q3gpgqfoq5c0g
include_exhausted
boolean

true also lists the grants with nothing left (used up, expired, retired or deducted). Any other value leaves them out.

The grants, what is left on each, and subtotals by kind.

Media typeapplication/json

A customer’s credit grants, newest first, with the remaining credit added up by currency and kind. Amounts are in the currency’s minor unit (cents for USD).

object
grants
required

The customer’s credit grants, newest first. A grant with nothing left is listed only with include_exhausted=true.

Array<object>

One grant on a customer’s credit balance (made by a grant or a positive adjustment) and how much of it is left. Amounts are in the currency’s minor unit (cents for USD).

object
id
required

The ledger entry that added the credit.

string
entry_type
required

grant or adjustment.

string
currency
required

The block’s currency, uppercase.

string
grant_kind

Absent for unclassified credit.

string
Allowed values: commit promotional
description
required

The description of the ledger entry that added the credit.

string
amount_cents
required

The credit the grant started with, in the currency’s minor unit.

integer format: int64
consumed_cents
required

Everything drawn from the grant, in the currency’s minor unit: used by invoices, expired, retired and deducted.

integer format: int64
remaining_cents
required

Credit left in the grant, amount_cents minus consumed_cents, in the currency’s minor unit.

integer format: int64
expired_cents
required

The part that expired unused, in the currency’s minor unit.

integer format: int64
retired_cents
required

Commit credit taken back when the invoice that funded it was refunded by a credit note, in the currency’s minor unit.

integer format: int64
deducted_cents
required

The part a dashboard user or an API key removed with a negative adjustment, in the currency’s minor unit.

integer format: int64
expires_at

The credit can be drawn up to and including this instant; a period invoice draws it when its period ends at or before it. The dashboard sends the local midnight after the picked day. Absent when the credit does not expire.

string format: date-time
source_invoice_id

For a commit grant, the top-up whose payment made the grant. Absent for other grants.

string
created_at
required

When the grant was added.

string format: date-time
remaining_by_currency
required

One entry per currency with credit left, ordered by currency.

Array<object>
object
currency
required

The currency, uppercase.

string
commit_remaining_cents
required

Remaining prepaid commit credit (commit), granted by paid top-ups, in the currency’s minor unit.

integer format: int64
promotional_remaining_cents
required

Remaining free credit (promotional), in the currency’s minor unit.

integer format: int64
other_remaining_cents
required

Remaining credit with no kind, such as adjustments and credit-note credit, in the currency’s minor unit.

integer format: int64

Example

{
"grants": [
{
"id": "hc_ccl_dav2242q3gpgqfoq5c50",
"entry_type": "grant",
"currency": "USD",
"grant_kind": "promotional",
"description": "Welcome credit",
"amount_cents": 5000,
"consumed_cents": 0,
"remaining_cents": 5000,
"expired_cents": 0,
"retired_cents": 0,
"deducted_cents": 0,
"expires_at": "2027-01-01T00:00:00Z",
"created_at": "2026-10-01T09:00:00Z"
}
],
"remaining_by_currency": [
{
"currency": "USD",
"commit_remaining_cents": 0,
"promotional_remaining_cents": 5000,
"other_remaining_cents": 0
}
]
}

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"
}
}

No customer with this ID in this account and mode.

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": "not_found",
"message": "customer not found",
"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