Errors
The error envelope, code conventions and the HTTP statuses you'll see.
Every failed request returns the same envelope, whatever the status code:
{
"error": {
"code": "auth.otp.invalid",
"message": "That code isn't right.",
"request_id": "0199a1b2-7c3d-7e4f-8a5b-6c7d8e9f0a1b",
"attempts_left": 3
}
}
| Field | Always present | Meaning |
|---|---|---|
code | yes | Stable, dotted identifier: <module>.<resource>.<problem> (e.g. auth.otp.invalid, platform.tenant.not_found). Safe to branch on in code. |
message | yes | Plain-English explanation. Safe to show a user, but don't parse it — use code. |
request_id | yes | Also echoed on the X-Request-ID response header. Include it when asking us about an error. |
fields | on validation errors | Per-field messages, e.g. {"q": ["Must be at least 2 characters."]}. |
retry_after | on 429 | Seconds to wait before retrying — see Rate limits. |
attempts_left | on some 401/423 | Remaining tries before a code or account locks. |
Statuses you'll see
| Status | Meaning |
|---|---|
400 | The request was rejected for a domain reason (e.g. wrong credentials). Check code. |
401 | Missing, invalid or expired credentials. |
403 | Signed in, but not allowed to do this. |
404 | The resource doesn't exist (or you can't see it). |
409 | Conflict — e.g. trying to delete something still in use (conflict.in_use). |
422 | Request body/query failed validation; see fields. |
429 | Rate limited; see retry_after. |
500 | Unexpected server error. message includes the request id; nothing else is disclosed. |
Some endpoints use additional statuses for specific situations (for example 410 for an expired
reset code, 423 for a locked account) — check the API reference for
what a given endpoint can return.
Examples from the API
Validation (422):
curl "https://semaschools.com/api/v1/platform/schools/search?q=a"
{
"error": {
"code": "validation.failed",
"message": "Some details need your attention.",
"fields": { "q": ["Must be at least 2 characters."] },
"request_id": "01a0e09e0e69739da0f2d4da3a6a747c"
}
}
Not found (404):
curl "https://semaschools.com/api/v1/platform/tenant/resolve?host=doesnotexist.semaschools.com"
{
"error": {
"code": "platform.tenant.not_found",
"message": "We couldn't find that school.",
"request_id": "01a0e09e0e9770018fbf81c9f024262e"
}
}
Unauthenticated (401):
{
"error": {
"code": "auth.unauthenticated",
"message": "Please sign in to continue.",
"request_id": "01a0e09e252a766289d36829fa51a4d6"
}
}
Never rely on the exact wording of message — only code, fields and retry_after are
guaranteed to be stable across releases.