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. Written down as org.credits.
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
included credits reset each period; purchased ones carry over.
A positive number of credits to grant.
Idempotency key. Generated if omitted.
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, or credits is not positive.
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"}