Errors
Errors
Corteksa uses standard HTTP status codes and a consistent JSON error shape, so you can handle failures the same way across every endpoint.
Error shape
{
"statusCode": 403,
"message": "You do not have permission to perform this action",
"error": "Forbidden"
}Validation errors return an array of messages:
{
"statusCode": 400,
"message": ["email must be an email", "name should not be empty"],
"error": "Bad Request"
}Status codes
| Code | Meaning | Common cause | Fix |
|---|---|---|---|
| 400 | Bad Request | Missing/invalid field, wrong enum, bad body | Check the message array; key record bodies by field slug |
| 401 | Unauthorized | Missing/expired token or API key | Re-authenticate; send Authorization: Bearer or X-Api-Key |
| 403 | Forbidden | Authenticated, but the role/key lacks the permission or scope | Grant the read.* / create.* scope or raise the access level |
| 404 | Not Found | Wrong slug — or a record outside your visibility (masked) | Verify the slug; check your access level |
| 409 | Conflict | Duplicate / concurrent write | Retry or resolve the duplicate |
| 422 | Unprocessable | Business-rule validation failed | Read message for the specific rule |
| 429 | Too Many Requests | Rate limit hit | Back off and retry with the standard backoff |
| 500 | Server Error | Unexpected fault (reported to Sentry) | Retry; if it persists, contact support |
Auth: 401 vs 403
- 401 = "I don't know who you are" — the credential is missing or invalid.
- 403 = "I know who you are, but you can't do this" — the permission/scope or
access level (
A > G > M > D) forbids it.
The 404 that's really a 403
Some resources (a chat or record outside your scope) are masked as 404 rather than 403, so you can't probe for things you can't see. If you're sure it exists, your access level is too low — see Authorization.
Handle errors well
- Parse
message(string or array) for a user-facing reason. - Retry
429and5xxwith exponential backoff; never retry4xxblindly. - Treat
401as "refresh and retry once", then send the user to log in.