Billing API¶
Inspect your subscription and the plans available to you, and (when Stripe is configured) start a Stripe Checkout or Customer Portal session.
Subscription and plan data are read from InvoicePDFs' own database, so those endpoints always work. The checkout and portal endpoints require Stripe to be configured on the server; when it is not, they return 501 Not Implemented with error code not_configured.
Get Subscription¶
Returns the current subscription status straight from the database — no Stripe API call is made, so this works whether or not Stripe is configured.
Response:
{
"data": {
"subscription_id": "sub_123",
"status": "active",
"plan_id": "plan_free",
"plan_name": "Free",
"stripe_configured": false,
"has_billing_account": false
}
}
| Field | Description |
|---|---|
subscription_id |
Stripe subscription ID, or null if none |
status |
Subscription status, or null if none |
plan_id |
ID of the account's current plan |
plan_name |
Display name of the current plan |
stripe_configured |
Whether Stripe billing is configured on the server |
has_billing_account |
Whether a Stripe customer exists for this account |
Try it
List Plans¶
Lists purchasable plans — those wired to a Stripe price. Read from the database.
Response:
{
"data": [
{
"id": "plan_pro",
"name": "Pro",
"price_id": "price_123",
"monthly_render_quota": 1000
}
]
}
| Field | Description |
|---|---|
id |
Plan ID |
name |
Plan display name |
price_id |
Stripe price ID used when starting checkout |
monthly_render_quota |
Number of PDF renders included per month |
Try it
Create Checkout Session¶
Creates a Stripe Checkout session for a subscription. A Stripe customer is lazily created for the account if one does not already exist.
Request:
| Field | Required | Description |
|---|---|---|
price_id |
Yes | Stripe price ID for the plan to subscribe to |
Response:
Redirect the user to url to complete payment.
Note
Requires Stripe to be configured on the server. If it is not, this endpoint returns 501 Not Implemented with error code not_configured.
Try it
Create Portal Session¶
Creates a Stripe Customer Portal session for self-service subscription management (updating payment methods, canceling, viewing invoices).
Response:
Redirect the user to url to manage their subscription.
Note
Requires Stripe to be configured on the server; otherwise this endpoint returns 501 Not Implemented with error code not_configured. If no billing account exists for the account yet, it returns 400 Bad Request with error code bad_request — subscribe first.