Skip to content

Top up in one click when you run low

POST
/orgs/{org}/billing/low-balance
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).

org
required

The organisation id the session was issued for. A token for one organisation can never read another.

string
Example
org_9f3c

The organisation id the session was issued for. A token for one organisation can never read another.

Media typeapplication/json
object
enabled
boolean | null
threshold

A whole number of credits, 0 to 1,000,000.

integer | null
<= 1000000
packKey

A pack on sale, or null for the first on sale.

string | null
key
additional properties
Examplegenerated
{
"enabled": true,
"threshold": 1,
"packKey": "example"
}

The settings as they now stand.

Media typeapplication/json
object
enabled
required

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.

boolean
threshold
required

Tell them when the credits the organisation holds fall below this.

number
thresholdMost
required

The most a threshold may be: what a page bounds its box by.

number
packKey
required

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.

string | 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.

Media typeapplication/json
object
error
required
string
key
additional properties
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).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
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.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
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.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed value: MAINTENANCE
Example
{
"code": "MAINTENANCE"
}
Retry-After
integer

Seconds until asking again is worth it (300 while the switch is on).

Report a problem with this page

sloose.com