Grant AI credits
const url = 'https://api.sloose.com/entitlements/admin/orgs/org_9f3c/credits';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"pool":"included","credits":1,"ref":"example","reason":"example","expiresAt":"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/entitlements/admin/orgs/org_9f3c/credits \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "pool": "included", "credits": 1, "ref": "example", "reason": "example", "expiresAt": "example" }'Backoffice route: a staff session, or ADMIN_TOKEN; never a customer’s session. Idempotent on ref: granting twice with the same ref grants once. The same ref sent with another pool, credits or reason, or with an expiresAt other than the one it was granted with, is refused (409 REF_REUSED) rather than answered as the grant already made: a key names one grant, and a retry that changed what it asks for is not that grant. Written down as org.credits.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The organisation id.
Example
org_9f3cThe organisation id.
Request Bodyrequired
Section titled “Request Bodyrequired”object
included credits reset each period; purchased ones carry over.
A positive number of credits to grant.
Idempotency key. Generated if omitted.
An ISO date (midnight UTC) or an ISO timestamp with Z or an offset, kept in UTC. Omitted or empty is the pool’s own: the period’s end for included, twelve months for purchased.
Responses
Section titled “Responses”Granted.
object
AI credits. Included credits reset each period; purchased ones do not.
object
Included + purchased − reserved
Examplegenerated
{ "ref": "example", "balance": { "included": 1, "purchased": 1, "reserved": 1, "available": 1, "periodStart": "example", "periodEnd": "example" }}pool is not one of the two pools, credits is not positive, or expiresAt is not an ISO date or timestamp.
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"}ref was granted already, with another pool, number of credits or reason, or an expiry other than the one sent now. Nothing is granted, and nothing written down.
object
Example
{ "code": "REF_REUSED"}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).