Answers the org's own postings inside `range=`, each as a signed entry: a…
Answers the org's own postings inside `range=`, each as a signed entry: a DEPOSIT CREDITS the wallet (positive, account `credits:<org>`) and every other…
GET /v1/billing/ledger
| Address | https://api.hanzo.ai/v1/billing/ledger |
| Method | GET |
| Operation | get_billing_ledger |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Answers the org's own postings inside range=, each as a signed
entry: a DEPOSIT CREDITS the wallet (positive, account credits:<org>) and
every other posting DEBITS it (negative, account usage:<org>), described by
its notes or its tags. The sign is the posting's own meaning, read through ONE
vocabulary shared with the ledger that wrote it — a reader with its own
spelling for deposit rendered a customer's grant as a charge.
This is the closest projection of the truth. The org's double-entry postings are the source of record — balanced, only ever appended, one file per org — and this lane is that list, wider than either half of it: the deposits are the grants /v1/billing/credits lists and the debits are the spend /v1/billing/usage rolls up. It answers 503 where this deployment runs no ledger, rather than reporting an empty wallet.
A row whose timestamp will not parse is KEPT rather than dropped — a malformed
date must show up in a money list, not vanish from it. balanceCents is
omitted: these are MOVEMENTS, and the standing balance is /v1/billing/balance.
Cents are ROUNDED from the ledger's exact 18-decimal USD. Scoped to the caller's own org, where the org's ledger file is the tenant boundary; 401 without a validated principal.
Request
1 field.
| Field | In | Type | Required | Description |
|---|---|---|---|---|
range | query | string | — | Range is the window: 24h, 7d, 30d or 90d. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | financeLedgerEntry[] | ok |
200 body — 7 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
[].account | body | string | — | |
[].balanceCents | body | integer | — | |
[].cents | body | integer | — | |
[].currency | body | string | — | |
[].date | body | string | — | |
[].description | body | string | — | |
[].id | body | string | — |
Failure carries the platform error shape — see Errors.
Examples
hanzo has no subcommand for this operation — the CLI serves only what cloud's live route table confirms. Use HTTP or an SDK.
import { Configuration, BillingApi } from 'hanzoai';
const api = new BillingApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getBillingLedger();from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import BillingApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = BillingApi(client).get_billing_ledger()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.BillingAPI.GetBillingLedger(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, billing_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = billing_api::get_billing_ledger(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.BillingApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new BillingApi(client).getBillingLedger();The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →
curl https://api.hanzo.ai/v1/billing/ledger \
-H "Authorization: Bearer $HANZO_API_KEY"The door reaches billing through the billing tool, which names its 9 operations with its own verbs — this one among them, under a name only the door declares. describe explains any of them:
curl -X POST https://api.hanzo.ai/v1/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "describe",
"arguments": {
"op": "get_billing_balance"
}
}
}'How is this guide?