Bill an org by invoice
const url = 'https://api.sloose.com/billing/admin/orgs/org_9f3c/invoice-billing';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"planKey":"team","interval":"month","daysUntilDue":1,"tax":"au_gst","poNumber":"example","reason":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.sloose.com/billing/admin/orgs/org_9f3c/invoice-billing \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "planKey": "team", "interval": "month", "daysUntilDue": 1, "tax": "au_gst", "poNumber": "example", "reason": "example" }'Backoffice route: a staff session, or ADMIN_TOKEN; never a customer’s session. Makes the org’s subscription billed by invoice (collection_method: send_invoice) on the plan and interval given, due daysUntilDue days after each invoice, with Australian GST at 10% on top (tax: au_gst) or no tax (none, a customer overseas). Dinode is the seller on these invoices: Stripe collects no tax, so the invoice charges only the tax chosen here. Every invoice names the seller (Dinode Pty Ltd, a custom field) and prints the account’s ABN, the bank details this deployment carries (INVOICE_PAYMENT_INSTRUCTIONS) and the PO number, if one is given; the first is issued, and so sent, at once. Its credits are granted as each invoice is issued, not when it is paid. Refused, as a Checkout is, while the org has a subscription — in its row or live at Stripe — and the org’s open plan Checkouts are closed first. Written down as org.invoice_billing with the reason.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The org id.
Example
org_9f3cThe org id.
Request Bodyrequired
Section titled “Request Bodyrequired”object
From 1 to 90; 30 when not given.
Responses
Section titled “Responses”The subscription made, and its first invoice.
object
The first invoice: open once issued and sent; a draft here could not be issued, and Stripe issues it once invoice.created has given it the bank details — held back while that fails, for up to three days. Check its status at Stripe.
object
Who sells on these invoices.
Examplegenerated
{ "subscriptionId": "example", "invoice": { "id": "example", "number": "example", "status": "example", "total": 1, "currency": "example", "hostedInvoiceUrl": "example" }, "seller": "example"}The request is not one this can make.
object
Examplegenerated
{ "error": "example"}A bearer that is neither the token nor a live session (code: AUTH_REQUIRED).
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}A customer’s session, an API token, or no bearer at all — not staff, and not the ADMIN_TOKEN (code: ADMIN_REQUIRED).
The error envelope every non-2xx answer uses.
object
Human-readable explanation.
Machine-readable reason. Absent on a few legacy 400s.
Examplegenerated
{ "error": "example", "code": "example"}No such org (ORG_NOT_FOUND).
object
Examplegenerated
{ "error": "example", "code": "example"}The org has a subscription already (ALREADY_SUBSCRIBED), it is closed (ORG_CLOSED: one closed while this was made has the subscription cancelled), or Stripe has no address to send invoices to (NO_BILLING_EMAIL).
object
Examplegenerated
{ "error": "example", "code": "example"}Stripe refused the request (PAYMENT_PROVIDER_REFUSED) — nothing was charged, though a step taken before the refusal stands: the org’s first Stripe customer, or an existing customer’s billing email brought up to date — or was unavailable (PAYMENT_PROVIDER_UNAVAILABLE: unreachable, failing or rate-limiting), which may or may not have gone through — check before retrying. Stripe’s own words are logged, not returned.
object
Example
{ "code": "PAYMENT_PROVIDER_REFUSED"}This deployment cannot issue it: no bank details (INVOICE_NOT_CONFIGURED), no price for the plan and interval (PRICE_NOT_CONFIGURED), no GST rate (TAX_RATE_NOT_CONFIGURED), no ABN (ABN_NOT_CONFIGURED), or no Stripe (STRIPE_NOT_CONFIGURED).
object
Examplegenerated
{ "error": "example", "code": "example"}