Fail on purpose
const url = 'https://api.sloose.com/billing/admin/failure-test';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"kind":"a"}'};
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/billing/admin/failure-test \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "kind": "a" }'Operator route: the shared ADMIN_TOKEN alone, never a person’s session, staff included. Throws an error no route handles, to prove that a deployment’s failures reach a person: the API logs [api] unhandled FailureTest (or FailureTestB, FailureTestC), answers 500, and mails staff, and Cloudflare’s Workers Observability records the failure as an issue, which is what the account’s failure alert is fed by. The body is optional: {"kind": "a" | "b" | "c"} from a closed list (default a), never a caller’s text; each kind is a different error name and so, to Cloudflare, a different issue. It writes one row: the claim that the day’s staff mail for this error’s name is spent. What the 500 does not say: the staff mail is sent after the answer and at most once in the 24 hours from the first call of a kind on an environment — whether or not that mail reached anybody — so a second call of a kind inside them proves Cloudflare’s half only and no mail arrives; and a kind whose issue exists opens no new issue, resolved or not; Cloudflare mails through an issue automation (a new issue at threshold 1, a count crossing, or a return after a quiet period), never through the notification policy alone. Each kind is spent once it has made its issue, and all three are on staging (a also on production). A body is now read, where the route once ignored any: no body and {} still throw FailureTest as before (and a ?kind= in the query is ignored); {"kind": null} is a kind that is not on the list and is 400; a JSON body that is junk or empty under a JSON content type is 400, and a body of any other content type (text/plain, a form, none declared) is 415.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
a (default): FailureTest. b: FailureTestB. c: FailureTestC. Each has a name and a message of its own and opens its own issue the first time on an environment; all three are spent on staging and a on production, so a request of a spent kind opens no new issue.
Responses
Section titled “Responses”A body that is not JSON of this shape, or a kind that is not a, b or c (code: INVALID_BODY): nothing is thrown, nothing is claimed and nobody is mailed.
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 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"}Not the ADMIN_TOKEN (code: ADMIN_REQUIRED): no bearer, a customer’s session, an API token, or a staff member’s session, which opens the rest of the backoffice and not this. A staff session that has passed no second factor recently is refused before that, as on every backoffice route (code: SECOND_FACTOR_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 body that is not JSON (text/plain, a form, or no content type declared): nothing is thrown, claimed or mailed. A request with no body at all is not one.
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"}Always, for the ADMIN_TOKEN and a kind from the list: the failure asked for, answered as every unhandled error is.
object
Example
{ "error": "internal error"}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).