# Billing API

> Read your organization's balance, credit changes and usage.

The organization's own billing view, read-only: wallet balance and mode, credit changes, usage.

- Base path: `/billing/v1/`; Connect/gRPC `pingx.billing.v1.BillingService`.
- Auth: `Authorization: Bearer <key>`; scope `billing:read` (or `billing`). The service has no write
  RPCs, so `billing:write` grants nothing extra.
- Money: integer **millicredits** (1 credit = 1000). int64 values are JSON strings. Timestamps RFC 3339.
- Pagination: `pageSize` (default 25, max 100) / `pageToken` -> `nextPageToken` (opaque, newest first;
  a full final page may be followed by one empty page).

| RPC | REST | Scope |
|---|---|---|
| GetBilling | `GET /billing/v1/account` | read |
| ListCreditChanges | `GET /billing/v1/credit-changes?pageSize=&pageToken=` | read |
| GetUsageSummary | `GET /billing/v1/usage/summary?days=` (default 30, max 366) | read |
| ListUsage | `GET /billing/v1/usage/events?operation=&pageSize=&pageToken=` | read |

## Deliberate exclusions

No payment, top-up or checkout initiation, no change of billing mode, negative-credit limit, rates or
credits, no enforcer/rate tables, no staff identities (credit changes show the note, not who made
them), no metering that charged nothing. The Billing page in the app offers no write action either,
so nothing the page can do is missing here.

## Authorization

Billing is for organization admins. Only admins can create API keys, so a key can read the same data an
admin can. The organization always comes from the key.

