GET /v2/merchant/billing/invoices returns the authenticated merchant’s billing
history for the trailing 365 days: per-invoice rows plus a totals envelope
(paid amount, platform fees retained, invoice count). This endpoint is the
data source for the merchant Billing History page in the dashboard.
This endpoint requires:
- Merchant JWT — any authenticated merchant role (
OWNER,MEMBER,PRODUCER)
sub claim. There is no
merchantId query parameter. If a client passes one anyway it is silently
ignored — the response is always scoped to the JWT-bound merchant.GET /v2/merchant/billing/invoices
Authentication
Obtain a merchant JWT via
POST /merchant/admin/login — see
Authentication. SUPER_ADMIN tokens work too (they are merchant
JWTs with an extra role); the response is scoped to the SUPER_ADMIN’s own
merchant record, not to the platform.
Query parameters
None. The window is fixed at trailing 365 days.Example
Response — 200 OK
Fields
Errors
Notes
- Trailing 365-day window.
windowStartis computed asnow − 365don every call. The window is rolling, not anchored — two calls a day apart return slightly differentwindowStart/windowEndvalues, and an invoice issued exactly 365d ago may drop out of one call’s window and back into the next. - Auth scope. The endpoint reads
merchantIdfrom the JWTsubclaim only. Any?merchantId=(or bodymerchantId) is silently ignored. A merchant cannot read another merchant’s invoices through this endpoint — even with a syntactically valid query parameter pointing at the target. - Fail-open semantics. If the underlying invoice store throws, the
endpoint returns the empty-state envelope (
invoices: [],totals.*: 0) with200 OKrather than propagating the error. Inspect server logs / Sentry for the underlying failure. Merchants never see a partial billing-history page error in the dashboard. - Currency. All monetary fields are USD major units (dollars), not
cents. Renders straight into
Intl.NumberFormat({ style: 'currency', currency: 'USD' })without dividing by 100. This contract diverges from the admin x402-earnings rollup (USD cents, integer) intentionally — merchant-facing endpoints serve pre-formatted human values; admin rollups serve aggregation-safe integer cents. - Only PAID invoices. Today the endpoint returns rows where
status === 'PAID'. Pending / void / refunded invoices are out of scope for v1 and tracked for a future revision.
Related
- x402 Earnings (Merchant) — companion merchant-facing rollup of x402 settlement events.
- Platform Fee Summary (Admin) — network-wide MRR / ARR / 30d / 365d rollup that aggregates the per-merchant billing surfaced here.
- x402 Earnings (Admin) — admin-side per-merchant x402 settlement rollup.