Mint an API token
const url = 'https://api.sloose.com/orgs/org_9f3c/tokens';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"CI — config push","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/orgs/org_9f3c/tokens \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "CI — config push", "expiresAt": "example" }'Creates a token scoped to this organisation with the admin role, acting as the member who created it — never above that member’s role at the time of each request, so an owner’s token is an admin. The secret is in the response and nowhere else, so store it when you receive it.
Session only. An organisation API token is refused here with 403 SESSION_REQUIRED: a token must not be able to mint or revoke tokens.
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
What the token is for. Shown in the token list.
Example
CI — config pushAn ISO date (midnight UTC) or an ISO timestamp with Z or an offset, kept in UTC. Omitted means the token never expires.
Responses
Section titled “Responses”Created. secret is not retrievable afterwards.
object
object
The token’s leading characters, for recognising it in a list.
Shown once. The server keeps only a hash of it.
Example
{ "secret": "slo_…"}The request — its body or its query — did not match the schema. issues carries the Zod issue list.
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"}You are no longer a member of this organisation.
object
Example
{ "code": "MEMBERSHIP_GONE"}An API token was used, the role is too low, the bearer belongs to another organisation, or the session is a staff member’s view of the organisation: a read-only one as on any write (IMPERSONATION_READ_ONLY), and a write-capable one too (IMPERSONATION_REFUSED), since a token would outlast the view, acting as the member. 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.
object
Example
{ "code": "SESSION_REQUIRED"}expiresAt is not in the future.
object
Example
{ "code": "EXPIRY_IN_PAST"}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).