Errors
Errors use conventional HTTP status codes and one JSON shape. Branch on error.code, show error.message, and log error.request_id.
Error shape
{
"error": {
"type": "invalid_request_error",
"code": "validation_failed",
"message": "records.0.metric: Invalid option: expected one of \"nhis_claims_submitted\"|…",
"request_id": "req_kGMKvwXx-phjiJsl",
"details": [
{ "path": "records.0.metric", "message": "Invalid option: …" }
]
}
}Every response — success or error — also carries a Request-Id header with the same value. Quote it when you contact support; it locates the request in the hub’s logs.
Status codes
| Status | type | Meaning |
|---|---|---|
| 200 / 201 | — | Success (201 when something was created) |
| 400 | invalid_request_error | Malformed JSON, bad cursor or bad Idempotency-Key |
| 401 | authentication_error | Missing, invalid, revoked or expired API key, or the developer account that owns it is not active |
| 403 | permission_error | The key lacks a scope the endpoint needs, or its live access or facility grant does not allow the request |
| 404 | not_found_error | Not found — including another facility’s resource requested with a facility-scoped key |
| 409 | conflict_error / idempotency_error | The resource’s state forbids the operation, or an Idempotency-Key was reused |
| 413 | invalid_request_error | Body larger than 1 MB |
| 422 | invalid_request_error | Validation failed — see details |
| 429 | rate_limit_error | Rate limited — wait Retry-After seconds |
| 503 | service_unavailable_error | A dependency is not configured or is down (e.g. online payments, or the sandbox for test keys) |
| 500 | api_error | Unexpected failure on our side. Safe to retry with the same Idempotency-Key. |
Common codes
| code | When |
|---|---|
missing_api_key | No Authorization header |
insufficient_scope | Missing scope(s) listed in details.missing |
validation_failed | A field failed validation |
resource_missing | The id does not exist (or is not visible to this key) |
conflict | e.g. paying a voided invoice, a second live subscription for one facility, a reused payment reference |
overpayment | A payment larger than the amount due |
idempotency_key_reused | Same Idempotency-Key, different request body |
request_in_progress | The first request with this Idempotency-Key has not finished |
facility_required | A network key sent usage without facility_id |
rate_limited | Too many requests for this key in the last 60 seconds |
payments_unavailable | Paystack is not configured on this hub |
Key and account codes
These come from the checks on your developer account, its live access and its grants. The hub makes them on every request, so a change on the account takes effect on the next call.
| Status | code | When |
|---|---|---|
| 401 | api_key_disabled | The developer account that owns the key is not active, for example because it is suspended or closed. |
| 403 | live_access_required | A live key was used, but live access is not approved for the account, or two-step verification is off. |
| 403 | facility_access_revoked | The account no longer holds a grant for the facility this live key was created for. |
| 403 | console_required | A live key called POST /webhook-endpoints. Live endpoints are created in the developer console, which asks for a code from your authenticator app. |
| 429 | developer_rate_limited | Your account’s test keys, or its live keys, together went over the account budget. See rate limits. |
| 503 | sandbox_unavailable | A test key was used, but the sandbox facility is not set up on this hub yet. |
Not an error: once your keys have stored 1,000 usage records in the sandbox in one UTC day, POST /usage answers 202 with persisted: false and reason: "sandbox_daily_cap", and stores nothing.
Handling errors
- 4xx (except 409
request_in_progressand 429): fix the request; retrying unchanged will fail again. - 429: wait for
Retry-Afterseconds, then retry. See rate limits. - 5xx and network errors: retry with exponential backoff and the same
Idempotency-Key. See idempotency. - Branch on
error.code, not onerror.message— messages may be reworded; codes are stable.
Developer account endpoints
The sign-in pages and the developer console call /api/developer/auth/*. These endpoints accept same-origin requests from the hub’s own pages only, so your integration never calls them. They use a different shape: { "success": false, "error": "…", "code": "…" }. The codes are listed here so you can recognise them:
| Status | code | When |
|---|---|---|
| 400 | invalid_json | The body is not valid JSON |
| 400 | invalid_token | A set-up or password-reset link is expired, already used or replaced by a newer one |
| 401 | invalid_credentials | The e-mail and password do not match an active account (the same answer in every case) |
| 401 | invalid_code | The two-step verification code or recovery code is not valid |
| 401 | invalid_challenge | The two-step sign-in step expired or was already used: sign in again |
| 401 | session_expired | The session has ended: sign in again |
| 403 | cross_site | The request did not come from the hub’s own pages |
| 403 | account_suspended | The account is suspended |
| 409 | refresh_race | Another tab refreshed the session a moment ago. The session is still valid; retry shortly. |
| 413 | body_too_large | The body is larger than 8 KB |
| 415 | unsupported_media_type | The body is not application/json |
| 422 | validation_failed | A field failed validation |
| 422 | weak_password | The password does not meet the policy. A set-up or reset link stays valid. |
| 429 | rate_limited | Too many attempts: wait Retry-After seconds |
| 500 | internal_error | Unexpected failure on our side |