Naafi Pay

Error Codes

Every NaafiPay API error returns the same JSON envelope, with a stable error.code string you can switch on in your application. HTTP status codes follow standard semantics: 4xx for client errors, 5xx for server errors. This page lists every error code the API can emit, what it means, and what action you (or your customer) need to take to resolve it. Use these codes — not the human-readable messages — when deciding how your application should react.

Error envelope

Error
1{
2 "error": {
3 "code": "invalid_amount",
4 "message": "The amount must be greater than 0.",
5 "status": 400,
6 "param": "amount"
7 }
8}

Authentication errors (401)

FieldTypeRequiredDescription
unauthorized401optionalAPI key is missing or malformed.
invalid_key401optionalAPI key was revoked or never existed.
test_mode_only401optionalLive key required for this operation, or vice versa.

Authorisation errors (403)

FieldTypeRequiredDescription
wrong_storefront403optionalResource belongs to a different storefront.
permission_denied403optionalAPI key role does not allow this action.
kyc_required403optionalLive payments are blocked until KYC is approved.

Validation errors (400)

FieldTypeRequiredDescription
invalid_amount400optionalAmount is missing, zero, negative, or above the max.
invalid_currency400optionalCurrency is not BDT.
invalid_url400optionalsuccess_url, cancel_url, or webhook_url is not a valid HTTPS URL.
invalid_email400optionalEmail is missing or not a valid address.
missing_field400optionalA required field is missing. error.param tells you which.
invalid_status400optionalStatus filter must be one of the documented values.
invalid_date400optionaldate_from or date_to is not a valid ISO 8601 timestamp.
invalid_plan400optionalplan_id does not exist or is archived.
already_paid400optionalCannot cancel an invoice that is already completed.
already_cancelled400optionalCannot cancel an invoice that is already cancelled.

Not found (404)

FieldTypeRequiredDescription
not_found404optionalThe resource does not exist.

Rate limiting (429)

FieldTypeRequiredDescription
rate_limited429optionalToo many requests in the current window. Read the Retry-After header.

Server errors (5xx)

FieldTypeRequiredDescription
internal_error500optionalUnexpected error on our side. Safe to retry with exponential backoff.
upstream_unavailable502optionalAn upstream provider (bKash, Nagad, card processor) is temporarily unavailable.
gateway_timeout504optionalUpstream provider did not respond in time. Safe to retry.
TipSwitch on error.code, not error.message
We may rephrase error.message for clarity in the future without warning. error.code values are stable and safe to depend on.
WarningRetry only on 5xx and 429
4xx errors (other than 429) indicate a problem with your request. Retrying without changing the request will produce the same error.
Updated at: May 30, 2026