Skip to main content

Error response format

All errors follow a consistent JSON structure:
{
  "statusCode": 400,
  "message": "Human-readable description of the error",
  "error": "Bad Request"
}
For validation errors, message may be an array of field-level messages:
{
  "statusCode": 400,
  "message": [
    "phone must be 11 digits",
    "amount must not be less than 50"
  ],
  "error": "Bad Request"
}

HTTP status codes

CodeNameWhen it occurs
200OKRequest succeeded
201CreatedResource created (e.g. access request submitted)
400Bad RequestInvalid request body, failed validation, or business logic error
401UnauthorizedMissing, invalid, or revoked API key
403ForbiddenAction not permitted for your account tier or status
404Not FoundThe requested resource does not exist
429Too Many RequestsRate limit exceeded
500Internal Server ErrorAn unexpected error on our side

Common error messages

Authentication & access

MessageCauseFix
UnauthorizedMissing or invalid API keyCheck your Authorization header
API access is only available to Tier 3 usersAccount not yet Tier 3Complete verification to upgrade
No approved API client foundAccess request not approvedSubmit an access request from your dashboard
Your API key is not activeKey revoked or disabledRegenerate your API key

Validation errors

MessageCause
Phone number must be 11 digitsphone field format invalid
minimum amount is N50amount below minimum
maximum amount is N10000amount above maximum
Webhook must be a valid HTTPS URLwebhookUrl not HTTPS
Maximum of 20 IP entriesIP allowlist limit reached

Transaction errors

MessageCause
Insufficient wallet balanceNot enough funds in wallet
Invalid transaction PINWrong PIN supplied
Product not foundNetwork/product name unrecognized
Meter number validation failedMeter number incorrect or service unavailable
Smartcard validation failedDecoder number incorrect

OTP errors

MessageCause
Invalid OTPWrong or expired OTP entered
OTP has expiredOTP not used within the time window (10 minutes)
Too many OTP attemptsOTP locked after repeated failures

Handling errors in code

const response = await fetch("https://api.dancity.app/api/external/v1/airtime/buy", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.DANCITY_API_KEY}`,
    "Content-Type": "application/json",
    channel: "API",
  },
  body: JSON.stringify({ product: "MTN Airtime", phone: "08012345678", amount: 100, pin: "1234" }),
});

if (!response.ok) {
  const error = await response.json();
  console.error(`Error ${error.statusCode}: ${error.message}`);
  // Handle specific codes
  if (response.status === 401) { /* refresh credentials */ }
  if (response.status === 400) { /* fix request parameters */ }
  return;
}

const data = await response.json();
Log the full error response body for every failed API call. The message field is always human-readable and helps quickly identify the root cause.