# List pnl

URL: https://docs.hanzo.ai/docs/openapi/books/get-books-pnl

> 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`

> [Books →](https://docs.hanzo.ai/docs/openapi/books) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                        |
| ------------- | -------------------------------------- |
| **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`     | books.PnL       | ok      |
| `default` | problem-details | refused |

`200` body — 15 fields.

| Field               | In   | Type             | Always | Description                                                                                                                                                                                                          |
| ------------------- | ---- | ---------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `expense`           | body | books.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 (int64)  | —      | 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 without re-deriving it from the array it arrived in. |
| `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 a period.                                             |
| `income`            | body | books.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 (int64)  | —      | 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 without re-deriving it from the array it arrived in. |
| `netIncome`         | body | integer (int64)  | —      | NetIncome is totalIncome minus totalExpense, in cents.                                                                                                                                                               |
| `to`                | body | string           | —      | To closes the period and is inclusive.                                                                                                                                                                               |
| `totalExpense`      | body | integer (int64)  | —      | TotalExpense is cost MATCHED to that revenue, in cents, including accrued infrastructure that has not been billed yet.                                                                                               |
| `totalIncome`       | body | integer (int64)  | —      | 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](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo books pnl
```

**SDK**

**.ts**

```ts
import { Configuration, BooksApi } from 'hanzoai';

const api = new BooksApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getBooksPnl();
```

**.py**

```python
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()
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.BooksAPI.GetBooksPnl(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::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?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.BooksApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new BooksApi(client).getBooksPnl();
```

**HTTP**

```bash
curl https://api.hanzo.ai/v1/books/pnl \
  -H "Authorization: Bearer $HANZO_API_KEY"
```

**MCP**

MCP reaches **books** through the `books` tool, which names its 20 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
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"
         }
       }
     }'
```

---

[Books API](https://docs.hanzo.ai/docs/openapi/books) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
