List a customer's credit grants
const url = 'http://localhost:8080/v1/credits/grants/hc_cus_dakhnk2q3gpgqfoq5c0g';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/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_ to also list grants with nothing left, for
history. Each grant’s consumed_
also counts credit no invoice used: expired_, the part that
expired unused; retired_, commit credit taken back when the
invoice that funded it was refunded by a credit note; and
deducted_, 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_.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The customer’s ID (hc_).
Example
hc_cus_dakhnk2q3gpgqfoq5c0gQuery Parameters
Section titled “Query Parameters”true also lists the grants with nothing left (used up,
expired, retired or deducted). Any other value leaves them out.
Responses
Section titled “Responses”The grants, what is left on each, and subtotals by kind.
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
The customer’s credit grants, newest first. A grant with nothing
left is listed only with include_.
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
The ledger entry that added the credit.
grant or adjustment.
The block’s currency, uppercase.
Absent for unclassified credit.
The description of the ledger entry that added the credit.
The credit the grant started with, in the currency’s minor unit.
Everything drawn from the grant, in the currency’s minor unit: used by invoices, expired, retired and deducted.
Credit left in the grant, amount_ minus consumed_, in the currency’s minor unit.
The part that expired unused, in the currency’s minor unit.
Commit credit taken back when the invoice that funded it was refunded by a credit note, in the currency’s minor unit.
The part a dashboard user or an API key removed with a negative adjustment, in the currency’s minor unit.
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.
For a commit grant, the top-up whose payment made the grant. Absent for other grants.
When the grant was added.
One entry per currency with credit left, ordered by currency.
object
The currency, uppercase.
Remaining prepaid commit credit (commit), granted by paid top-ups, in the currency’s minor unit.
Remaining free credit (promotional), in the currency’s minor unit.
Remaining credit with no kind, such as adjustments and credit-note credit, in the currency’s minor unit.
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.
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" }}No customer with this ID in this account and mode.
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": "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_), 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