Response Envelope
Every endpoint in a Kirak application—whether generated CRUD routes, GraphQL, /auth/*, /storage/*, or custom modules—returns a standardized, predictable response envelope.
Single Source of Truth: The HTTP status line always equals the
statusCodeinteger in the JSON body. Client SDKs and frontend consumers can trust either one.
Success Envelope
Section titled “Success Envelope”{ "statusCode": 200, "status": "success", "message": "Records fetched successfully", "data": [ { "id": 1, "title": "First Post" }, { "id": 2, "title": "Second Post" } ], "pagination": { "limit": 20, "page": 1, "offset": 0, "total": 156, "total_pages": 8, "has_more": true }}Field Specifications:
Section titled “Field Specifications:”statusCode(integer): HTTP status code (always 200 for successful operations; Kirak does not use 201 or 204).status(string): Always"success".message(string): Human-readable confirmation string (e.g."tasks created successfully").data(object|array|null): The payload payload. On single-record reads or writes, this is an object (e.g.{"id": 42}); on queries, an array of records.pagination(object|null): Present on read operations. If the caller did not passpageoroffset, or for non-read operations,paginationisnull.
Error Envelope
Section titled “Error Envelope”{ "statusCode": 403, "status": "error", "error": "PERMISSION_DENIED", "message": "Role 'user' is not authorized to destroy 'posts'", "data": null, "details": null}Field Specifications:
Section titled “Field Specifications:”statusCode(integer): 4xx or 5xx status code matching the HTTP response header.status(string): Always"error".error(string): A stable machine code (e.g.PERMISSION_DENIED,VALIDATION_ERROR,NOT_FOUND). Frontend applications should branch logic on this string, not onmessage.message(string): Descriptive human-readable explanation of the error.data(null): Alwaysnullon errors.details(object|null): Optional structured context (such as input validation errors or MFA tokens).
Structured Validation Errors
Section titled “Structured Validation Errors”When a request fails schema or type validation, Kirak returns 400 VALIDATION_ERROR with a granular list of failing fields in details.fields:
{ "statusCode": 400, "status": "error", "error": "VALIDATION_ERROR", "message": "Request validation failed: 2 invalid fields", "data": null, "details": { "fields": [ { "field": "title", "code": "missing", "message": "Field required" }, { "field": "email", "code": "value_error", "message": "Input should be a valid email address" } ] }}field: Column or property path (uses dotted notation for nested objects or arrays, e.g.address.cityoritems.0.sku).code: Stable validator code (e.g.missing,string_type,enum,max_length).
Machine Codes Reference
Section titled “Machine Codes Reference”Every error code Kirak and its modules answer with, its status and what it means:
error |
Status | From | Meaning |
|---|---|---|---|
VALIDATION_ERROR |
400 | core | The request, a field value or a GraphQL query is invalid, including a duplicate of a unique field. A route that refuses a well-formed body it cannot process answers 422 with this code (e.g. /monitoring/alerts/evaluate, /scheduler/*). A request body that fails validation lists every invalid field (at most 20) in details.fields, each with field, code and message; so do a module operation’s params that break its spec (missing, wrong type, not allowed, or a key the operation does not take). |
INVALID_JSON |
400 | core | The request body is not valid JSON. |
AUTHENTICATION_ERROR |
401 | core | A credential is required or was rejected. |
PERMISSION_DENIED |
403 | core | The caller’s role may not do this, or not on these records or fields. |
DATABASE_READ_ONLY |
403 | core | The database is read-only (PostgreSQL, set by the host when its storage quota is used): writes and logins are refused, reads still work. |
DATABASE_WRITE_DENIED |
403 | core | The database refused a write: the app’s role may not write (PostgreSQL, a host revokes it to make the app read-only). Reads still work. |
NOT_FOUND |
404 | core | No such route, model or record, or a valid token’s user no longer exists. |
PAYLOAD_TOO_LARGE |
413 | core | The request body is over the limit: kirak.json max_body_mb (default 10 MB), or on a storage upload route its image_max_size / file_max_size plus 1 MB. The message names the limit in bytes. |
RATE_LIMIT_EXCEEDED |
429 | core | Too many requests; retry after the Retry-After header’s seconds. |
LISTING_NOT_SUPPORTED |
501 | core | The admin API cannot list the rate-limit counters here (a Redis that refuses SCAN, as one shared by several apps may). Get or reset one counter by its key instead. |
DATABASE_ERROR |
500 | core | The database operation failed; the details are logged, not returned. |
INTERNAL_ERROR |
500 | core | An unexpected server error. |
SERVICE_UNAVAILABLE |
503 | core | A backing service (Redis) could not be reached; retry later. |
HTTP_ERROR |
varies | core | Any other HTTP error; see statusCode. |
MISSING_TOKEN |
401 | auth | The route needs a credential and none was sent. |
INVALID_TOKEN |
401 | auth | The access or refresh token is malformed or not valid. |
TOKEN_EXPIRED |
401 | auth | The token has expired: refresh an access token, sign in again for a refresh token. |
TOKEN_REVOKED |
401 | auth | The refresh token was revoked (logout, password change or reset, or a reused rotated token ended its session); sign in again. With Redis, an access token issued before a logout of all sessions, a password change or reset, a role change or a deactivation is refused with this code too (auth.access_token_expire_minutes bounds the window without it). |
AUTH_UNAVAILABLE |
503 | auth | A used one-time sign-in code or nonce could not be recorded, an MFA code could not be counted, an access token’s revocation could not be checked or recorded (database or Redis unreachable), an auth route’s rate limit could not be counted (database and Redis both unreachable), or the provider’s signing keys could not be fetched, so the request was not accepted; retry. |
INVALID_API_KEY |
401 | auth | The API key is unknown, revoked or expired. |
ENCRYPTION_KEY_UNKNOWN |
500 | auth | A stored secret (MFA or social sign-in data) cannot be decrypted, usually because the encryption key changed; the operator must restore the key. |
INVALID_CREDENTIALS |
401 | auth | Wrong email or password, or a wrong current password on change-password. |
INVALID_OTP |
401 | auth | The one-time code is wrong or expired. |
INVALID_MFA_CODE |
401 | auth | The MFA or backup code is wrong, or was already used. |
MFA_LOCKED |
401 | auth | 5 MFA codes without a correct one for this user in 15 minutes; the code was not checked; retry after 15 minutes. |
SOCIAL_AUTH_FAILED |
401 | auth | The social provider sign-in did not complete. |
MOBILE_SIGN_IN_NOT_SUPPORTED |
400 | auth | The provider’s native sign-in gives nothing Kirak can check was issued to this app (OAuth 1, SAML, …), or an access token was sent to a provider other than facebook, or a code_verifier was sent for a provider that does not do PKCE; use the web flow with redirect_to, or send id_token / code. |
NONCE_REQUIRED |
401 | auth | auth.social. |
NONCE_MISMATCH |
401 | auth | The nonce does not match the ID token’s nonce claim, or the token has a nonce and none was sent. |
NONCE_REUSED |
401 | auth | This ID token and nonce already signed in once; sign in again. |
INVALID_REDIRECT |
400 | auth | redirect_to is not in auth.redirect_urls, or the PKCE code_challenge is missing, malformed or not S256. |
INVALID_GRANT |
400 | auth | The sign-in code is unknown, expired, already used, or the code_verifier or redirect_to does not match; sign in again. |
SOCIAL_PROVIDER_ERROR |
502 | auth | A social sign-in failed because the provider could not be reached or failed on its side: at /login (OAuth 1 and OpenID 2 providers call the provider there) or when the code is exchanged at the callback or the mobile route. |
SOCIAL_AUTH_CANCELLED |
401 | auth | The user cancelled at the provider; sent to redirect_to as error=SOCIAL_AUTH_CANCELLED. |
SOCIAL_EMAIL_MISSING |
401 | auth | The provider sent no email address (the user did not allow access to it, or the provider has none), so the sign-in cannot find or create an account. For a provider that has no email to send, auth.social. |
SOCIAL_EMAIL_NOT_VERIFIED |
409 | auth | An account has the email of this social sign-in but its own email is not verified, so the sign-in is not linked to it. |
SOCIAL_EMAIL_PRIVATE |
403 | auth | A first GitHub sign-in whose email is private, and auth.social.github.require_public_email is on. The message tells the user to make the email public on GitHub and sign in again. |
MFA_REQUIRED |
403 | auth | The account has MFA and no tokens were issued: send details.mfa_token with an MFA code to mfa_challenge (a password login may instead repeat with mfa_code). From setup_mfa: send code to add another authenticator. |
INVALID_MFA_TOKEN |
401 | auth | mfa_challenge: the mfa_token is invalid, expired (5 minutes) or already used; sign in again. |
MFA_METHOD_LIMIT |
409 | auth | setup_mfa: the user has 5 authenticators already; remove one first. |
ACCOUNT_INACTIVE |
403 | auth | The account is deactivated. |
ACCOUNT_CLOSED |
403 | auth | The account was closed; it cannot sign in. Its data is deleted when auth.account_close_window is over. When its user closed it and auth.account_reopen is on, a sign-in that passed every check carries details.reopen_token, closed_at and purge_at: send the token to reopen_account. |
INVALID_REOPEN_TOKEN |
401 | auth | reopen_account: the reopen token is invalid, expired or used, or the account can no longer be reopened; sign in again. |
ACCOUNT_ALREADY_CLOSED |
409 | auth | close_account: the account is closed already. |
ACCOUNT_NOT_CLOSED |
409 | auth | restore_account: the account is not closed. |
ACCOUNT_PURGE_STARTED |
409 | auth | restore_account: the account’s window is over and its data is being deleted. |
REAUTH_REQUIRED |
401 | auth | close_account for an account without a password: sign in again and close within 5 minutes. |
ACTIVE_SUBSCRIPTION |
409 | auth | close_account: a subscription can still bill the user; cancel it first (details.subscription_ids). |
ACTIVE_MERCHANT_ACCOUNT |
409 | auth | close_account: the user has a merchant account; settle and remove it first. |
EMAIL_NOT_VERIFIED |
403 | auth | The email address must be verified before signing in. Also a first social sign-in whose email the provider did not confirm as verified, when auth.social. |
WEAK_PASSWORD |
400 | auth | The new password does not meet the password rules; message says which. |
INVALID_RESET_TOKEN |
400 | auth | The password reset link is invalid or already used. |
INVALID_VERIFICATION_TOKEN |
400 | auth | The email verification link is invalid or expired, or its account or address no longer exists. |
EMAIL_ALREADY_VERIFIED |
409 | auth | The email address of the verification link is already verified. |
EMAIL_ALREADY_EXISTS |
409 | auth | An account with this email exists. |
REGISTRATION_CLOSED |
403 | auth | auth.registration is closed: register, a first phone-code sign-in and a first social sign-in create no account. |
PHONE_IN_USE |
409 | auth | Another account has this phone number, so it cannot be added to this one. |
KEY_ROTATION_UNAVAILABLE |
409 | auth | rotate_keys: this process runs only per request and the scheduler module is off, so a rotation cannot run in the background; enable the scheduler. |
USER_DATA_ERROR |
500 | auth | The signed-in user’s record could not be read. |
INTEGRATION_UNKNOWN |
404 | integrations | No integration with this name is configured in kirak.json. |
INTEGRATION_NOT_OAUTH |
400 | integrations | The integration is an api_key one, which has no connect flow. |
INTEGRATION_STATE_INVALID |
400 | integrations | The connect link or the provider’s state is invalid, expired, already used, or does not belong to this browser. Start the connection again. |
INTEGRATION_CANCELLED |
400 | integrations | The user refused at the provider, or the provider sent no code. Sent as the error parameter of the return_to redirect. |
INTEGRATION_CONNECT_INVALID |
400 | integrations | A connect value is missing, not declared by the profile, or does not match its pattern. |
INTEGRATION_CONNECTION_LIMIT |
409 | integrations | The app’s limit on connections to this service is reached. |
INTEGRATION_CONNECTION_NOT_FOUND |
404 | integrations | No connection with this id belongs to the user. |
INTEGRATION_PROVIDER_ERROR |
400 | integrations | The provider refused the request, or its answer lacked a value Kirak needs. |
INTEGRATION_PROVIDER_UNAVAILABLE |
502 | integrations | The provider did not answer in time, answered with an error, or its answer cannot be read. The outcome is unknown; try again. |
INTEGRATION_RATE_LIMITED |
429 | integrations | Too many requests for this operation. Wait a minute. |
INTEGRATION_NOT_CONNECTED |
409 | integrations | The user has no connection to this integration. Start a connect. |
INTEGRATION_NEEDS_REAUTH |
409 | integrations | The connection must be made again: the provider no longer accepts its grant. Start a new connect. |
INTEGRATION_CONNECTION_REQUIRED |
400 | integrations | The user has several connections to this integration; pass the connection_id. |
INTEGRATION_USER_REQUIRED |
400 | integrations | The call needs a user: pass user_id, or call as a signed-in user. |
INTEGRATION_PATH_INVALID |
400 | integrations | The path is not a path on the integration’s API (it must start with / and must not hold a scheme, a host or ‘..’). |
INTEGRATION_RESPONSE_TOO_LARGE |
413 | integrations | The provider’s response is larger than 64 KB. |
INTEGRATION_WEBHOOKS_NOT_SUPPORTED |
404 | integrations | The integration’s profile declares no webhooks. |
INTEGRATION_WEBHOOK_BODY_INVALID |
400 | integrations | The webhook body is not JSON. |
INTEGRATION_WEBHOOK_HANDLER_FAILED |
500 | integrations | A webhook handler raised; the provider may send the event again. |
INTEGRATION_SITE_NOT_FOUND |
404 | integrations | The site is not one of the connection’s sites. |
INTEGRATION_CONNECTION_BUSY |
409 | integrations | The connection changed while it was being updated (a refresh). Try again. |
INTEGRATION_APP_GRANT |
400 | integrations | The integration uses the client_credentials grant: users do not connect to it. |
INTEGRATION_APP_TOKEN_REFUSED |
502 | integrations | The provider refused the app’s client credentials grant. |
INTEGRATION_KEY_INVALID |
422 | integrations | The provider does not accept the key, or the key or its label is not in the form Kirak takes. |
INTEGRATION_NOT_USER_KEY |
400 | integrations | Users do not save a key for this instance: it is an oauth2 integration (connect it instead), or an api_key one whose key belongs to the app. |
INTEGRATION_PROXY_NOT_ALLOWED |
403 | integrations | The instance uses the app’s own key (key_owner app), which the proxy routes do not expose. Call it with client() in a route of the app’s own. |
INTEGRATION_HOST_NOT_ALLOWED |
500 | integrations | A call would go to a host that is not the instance’s base_url or allowed_hosts. Refused before anything is sent. |
MONITORING_NO_STORE |
501 | monitoring | The app keeps no monitoring records to read: monitoring.sinks has no sqlite (stdout only). Every read endpoint answers this; /ping and /health still work. Not temporary, so do not retry. |
STORAGE_ERROR |
varies | storage | The storage provider failed to upload, delete, sign a URL for or list files: 502 when it is down or refuses Kirak’s credentials, 400 when it refused the request, 500 otherwise (details.kind). |