billing origin).
The Billing API uses its own base URL, separate from the Core API. In the examples in this
section the base is
https://billing-api.sandbox.z2pay.com. Authentication is the same as the
rest of the platform: the x-api-key header with your sandbox key. See
Authentication and Environments.The model: Plan → Price → Subscription → Invoice
Recurring billing is built on four chained resources. Understanding this chain is the first step to integrating.Plan
The catalog of the recurring offer: name, code, and the components it is made of. Starts in
draft, is published (active), and can be archived (archived).Price
A price version of a plan component: defines
unitAmount (in cents), currency, and the
recurrence (how often it charges). Versioned — creating a new Price deactivates the previous
one for the same currency/recurrence.Subscription
Links a customer to a plan (or to standalone items). It is the live contract: it has a
status, a default payment method, the next invoice date, and cycles.
Invoice
The billing document for one cycle. It is born from a subscription, charged via the PSP,
and transitions between
open, paid, past_due, etc.You do not need to create a Plan to have a subscription. It is possible to create a
subscription with standalone items (inline), providing
description and unitAmount directly
— in that case recurrence and currency become required in the subscription body. The Plan
path is recommended when you sell the same offer to many customers.How cycles work
Once the subscription exists, the Billing scheduler takes care of the rest. Each cycle it generates the next invoice, triggers the charge via the PSP, and updates the subscription status based on the result.Creation
You create the subscription (
POST /subscriptions). If a defaultPaymentMethodRef is provided,
it is ready to charge from the start; without a payment method, it is created as incomplete.Invoice generation
By default (
invoiceGenerationMode=just_in_time) the scheduler generates one invoice per
cycle. In upfront mode, all maxCycles invoices are issued at creation time (each with its
own due date).Charging
With
collectionMethod=charge_automatically (default), Billing charges the default payment
method. Each charge becomes a PSP transaction with origin=billing. With send_invoice,
the invoice is only issued for the customer to pay manually.Main endpoints
A consolidated view of the Billing resources. Each group has its own reference page with complete body fields and examples. All routes require thex-api-key header.
Plans and Prices
| Method | Route | Description |
|---|---|---|
POST | /plans | Creates a plan (initial status draft). |
GET | /plans | Lists plans (paginated, with filters). |
GET | /plans/:id | Retrieves a plan’s details. |
PATCH | /plans/:id | Updates plan fields. |
POST | /plans/:id/publish | Publishes the plan (draft → active). |
POST | /plans/:id/archive | Archives the plan. |
GET | /plans/:id/template | Returns the plan and its components with the current Price for each. |
GET | /plans/:id/items | Lists the plan’s components. |
POST | /plans/:id/items | Adds a component to the plan. |
PATCH | /plans/:id/items/:itemId | Updates a component. |
DELETE | /plans/:id/items/:itemId | Archives a component. |
GET | /plans/:id/prices | Lists the plan’s Price versions. |
POST | /plans/:id/prices | Creates a new Price version. |
POST | /plans/:id/prices/:priceId/archive | Archives a Price version. |
POST | /plans/:id/charges | Creates a component and its initial Price atomically. |
Subscriptions
| Method | Route | Description |
|---|---|---|
POST | /subscriptions | Creates a subscription. |
GET | /subscriptions | Lists subscriptions (paginated, with filters). |
GET | /subscriptions/:id | Retrieves a subscription’s details. |
GET | /subscriptions/:id/items | Lists the subscription’s active items. |
POST | /subscriptions/:id/cancel | Cancels (immediately or at end of cycle). |
POST | /subscriptions/:id/uncancel | Undoes a scheduled cancellation. |
POST | /subscriptions/:id/pause | Pauses the subscription. |
POST | /subscriptions/:id/resume | Resumes a paused subscription. |
Invoices
| Method | Route | Description |
|---|---|---|
GET | /invoices | Lists invoices (paginated, with filters). |
GET | /invoices/:id | Retrieves an invoice’s details. |
GET | /invoices/:id/line-items | Lists the invoice’s line items. |
The creation and action endpoints (
POST .../publish, POST .../cancel, POST .../pause,
etc.) accept the optional Idempotency-Key header. Resending the same request with the same key
returns the same result without duplicating the operation. See Conventions.First call (sandbox)
A quickGET to confirm that your sandbox key can reach the Billing API and to list existing
subscriptions (the list will be empty if you have not created any yet).
Errors
The Billing endpoints follow the same error pattern as the rest of the platform. Common statuses in this section:404— resource not found (subscription, plan, price, or customer does not exist).409— operation invalid for the current state (e.g., cancelling an already-cancelled subscription, pausing anupfrontsubscription, or a validation conflict on creation).400— invalid body (e.g., required fields missing or a forbidden combination of fields).
See also
Plans and Prices
Build the catalog for your recurring offer.
Subscriptions
Create, cancel, pause, and resume contracts.
Invoices
Query the charges generated each cycle.
Cycles and billing
Understand invoice generation, charging, and cycle advancement.
Customers
A subscription always points to a customer.
Webhooks
Receive notifications for paid invoices, charge failures, and status changes.

