Errors
Failed requests return JSON with an error string and an appropriate HTTP status. There is no single global error type enum across all routes.
Status codes
- 400 — Invalid input, malformed JSON, or business validation failure
- 401 — Missing or invalid authentication, or no org/branch scope
- 403 — Authenticated but not allowed for this action
- 404 — Resource not found
- 409 — Conflict (for example duplicate patient IC)
- 500 — Unexpected server error
Error body
{
"error": "Unauthorized"
}
Validation errors use the same shape, for example:
{
"error": "patientName is required"
}
Extended errors
Some routes add fields when useful. Patient create in centralized mode may return:
{
"error": "A patient with this IC already exists",
"code": "IDC_EXISTS",
"existingPatientId": "uuid",
"existingPatientName": "Ahmad bin Ali"
}
with status 409.
Analytics ingest may include Zod details on 400. Partner webhooks (Outside Cleos) sometimes return a status and message pair instead of error.
What to do
- Read the
errormessage and fix the request. - Confirm 401 issues with
GET /api/auth/meand branch context. - For 403, check the user role and
deniedKeys. - Retry 500 only for idempotent reads; report persistent failures to your Cleos administrator.