Reference

Errors & Response Envelope

Every MailAfrica endpoint wraps responses in a standard envelope. Understand success and error shapes, pagination, and the full error-code catalog.

Every endpoint returns a JSON envelope. Errors never leak internals — just a stable code, a message, and your request id.

Success envelope

json
{
  "success": true,
  "message": "balance retrieved",
  "data": { "balance_tzs": 45000 },
  "pagination": null,
  "request_id": "req_01",
  "timestamp": "2026-08-15T00:00:00Z"
}

Error envelope

json
{
  "success": false,
  "message": "insufficient balance",
  "errors": [
    {
      "field": "amount_tzs",
      "code": "INSUFFICIENT_BALANCE",
      "message": "wallet balance is too low"
    }
  ],
  "request_id": "req_02",
  "timestamp": "2026-08-15T00:00:00Z"
}

errors[] entries carry an optional field, a stable code, and a human message. List endpoints return pagination with page, per_page, total, total_pages.

HTTP status codes

StatusMeaning
200OK
201Created (e.g. address, key, webhook, message sent)
400Bad request — validation or rule violation
401Missing or invalid credentials
402Payment required — INSUFFICIENT_BALANCE
403Forbidden — not yours, account disabled, or identity unverified
404Not found
409Conflict — duplicate, limit reached, or state conflict
429Rate limited
5xxServer / upstream provider error — retry with backoff

Error codes

StatusCodeMeaningHow to fix
Client error401UNAUTHORIZEDMissing, malformed, or expired credentials.Send a valid X-API-Key or JWT. Refresh expired JWTs.
Client error400VALIDATION_ERRORThe request body or query failed validation.Read the field in the error and correct it.
Client error403ACCOUNT_DISABLEDThe account is disabled.Contact support; existing keys stop working immediately.
Client error403FORBIDDENThe resource isn't yours, or identity isn't verified.Verify email/phone; only use your own resource ids.
Client error404NOT_FOUNDResource doesn't exist.Check the id/url you passed.
Client error409CONFLICTDuplicate or conflicting state.Check for existing resources; resolve the conflict first.
Client error409LIMIT_REACHEDYou hit a per-account cap (e.g. 100 addresses).Delete unused resources or contact support.
Client error402INSUFFICIENT_BALANCEWallet can't cover the operation.Top up and retry.
Client error429RATE_LIMITEDToo many requests.Back off and respect the rate limit.
Server error503NOT_CONFIGUREDA provider integration isn't configured server-side.This is a platform-side gap; retry later.
Server error502PROVIDER_ERRORUpstream provider failure.Retry; outbound balance is refunded on failure.
Client error200PENDINGDNS verification not yet propagated.Wait and re-verify — not a real failure.

Retry guidance

  • Retry 429, 502, 503, and timeout errors with exponential backoff and jitter.
  • Do not blindly retry 400, 401, 403, 404, 409 — fix the request first.
  • Sends and webhook deliveries are already idempotent from the platform side; repeated POST calls are safe to retry.