Skip to content

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

422 Unprocessable Entity
{
  "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

StatustypeMeaning
200 / 201—Success (201 when something was created)
400invalid_request_errorMalformed JSON, bad cursor or bad Idempotency-Key
401authentication_errorMissing, invalid, revoked or expired API key, or the developer account that owns it is not active
403permission_errorThe key lacks a scope the endpoint needs, or its live access or facility grant does not allow the request
404not_found_errorNot found — including another facility’s resource requested with a facility-scoped key
409conflict_error / idempotency_errorThe resource’s state forbids the operation, or an Idempotency-Key was reused
413invalid_request_errorBody larger than 1 MB
422invalid_request_errorValidation failed — see details
429rate_limit_errorRate limited — wait Retry-After seconds
503service_unavailable_errorA dependency is not configured or is down (e.g. online payments, or the sandbox for test keys)
500api_errorUnexpected failure on our side. Safe to retry with the same Idempotency-Key.

Common codes

codeWhen
missing_api_keyNo Authorization header
insufficient_scopeMissing scope(s) listed in details.missing
validation_failedA field failed validation
resource_missingThe id does not exist (or is not visible to this key)
conflicte.g. paying a voided invoice, a second live subscription for one facility, a reused payment reference
overpaymentA payment larger than the amount due
idempotency_key_reusedSame Idempotency-Key, different request body
request_in_progressThe first request with this Idempotency-Key has not finished
facility_requiredA network key sent usage without facility_id
rate_limitedToo many requests for this key in the last 60 seconds
payments_unavailablePaystack 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.

StatuscodeWhen
401api_key_disabledThe developer account that owns the key is not active, for example because it is suspended or closed.
403live_access_requiredA live key was used, but live access is not approved for the account, or two-step verification is off.
403facility_access_revokedThe account no longer holds a grant for the facility this live key was created for.
403console_requiredA live key called POST /webhook-endpoints. Live endpoints are created in the developer console, which asks for a code from your authenticator app.
429developer_rate_limitedYour account’s test keys, or its live keys, together went over the account budget. See rate limits.
503sandbox_unavailableA 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_progress and 429): fix the request; retrying unchanged will fail again.
  • 429: wait for Retry-After seconds, 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 on error.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:

StatuscodeWhen
400invalid_jsonThe body is not valid JSON
400invalid_tokenA set-up or password-reset link is expired, already used or replaced by a newer one
401invalid_credentialsThe e-mail and password do not match an active account (the same answer in every case)
401invalid_codeThe two-step verification code or recovery code is not valid
401invalid_challengeThe two-step sign-in step expired or was already used: sign in again
401session_expiredThe session has ended: sign in again
403cross_siteThe request did not come from the hub’s own pages
403account_suspendedThe account is suspended
409refresh_raceAnother tab refreshed the session a moment ago. The session is still valid; retry shortly.
413body_too_largeThe body is larger than 8 KB
415unsupported_media_typeThe body is not application/json
422validation_failedA field failed validation
422weak_passwordThe password does not meet the policy. A set-up or reset link stays valid.
429rate_limitedToo many attempts: wait Retry-After seconds
500internal_errorUnexpected failure on our side