Skip to main content
Sema Schools

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
  }
}
FieldAlways presentMeaning
codeyesStable, dotted identifier: <module>.<resource>.<problem> (e.g. auth.otp.invalid, platform.tenant.not_found). Safe to branch on in code.
messageyesPlain-English explanation. Safe to show a user, but don't parse it — use code.
request_idyesAlso echoed on the X-Request-ID response header. Include it when asking us about an error.
fieldson validation errorsPer-field messages, e.g. {"q": ["Must be at least 2 characters."]}.
retry_afteron 429Seconds to wait before retrying — see Rate limits.
attempts_lefton some 401/423Remaining tries before a code or account locks.

Statuses you'll see

StatusMeaning
400The request was rejected for a domain reason (e.g. wrong credentials). Check code.
401Missing, invalid or expired credentials.
403Signed in, but not allowed to do this.
404The resource doesn't exist (or you can't see it).
409Conflict — e.g. trying to delete something still in use (conflict.in_use).
422Request body/query failed validation; see fields.
429Rate limited; see retry_after.
500Unexpected 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.