Top up in one click when you run low
const url = 'https://api.sloose.com/orgs/org_9f3c/billing/low-balance';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"enabled":true,"threshold":1,"packKey":"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/orgs/org_9f3c/billing/low-balance \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "enabled": true, "threshold": 1, "packKey": "example" }'Whether, and when, the organisation’s owner and administrators are told its AI credits are running low: a credits_low notice on Usage & credits and in the banner, and its mail, once per shortfall, with the pack one click away. What is short is what the organisation holds — its included and purchased credits, whatever calls in flight have reserved. Nothing is charged by it: Stripe sells every pack, and a buyer who saved a card with an earlier pack is offered it again by the pack’s Checkout, so they pay with one press. The notice ends when a grant (a pack, a period’s credits, staff’s) or this setting leaves the organisation holding the threshold or more, or when this is turned off.
Session only: billing is a person’s to manage, never an organisation’s API token’s (D5).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The organisation id the session was issued for. A token for one organisation can never read another.
Example
org_9f3cThe organisation id the session was issued for. A token for one organisation can never read another.
Request Bodyrequired
Section titled “Request Bodyrequired”object
A whole number of credits, 0 to 1,000,000.
A pack on sale, or null for the first on sale.
Examplegenerated
{ "enabled": true, "threshold": 1, "packKey": "example"}Responses
Section titled “Responses”The settings as they now stand.
object
Whether the owner and administrators are told — a credits_low notice and its mail — when the credits the organisation holds (included and purchased) fall below threshold. Nothing is ever charged by it: the notice links to the pack, whose Checkout offers again a card a buyer chose to save with an earlier pack.
Tell them when the credits the organisation holds fall below this.
The most a threshold may be: what a page bounds its box by.
The pack the notice offers; null is the smallest on sale — and so is a pack chosen before that is no longer on sale, which reads as null.
Examplegenerated
{ "enabled": true, "threshold": 1, "thresholdMost": 1, "packKey": "example"}A threshold that is not a whole number of credits from 0 to 1,000,000, or a pack not on sale.
object
Examplegenerated
{ "error": "example"}No bearer, or one that no longer resolves: a session that is unknown or expired (code: AUTH_REQUIRED), or an API token that was revoked or expired (TOKEN_REVOKED, TOKEN_EXPIRED), whose organisation is gone (ORG_NOT_FOUND) or whose member or user row is (MEMBERSHIP_GONE).
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"}The bearer’s role is too low, it was issued for a different organisation, it is an API token (SESSION_REQUIRED), or it is a staff member’s view of the organisation (IMPERSONATION_REFUSED; a read-only view is refused before this, IMPERSONATION_READ_ONLY). Like every route behind a session: a session signed in but in no organisation is refused code: NO_ORG, a banned person code: BANNED, and a closed organisation code: ORG_CLOSED.
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"}The restore switch is on (code: MAINTENANCE): every route but /health and /robots.txt is refused before anything is read, except the operator’s own POST /staff/people/{id}/delete with the ADMIN_TOKEN. Sloose is down for maintenance. Please try again in a few minutes.
object
Example
{ "code": "MAINTENANCE"}Headers
Section titled “Headers”Seconds until asking again is worth it (300 while the switch is on).