Wallets
Customers' prepaid balances and their ledgers.
Every amount is an integer number of micro-USD as a decimal string. A customer's balance is purchased credit plus the grants that have not expired; requests that name the customer are paid from it when the environment's wallet policy is on.
| Operation | Method | SDK |
|---|---|---|
| Grant credit | POST | hixel.wallets.grant |
| Credit a wallet | POST | hixel.wallets.credit |
| Get a customer's wallet | GET | hixel.wallets.get |
| List a customer's ledger | GET | hixel.wallets.listLedger |
| List wallets | GET | hixel.wallets.list |
| Get outstanding credit | GET | hixel.wallets.outstanding |
| List the environment's ledger | GET | hixel.ledger.list |
| Summarize the ledger | GET | hixel.ledger.summary |
Grant credit#
Adds credit without payment, such as a plan's allowance, optionally expiring. Written to the ledger at once, then applied to the gateway's balance of the customer; the wallet's pending_credits counts the credits the gateway has not confirmed yet, which are retried until it does. A retry with the same idempotency_key answers the same entry (200); the same key with another kind, amount or expiry is credit_idempotency_key_reused.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Request body: GrantBody
| Field | Type | Description |
|---|---|---|
amount_micros required | string | Positive micro-USD as a decimal string, at most 1,000,000 USD. |
expires_at | string (date-time) | When the grant's unspent credit expires; never when left out. |
idempotency_key required | string | Grants once per key, forever: a plan allowance keys on its billing period. |
reason | string | Why, in your words; kept on the ledger entry. |
Response 200: LedgerEntry
| Field | Type | Description |
|---|---|---|
id required | string | The id of a ledger entry (led_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
wallet_id required | string | The id of a customer's wallet (wal_…). |
customer required | string | Your id for the customer (its external_id), as every path takes it. |
kind required | "grant" | "top_up" | "auto_refill" | "usage" | "refund" | "adjustment" | … | Why a ledger entry moved a wallet's balance. |
amount_micros required | string | Signed: credits are positive, usage and expiry negative. |
idempotency_key required | string | |
grant_key required | string | null | The grant a usage or expiry entry draws from (its idempotency key). |
grant_entry_id required | string | null | |
expires_at required | string | null | A grant's expiry; null for one that never expires. |
usage_event_id required | string | null | |
reason required | string | null | |
actor required | object | |
actor.user_id required | string | null | null for a key or for the platform itself. |
actor.label required | string | An email address, a key id, or hixel:usage. |
created_at required | string (date-time) |
Errors
- 400
invalid_amount,invalid_expiry,invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.credit_idempotency_key_reused: This idempotency_key already credited this wallet with another kind, amount or expiry. Use a new key for a new credit.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X POST "https://api.hixel.dev/v1/customers/org_42/grants" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount_micros": "5000000",
"idempotency_key": "plan:org_42:2026-11"
}'const ledgerEntry = await hixel.wallets.grant("org_42", {
amount_micros: "5000000",
idempotency_key: "plan:org_42:2026-11",
});Credit a wallet#
A manual top-up, an adjustment or a refund. Written to the ledger at once, then applied to the gateway's balance of the customer; the wallet's pending_credits counts the credits the gateway has not confirmed yet, which are retried until it does. A retry with the same idempotency_key answers the same entry (200); the same key with another kind, amount or expiry is credit_idempotency_key_reused.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Request body: CreditBody
| Field | Type | Description |
|---|---|---|
kind required | "top_up" | "adjustment" | "refund" | top_up (positive), adjustment (either sign) or refund (positive returns purchased credit, negative takes it back). A top-up paid through Stripe Checkout is credited by the platform itself. |
amount_micros required | string | Micro-USD as a decimal string: positive for a top-up, signed for an adjustment or refund. |
idempotency_key required | string | Credits once per key, forever: 1 to 200 characters of visible ASCII, not starting with usage:, expiry: or stripe:. |
reason | string | Why, in your words; kept on the ledger entry. |
Response 200: LedgerEntry
| Field | Type | Description |
|---|---|---|
id required | string | The id of a ledger entry (led_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
wallet_id required | string | The id of a customer's wallet (wal_…). |
customer required | string | Your id for the customer (its external_id), as every path takes it. |
kind required | "grant" | "top_up" | "auto_refill" | "usage" | "refund" | "adjustment" | … | Why a ledger entry moved a wallet's balance. |
amount_micros required | string | Signed: credits are positive, usage and expiry negative. |
idempotency_key required | string | |
grant_key required | string | null | The grant a usage or expiry entry draws from (its idempotency key). |
grant_entry_id required | string | null | |
expires_at required | string | null | A grant's expiry; null for one that never expires. |
usage_event_id required | string | null | |
reason required | string | null | |
actor required | object | |
actor.user_id required | string | null | null for a key or for the platform itself. |
actor.label required | string | An email address, a key id, or hixel:usage. |
created_at required | string (date-time) |
Errors
- 400
invalid_amount,invalid_expiry,invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.credit_idempotency_key_reused: This idempotency_key already credited this wallet with another kind, amount or expiry. Use a new key for a new credit.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X POST "https://api.hixel.dev/v1/customers/org_42/credits" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"kind": "top_up",
"amount_micros": "5000000",
"idempotency_key": "plan:org_42:2026-11"
}'const ledgerEntry = await hixel.wallets.credit("org_42", {
kind: "top_up",
amount_micros: "5000000",
idempotency_key: "plan:org_42:2026-11",
});Get a customer's wallet#
The customer's balance, grants and the gateway's live view of them; customer_not_found when the environment has no customer by this id. A customer without a ledger entry has a zero balance and wallet_id null.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Response 200: Wallet
| Field | Type | Description |
|---|---|---|
customer required | string | Your id for the customer (its external_id), as every path takes it. |
wallet_id required | string | null | null until the first entry. |
balance required | object | As the ledger sums it, unexpired grants only: purchased credit plus grants. |
balance.purchased_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
balance.grants_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
balance.total_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
grants required | array of object | The grants with credit left, soonest expiry first. |
grants[].entry_id required | string | The id of a ledger entry (led_…). |
grants[].key required | string | The grant's idempotency key. |
grants[].amount_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
grants[].remaining_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
grants[].expires_at required | string | null | |
pending_credits required | integer | Credits the gateway has not confirmed yet. |
rejected_credits required | integer | Credits the gateway refused for good: in the ledger, not in the balance the gateway holds. |
live required | object | The gateway's live view of the balance, or unavailable when it could not be read just now. |
live.status required | "available" | |
live.balance required | object | |
live.balance.purchased_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
live.balance.grants_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
live.balance.total_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
live.reserved_micros required | string | Held by requests still running. |
live.available_micros required | string | The balance minus what running requests hold: what a new request may spend. |
live.spend required | object | Settled spend in each current window (UTC; weeks start on Monday). |
live.spend.day_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
live.spend.week_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
live.spend.month_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
live.spend.total_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/customers/org_42/wallet" \
-H "Authorization: Bearer $HIXEL_API_KEY"const wallet = await hixel.wallets.get("org_42");List a customer's ledger#
A page of the customer's ledger entries, newest first.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
cursor | query | string | The next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it. |
limit | query | integer | How many items the page holds: an integer from 1 to 100; 50 when left out. |
Response 200: LedgerEntryList
| Field | Type | Description |
|---|---|---|
data required | array of LedgerEntry | |
data[].id required | string | The id of a ledger entry (led_…). |
data[].organization_id required | string | The id of your organization (org_…). |
data[].project_id required | string | The id of a project (proj_…). |
data[].environment_id required | string | The id of an environment (env_…). |
data[].wallet_id required | string | The id of a customer's wallet (wal_…). |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
data[].kind required | "grant" | "top_up" | "auto_refill" | "usage" | "refund" | "adjustment" | … | Why a ledger entry moved a wallet's balance. |
data[].amount_micros required | string | Signed: credits are positive, usage and expiry negative. |
data[].idempotency_key required | string | |
data[].grant_key required | string | null | The grant a usage or expiry entry draws from (its idempotency key). |
data[].grant_entry_id required | string | null | |
data[].expires_at required | string | null | A grant's expiry; null for one that never expires. |
data[].usage_event_id required | string | null | |
data[].reason required | string | null | |
data[].actor required | object | |
data[].actor.user_id required | string | null | null for a key or for the platform itself. |
data[].actor.label required | string | An email address, a key id, or hixel:usage. |
data[].created_at required | string (date-time) | |
next_cursor required | string | null | Pass back as cursor for the next page; null on the last page. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_cursor: The cursor is not one this list gave.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/customers/org_42/ledger" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.wallets.listLedger("org_42")) {
console.log(item);
}List wallets#
A page of the environment's wallets (customers with a ledger entry), by balance. Balances move while usage is recorded, so a wallet whose balance crosses the page boundary between two calls may be listed twice or skipped.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
sort | query | "balance_asc" | "balance_desc" | By total balance: balance_asc (the default) or balance_desc. |
balance_alert | query | array of "none" | "low" | "depleted" | Only wallets in one of these states, given once or several times: none, low (below the environment's threshold) or depleted (at or below zero). |
customer | query | array of string | Only these customers' wallets, by your ids for them, given once or up to 100 times. A customer without a wallet is not listed. |
cursor | query | string | The next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it. |
limit | query | integer | How many items the page holds: an integer from 1 to 100; 50 when left out. |
Response 200: WalletList
| Field | Type | Description |
|---|---|---|
data required | array of WalletSummary | |
data[].id required | string | The id of a customer's wallet (wal_…). |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
data[].customer_name required | string | null | The customer's name; null when you never named it. |
data[].balance required | object | |
data[].balance.purchased_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
data[].balance.grants_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
data[].balance.total_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
data[].balance_alert required | "none" | "low" | "depleted" | Which low-balance webhook a wallet last sent: none while its balance is at or above the environment's threshold, low once wallet.balance_low was sent, depleted once wallet.depleted was. |
data[].last_activity_at required | string (date-time) | When the wallet's latest ledger entry was written. |
data[].created_at required | string (date-time) | |
next_cursor required | string | null | Pass back as cursor for the next page; null on the last page. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_cursor: The cursor is not one this list gave.environment_required: a project key was sent withoutx-hixel-environment.invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/wallets" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.wallets.list()) {
console.log(item);
}Get outstanding credit#
The credit the environment's customers hold now, summed over every wallet as each wallet's balance is defined: purchased credit and grants, how many wallets are low or depleted, and how many credits the gateway has not confirmed.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Response 200: OutstandingCredit
| Field | Type | Description |
|---|---|---|
environment_id required | string | The id of an environment (env_…). |
balance required | object | |
balance.purchased_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
balance.grants_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
balance.total_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
wallets required | integer | |
low_wallets required | integer | |
depleted_wallets required | integer | |
pending_credits required | integer | |
rejected_credits required | integer | |
as_of required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/wallets/outstanding" \
-H "Authorization: Bearer $HIXEL_API_KEY"const outstandingCredit = await hixel.wallets.outstanding();List the environment's ledger#
A page of the ledger across the environment's customers, newest first. customer_not_found when customer names no customer of the environment.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
kind | query | array of "grant" | "top_up" | "auto_refill" | "usage" | "refund" | "adjustment" | … | Only entries of these kinds, given once or several times. |
customer | query | string | Only this customer's entries, by your id for it. |
from | query | string (date-time) | Only entries written at or after this instant. |
to | query | string (date-time) | Only entries written before this instant. |
cursor | query | string | The next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it. |
limit | query | integer | How many items the page holds: an integer from 1 to 100; 50 when left out. |
Response 200: EnvironmentLedgerEntryList
| Field | Type | Description |
|---|---|---|
data required | array of EnvironmentLedgerEntry | |
data[].id required | string | The id of a ledger entry (led_…). |
data[].organization_id required | string | The id of your organization (org_…). |
data[].project_id required | string | The id of a project (proj_…). |
data[].environment_id required | string | The id of an environment (env_…). |
data[].wallet_id required | string | The id of a customer's wallet (wal_…). |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
data[].kind required | "grant" | "top_up" | "auto_refill" | "usage" | "refund" | "adjustment" | … | Why a ledger entry moved a wallet's balance. |
data[].amount_micros required | string | Signed: credits are positive, usage and expiry negative. |
data[].idempotency_key required | string | |
data[].grant_key required | string | null | The grant a usage or expiry entry draws from (its idempotency key). |
data[].grant_entry_id required | string | null | |
data[].expires_at required | string | null | A grant's expiry; null for one that never expires. |
data[].usage_event_id required | string | null | |
data[].reason required | string | null | |
data[].actor required | object | |
data[].actor.user_id required | string | null | null for a key or for the platform itself. |
data[].actor.label required | string | An email address, a key id, or hixel:usage. |
data[].created_at required | string (date-time) | |
data[].customer_name required | string | null | The customer's name; null when you never named it. |
next_cursor required | string | null | Pass back as cursor for the next page; null on the last page. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_cursor: The cursor is not one this list gave.invalid_range:frommust be beforeto, and a summary covers at most 92 days.environment_required: a project key was sent withoutx-hixel-environment.invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/ledger" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.ledger.list()) {
console.log(item);
}Summarize the ledger#
The environment's ledger by UTC day and kind over the range, at most 92 days.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
from required | query | string (date-time) | The start of the range, inclusive. |
to required | query | string (date-time) | The end of the range, exclusive: at most 92 days after from. |
Response 200: LedgerSummary
| Field | Type | Description |
|---|---|---|
from required | string (date-time) | |
to required | string (date-time) | |
rows required | array of object | |
rows[].day required | string | |
rows[].kind required | "grant" | "top_up" | "auto_refill" | "usage" | "refund" | "adjustment" | … | Why a ledger entry moved a wallet's balance. |
rows[].entries required | integer | |
rows[].amount_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
rows[].credited_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
rows[].debited_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_range:frommust be beforeto, and a summary covers at most 92 days.environment_required: a project key was sent withoutx-hixel-environment.invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/ledger/summary?from=2026-11-01T00%3A00%3A00Z&to=2026-12-01T00%3A00%3A00Z" \
-H "Authorization: Bearer $HIXEL_API_KEY"const ledgerSummary = await hixel.ledger.summary({
from: "2026-11-01T00:00:00Z",
to: "2026-12-01T00:00:00Z",
});