OpenapiBooks
Returns the org's accrual-basis Profit & Loss over an optional (from, to]…
Returns the org's accrual-basis Profit & Loss over an optional (from, to] window of RFC3339 posting times: recognized revenue, matched cost, and the net.
GET /v1/books/pnl
| Address | https://api.hanzo.ai/v1/books/pnl |
| Method | GET |
| Operation | get_books_pnl |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Returns the org's accrual-basis Profit & Loss over an optional (from, to] window of RFC3339 posting times: recognized revenue, matched cost, and the net.
Request
3 fields.
| Field | In | Type | Required | Description |
|---|---|---|---|---|
sandbox | query | string | — | Sandbox reads the org's SANDBOX ledger when it is exactly "true". |
from | query | string | — | From is the RFC3339 start of the window, exclusive. |
to | query | string | — | To is the RFC3339 end of the window, inclusive. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | PnL | ok |
200 body — 15 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
expense | body | PnLLine[] | — | Expense is the cost lines that moved in the period, one per account. |
expense[].account | body | string | — | Account is the chart-of-accounts number this line reports on. |
expense[].amount | body | integer | — | Amount is the account's movement over the period in whole cents, in its NATURAL sign: positive when the account behaved normally, for income and expense alike. |
expense[].name | body | string | — | Name is that account's human name from the fixed chart. |
expense[].type | body | string | — | Type is the account's fundamental class, which on this statement is always income or expense — it tells a reader which half of the statement the line came from… |
from | body | string | — | From opens the period and is EXCLUSIVE — movement strictly after it, matching the trial balance's opening boundary so the two reports agree on what belongs to… |
income | body | PnLLine[] | — | Income is the revenue lines that moved in the period, one per account. |
income[].account | body | string | — | Account is the chart-of-accounts number this line reports on. |
income[].amount | body | integer | — | Amount is the account's movement over the period in whole cents, in its NATURAL sign: positive when the account behaved normally, for income and expense alike. |
income[].name | body | string | — | Name is that account's human name from the fixed chart. |
income[].type | body | string | — | Type is the account's fundamental class, which on this statement is always income or expense — it tells a reader which half of the statement the line came from… |
netIncome | body | integer | — | NetIncome is totalIncome minus totalExpense, in cents. |
to | body | string | — | To closes the period and is inclusive. |
totalExpense | body | integer | — | TotalExpense is cost MATCHED to that revenue, in cents, including accrued infrastructure that has not been billed yet. |
totalIncome | body | integer | — | TotalIncome is revenue RECOGNIZED in the period, in cents — accrual, not cash, so a prepaid top-up is not in it until the credit is consumed. |
Failure carries the platform error shape — see Errors.
Examples
hanzo books pnlimport { Configuration, BooksApi } from 'hanzoai';
const api = new BooksApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getBooksPnl();from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import BooksApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = BooksApi(client).get_books_pnl()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.BooksAPI.GetBooksPnl(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, books_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = books_api::get_books_pnl(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.BooksApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new BooksApi(client).getBooksPnl();curl https://api.hanzo.ai/v1/books/pnl \
-H "Authorization: Bearer $HANZO_API_KEY"The door reaches books through the books tool, which names its 24 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": "list_book_accounts"
}
}
}'How is this guide?