Errors

Tell a failed request from a failed payment, and what to do about each.

Check the HTTP status of every response: 2xx means it worked, 4xx means you have to change the request, and 5xx means the problem is on our side.

The error body

Every error has this body, whatever endpoint it comes from:

{
  "error": {
    "type": "invalid_request_error",
    "code": "resource_missing",
    "message": "Payment not found",
    "param": "id",
    "requestId": "req_4f1c2a9e8b7d4c3a9f0e1d2c3b4a5f6e"
  }
}
FieldMeaning
typeThe group of the error. Read it first.
codeA lower_snake code. Branch on this field.
messageWhat happened and what to do. Log it or show it to your team, but do not branch on it, since messages can be reworded.
paramThe request field at fault, such as amount or Idempotency-Key. Absent when no field is at fault.
requestIdThe call's request ID.

The HTTP status is the only status. The body does not repeat it.

The OAuth endpoints, /api/v1/oauth/token and /api/v1/oauth/revoke, answer in the OAuth 2.0 shape of RFC 6749 instead. Their errors have an error string such as invalid_client, and an error_description. See Authentication.

Types

typeWhen
invalid_request_errorSomething is wrong with the request or with the state it targets: 400, 401, 403, 404, 409 and 422.
idempotency_errorAn Idempotency-Key was reused for another request, or the first request with it is still running.
rate_limit_errorYou sent too many requests: 429.
api_errorThe failure is on our side: 500, 502, 503 and 504.

Request IDs

Log the Request-Id response header, such as req_4f1c2a9e8b7d4c3a9f0e1d2c3b4a5f6e. It is the same value as requestId in the body. Quote it when you contact support, so the call can be found.

Authentication errors

Every 401 carries a WWW-Authenticate: Bearer realm="Flex Malipo" header next to the error body, with the code authentication_required. A 403 does not carry that header. It answers with the code permission_denied.

Status codes

CodeMeaningWhat to do
200, 201, 202, 204It worked. 202 means the outcome comes later.
400The request is invalid: a missing or malformed field, or a value the API does not accept.Fix the request. Do not retry it unchanged.
401The access token is missing, expired or revoked.Get a new token and retry.
403The token lacks the scope the call needs, the call is not available to you, or your key may not be used from this address.Check the key's scopes and allowed addresses.
404You have no resource with this ID, or there is nothing at this path.Check the ID and the path.
405, 406, 415The method is not allowed on the path, you ask for a format other than JSON, or the body is not JSON.Fix the request.
409The request conflicts with the state of a resource, or an earlier request with the same Idempotency-Key is still running.For idempotency_request_in_progress, retry with the same Idempotency-Key after a short wait. For any other code, do not retry: read the resource, then decide.
422The request is valid but cannot be done, such as a payment to a network you switched off.Change what you ask for.
429You sent too many requests.Wait the seconds in Retry-After, then retry. See Rate limits.
500, 502, 504The request did not complete.Retry with the same Idempotency-Key.
503The service cannot answer right now.Retry only when the response has a Retry-After header, after that many seconds. Without it, do not retry.

Retry a write only with the same Idempotency-Key. See Idempotency. Wait longer after each retry, for example 1 second, then 2, then 4, and stop after 2 retries.

Codes you may meet

Every error has a code. The generic ones come from any endpoint.

CodeStatusMeaning
parameter_invalid400A field is missing, has the wrong type or format, or breaks a limit. param names the first field at fault, and message lists every one.
parameter_missing400A required query parameter or header is missing.
amount_invalid400An amount is not an integer in the currency's minor unit. See Money.
api_version_invalid400The version you sent is not one this API serves. See Versioning.
resource_already_exists400Another object already has this value of a field that must be unique, such as a customer's externalId or a price's lookupKey. param names the field, and message names the object that has it.
authentication_required401The token is missing, invalid or expired.
permission_denied403The credential cannot do this.
resource_missing404There is no such resource, or nothing at this path.
method_not_allowed405The method is not allowed on this path.
not_acceptable406The API answers in application/json only.
media_type_unsupported415Send the body as application/json.
conflict409The request conflicts with the state of a resource, with no more specific code.
request_not_allowed422The request is valid but cannot be done, with no more specific code.
rate_limited429You sent too many requests.
service_unavailable503The service cannot answer right now. Retry-After is present when a retry is safe.
upstream_failed502A service Flex Malipo depends on failed.
upstream_timeout504The service took too long to answer.
internal_error500Something went wrong on our side.

These codes belong to one area.

CodeStatusMeaning
account_not_verified403Live mode is off until your business is approved. Test mode is not affected. See Go live.
idempotency_key_reused400The Idempotency-Key was already used with a different request. Type idempotency_error.
idempotency_request_in_progress409A request with this Idempotency-Key is still running. Type idempotency_error. Retry with the same key after a short wait.
amount_too_large400An amount is above the largest the network takes, a refund is more than what is left to refund, or a payment you record is more than what is still to pay on the invoice. limit.maximum shows the largest amount. See Amount limits.
refund_window_passed400The payment succeeded more than 1 year ago.
refund_not_supported400The payment's network cannot send a refund yet.
payment_not_refundable400Only a SUCCEEDED collection can be refunded.
insufficient_balance400Your available balance does not cover the refund and its payout fee.
subscription_exists409The customer already holds an open subscription the rules do not allow a second to. See One subscription per customer.
too_many_prompts429Too many payment requests to one phone number. Retry-After says how long to wait.
amount_too_small400An amount is below the smallest the network takes, or a part payment would leave less to pay than the smallest amount a customer can pay. limit.minimum shows the smallest amount. See Amount limits.
payment_method_unactivated422The customer's number is on a network you cannot take payments on: it is not available to you, you switched it off, it cannot pay out, or, with a live key, the number is on no network. The message names the networks you can take. See Amount limits.
invoice_not_open409The invoice is paid or void, its subscription takes no payment, or it is an invoice for an upgrade that has expired. See Record a payment.
quote_mismatch409The quote you sent is not for this subscription and this request.
quote_expired409The quote has expired. Request a new preview and send its quoteId.
invalid_status409The subscription is in a status that does not allow this change.
upgrade_pending409An upgrade is waiting for payment, so the subscription cannot be changed yet.
payment_in_progress409A payment on this invoice is still in progress.
invoice_not_withdrawable409The invoice cannot be withdrawn.
period_closed409The billing period the usage belongs to has closed.
dimension_limit_exceeded422A meter event has more dimension values than the meter allows.

A 503 from Create a payment or from a checkout session carries Retry-After when the request can be sent again with the same Idempotency-Key.

Payment failures are not errors

A payment the customer declines is not an HTTP error: creating it worked, so you get 201. You learn the outcome later from a payment.failed webhook, or from the payment's status and failureCode.

failureCodeWhy the payment failed
CUSTOMER_DECLINEDThe customer declined on their phone.
INSUFFICIENT_FUNDSThe customer's wallet did not have enough money.
INSUFFICIENT_BALANCEA payout that your available balance could not cover.
EXPIREDA collection the customer did not approve within 3 minutes, or a payout that was not sent within 4 hours. The status is EXPIRED.

Mobile money networks can report other codes. Treat an unknown failureCode as a failure and show failureMessage to your team, not to the customer.

On this page