Billing
Plans, subscriptions, usage, budgets, quotas and invoices.
Every path is under /api/v1; see the API for authenticating, errors and rate
limits, and the schemas for the bodies.
Resource usage of the organization's runs in a month (billing:manage)
GET /api/v1/orgs/{org}/usage
Runs that reached a runner and finished in the month (UTC), per project and runner kind
(shared: the platform's runners, own: the organization's or a project's). run_seconds
counts from the process start to its end, occupied_seconds from placement on the runner
(pull, start and artifact uploads included). CPU and memory are what the runs reserved,
over their run time. Lines are per project, runner kind and class. credit compares the
month's price with the usage credit of the organization's current plan.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
month |
query | string: YYYY-MM; the current month by default. |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
credit |
object, required | In micro-euros. |
from |
string (date-time), required | |
lines |
array of any, required | |
month |
string, required | |
to |
string (date-time), required | |
total |
UsageTotals, required |
Errors: 400, 403, 404 (how errors look).
The organization's budget and its projects' (billing:manage)
GET /api/v1/orgs/{org}/budgets
Projects without a budget (or with an empty one) are left out.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
closed_schedules |
array of ClosedSchedule, required | Schedules the caller may read with a fire in the coming week on a day the organization's budget closes. |
organization |
BudgetView, required | |
projects |
array of any, required |
Errors: 403, 404 (how errors look).
Replace the organization's budget (billing:manage, audited as org.budget)
PUT /api/v1/orgs/{org}/budget
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): Budget.
Answers:
200: OK, BudgetView
Errors: 400, 403, 404, 422 (how errors look).
The organization's quotas and what it uses of them (org:read or platform:billing)
GET /api/v1/orgs/{org}/quotas
Creating a project, runner join token, runner or run over a count answers 409
quota_exceeded. Runs over a shared-runner cap don't go to shared runners.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, Quotas
Errors: 404 (how errors look).
Override the organization's quotas (platform:billing)
PUT /api/v1/orgs/{org}/quotas
Replaces all overrides; null keeps the platform default.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): QuotaOverrides.
Answers:
200: OK, Quotas
Errors: 400, 403, 404, 422 (how errors look).
The organization's plan (org:read)
GET /api/v1/orgs/{org}/subscription
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, Subscription
Errors: 404 (how errors look).
Switch the organization's plan (billing:manage)
PUT /api/v1/orgs/{org}/subscription
Decision 130. A more expensive plan applies at once and issues an invoice for the price
difference over the month's remaining days, charged right away; one at the same price
applies at once; a cheaper one is scheduled for the 1st (pending). Choosing the current
plan again cancels a scheduled change. A paid plan needs billing details and a payment
method (409 no_payment_method); hidden plans are 404.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
plan_id |
ID, required |
Answers:
200: OK, SubscriptionChange
Errors: 400, 403, 404, 409 (how errors look).
The organization's billing details and payment method (billing:manage)
GET /api/v1/orgs/{org}/billing
404 billing_disabled when the installation has no payment provider.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, BillingAccount
Errors: 403, 404 (how errors look).
Save the billing details and send them to the payment provider (billing:manage)
PUT /api/v1/orgs/{org}/billing
422 invalid_details names the wrong field in its message. 502 provider_failed when the
provider didn't answer: the details are saved, and saving again retries.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Body (application/json): BillingDetails.
Answers:
200: OK, BillingAccount
Errors: 400, 403, 404, 422, 502 (how errors look).
The payment provider's page for adding a payment method (billing:manage)
POST /api/v1/orgs/{org}/billing/payment-method
Send the browser to url; it comes back to the organization's billing page, and the
method shows once the provider's webhook arrived. 409 no_billing_details before the
details are saved.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
url |
string, required |
Errors: 403, 404, 409, 502 (how errors look).
The next monthly invoice as it stands now (billing:manage)
GET /api/v1/orgs/{org}/billing/upcoming
Decision 131: next month's plan fee (of a scheduled plan, if any) and this month's extra minutes so far, before tax. Empty lines when nothing would be owed.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
lines |
array of InvoiceLine, required | |
period |
string, required | The month (YYYY-MM) it will be issued for. |
subtotal_cents |
integer (int64), required |
Errors: 403, 404 (how errors look).
The organization's invoices, newest first (billing:manage)
GET /api/v1/orgs/{org}/invoices
Issued in advance on the 1st of each month: the month's plan fee and the previous month's overage; months without anything owed have none. Without lines.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
invoices |
array of Invoice, required | |
payment_due |
object, required | Invoices whose charge failed or that have no payment method to charge, or null. Unpaid 7 days after issue, the organization is suspended until they are paid. |
Errors: 403, 404 (how errors look).
An invoice with its lines (billing:manage)
GET /api/v1/orgs/{org}/invoices/{invoice}
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
invoice |
path | ID |
Answers:
200: OK, Invoice
Errors: 403, 404 (how errors look).
Download an invoice's PDF (billing:manage)
GET /api/v1/orgs/{org}/invoices/{invoice}/pdf
409 not_ready until the PDF is rendered, shortly after the invoice is issued.
| Parameter | In | Description |
|---|---|---|
org |
path | ID |
invoice |
path | ID |
Answers:
200: The PDF, as an attachment named by the invoice number., string (binary)
Errors: 403, 404, 409 (how errors look).
The dummy payment provider's setup page (development only; the token is the session)
GET /api/v1/billing/dummy/{token} (no sign-in needed)
| Parameter | In | Description |
|---|---|---|
token |
path | string |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
expires_at |
string (date-time), required | |
name |
string, required | The customer's legal name. |
Errors: 404 (how errors look).
Add the dummy's test card, or decline, and go back
POST /api/v1/billing/dummy/{token} (no sign-in needed)
| Parameter | In | Description |
|---|---|---|
token |
path | string |
Body (application/json): object.
| Field | Type | Description |
|---|---|---|
decline |
boolean | |
failing |
boolean | Add a card whose charges fail. |
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
return_url |
string, required |
Errors: 400, 404 (how errors look).
The offered plans (platform admins see hidden ones too)
GET /api/v1/plans
Answers:
200: OK, object with the fields below
| Field | Type | Description |
|---|---|---|
plans |
array of Plan, required |
The project's budget and what it spent (project:read)
GET /api/v1/projects/{project}/budget
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Answers:
200: OK, BudgetView
Errors: 404 (how errors look).
Replace the project's budget (billing:manage on its organization, audited as project.budget)
PUT /api/v1/projects/{project}/budget
It may be higher than the organization's; the lower one stops first.
| Parameter | In | Description |
|---|---|---|
project |
path | ID |
Body (application/json): Budget.
Answers:
200: OK, BudgetView
Errors: 400, 403, 404, 422 (how errors look).