Errors and Retries

A request that Levl refuses is answered with an HTTP error status and a JSON body that says why. This page lists those answers and says when a request is safe to send again.

Error format

{
  "error": "Bad Request",
  "error_key": "FIELD_VALIDATION_FAILED",
  "message": "Validation failed",
  "details": [
    {
      "source": "cl_transfer_id",
      "rejected_value": "invoice-1042",
      "message": "a transfer with this cl_transfer_id already exists for the account"
    }
  ]
}
  • error_key: a stable key for the kind of error.
  • details: present on a validation error. Each entry names the field or rule that failed in source and what is wrong in message.

Status codes

Statuserror_keyMeaningSend again?
400FIELD_VALIDATION_FAILED or FIELD_MISSINGThe request is not acceptable. details names each field.No. Correct the request first.
401none, the body is emptyThe access token is missing, invalid or expired.Yes, with a new token.
404ends in _NOT_FOUND, for example TRANSFER_NOT_FOUNDThe resource does not exist.No.
429RATE_LIMIT_EXCEEDEDToo many requests in a short time. Validate receiver bank allows you 3 requests per second, and fewer while the service as a whole is busy.Yes, after a pause.
500INTERNAL_SERVER_ERRORLevl could not process the request.Yes. For a transfer creation, as described below. A request that keeps answering 500 may itself be malformed.
503SERVICE_UNAVAILABLETransfers are temporarily unavailable.Yes, after the number of seconds in the Retry-After header.

Retrying a transfer creation

A first attempt answered with a 4xx status, a 429 included, created no transfer. Send the corrected request with a new Idempotency-Key.

After a 5xx status, or when no response arrives, send the same request again with the same Idempotency-Key and the same cl_transfer_id. The answer tells you what happened:

Answer to the retryWhat it means
201 with Idempotency-Replayed: falseThe first attempt created nothing. The transfer is created now.
201 with Idempotency-Replayed: trueThe first attempt created the transfer. The body is the answer that attempt was given, so read the transfer for its current status.
400 on cl_transfer_id: a transfer with this cl_transfer_id already exists for the accountThe first attempt created the transfer, and its answer is no longer kept under the key. Read the transfer with GET /v0/transfers?clTransferId=.
400 on transfer: idempotency_key replayed with different request bodyThe key can no longer be used, and the first attempt may or may not have created the transfer. Look it up with GET /v0/transfers?clTransferId=. If it is not there, send the request again with a new Idempotency-Key.

Send a cl_transfer_id with every transfer. It is unique within your account, so it protects against a duplicate even when the idempotency key is lost, and it lets you find a transfer whose response you never received.

A created transfer can be read as soon as its 201 is returned.

Accepted, then failed

A 201 means the transfer was accepted, not that it will be paid. A transfer that cannot be paid moves to FAILED, which you see on GET /v0/transfers and in the webhook. The common causes are:

  • Insufficient wallet balance. The balance is not checked when the transfer is created. The transfer is accepted and moves to FAILED, usually within seconds, and nothing is debited. Read the balance with Get wallets before sending.
  • The receiving bank rejects the payout, for example because the account does not exist or is closed. The amount is returned to your wallet.

A FAILED transfer is final and is not retried. To pay the beneficiary, create a new transfer with a new Idempotency-Key and a new cl_transfer_id.


Did this page help you?