e Ecovoy Developers
ecovoy.com Log in

Error codes

Every API response is JSON, errors included, whatever Accept header you send. Ecovoy uses standard HTTP status codes and a stable, machine-readable code for every error.

Error format

All endpoints (except the OAuth errors of /oauth/token) return errors in this envelope. details is present only when there is more information:

Error response
HTTP/1.1 403 Forbidden
Content-Type: application/json
X-Request-Id: req_3c1b2a6e0f9d4c1e9b8a6d5e4f3a2b10

{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_SCOPE",
    "message": "This operation requires the 'topup:write' scope.",
    "details": { "required_scope": "topup:write" },
    "request_id": "req_3c1b2a6e0f9d4c1e9b8a6d5e4f3a2b10"
  }
}

Validation errors list each invalid field in details:

422 VALIDATION_ERROR
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The submitted data is invalid.",
    "details": {
      "mobile_number": ["The mobile number field format is invalid."]
    },
    "request_id": "req_5d4c3b2a1f0e4d9c8b7a6f5e4d3c2b1a"
  }
}

Every error includes a request_id, also sent in the X-Request-Id header of every response. Error messages never contain internal details; send the request_id to support so we can find the details of a failed call.

500 INTERNAL_SERVER_ERROR
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
X-Request-Id: req_9f0c7d1e2b3a4c5d8e6f7a8b9c0d1e2f

{
  "success": false,
  "error": {
    "code": "INTERNAL_SERVER_ERROR",
    "message": "An unexpected error occurred. Please try again later.",
    "request_id": "req_9f0c7d1e2b3a4c5d8e6f7a8b9c0d1e2f"
  }
}

Token endpoint errors

Credential errors of POST /oauth/token follow the OAuth 2.0 specification (RFC 6749): error is a string, explained by error_description.

OAuth error
HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "success": false,
  "error": "invalid_client",
  "error_description": "Client authentication failed."
}
HTTPerrorMeaning
400unsupported_grant_typegrant_type is not client_credentials.
400invalid_requestclient_id or client_secret missing.
400invalid_scopeA requested scope is unknown or not allowed for your account.
401invalid_clientWrong, revoked or regenerated credentials; suspended application; inactive account.
403unauthorized_clientProduction credentials for an application that is not approved for Production.

Other errors of this endpoint (for example 429 after more than 10 token requests per minute) use the standard envelope above.

HTTP errors

HTTPcodeMeaning / what to do
400BAD_REQUESTMalformed request, e.g. a body that is not valid JSON.
401UNAUTHENTICATEDNo Authorization: Bearer header.
401INVALID_TOKENToken expired, revoked or unknown. Request a new token.
403INSUFFICIENT_SCOPEThe token lacks the scope in details.required_scope, or your account no longer has the permission.
404NOT_FOUNDUnknown endpoint, or a resource that does not belong to you.
405METHOD_NOT_ALLOWEDWrong HTTP method. The Allow header lists the accepted ones.
409CONFLICTThe request conflicts with the current state of the resource.
413PAYLOAD_TOO_LARGEThe request body is too large.
415UNSUPPORTED_MEDIA_TYPESend bodies as application/json (/oauth/token also accepts application/x-www-form-urlencoded).
422VALIDATION_ERRORInvalid fields; see details.
429TOO_MANY_REQUESTSRate limit exceeded. Wait for Retry-After seconds.
500INTERNAL_SERVER_ERRORUnexpected error. Retry with backoff and contact support with the request_id.
502PROVIDER_ERRORAn upstream service could not complete the request. Retry later with backoff.
503SERVICE_UNAVAILABLETemporarily unavailable (e.g. maintenance). Retry after Retry-After seconds.

Operation errors

HTTPcodeMeaning / what to do
400IDEMPOTENCY_KEY_REQUIREDSend an Idempotency-Key header (max. 100 characters).
403OPERATION_NOT_AVAILABLEThe operation is not available in this environment.
409CONFIRMATION_ALREADY_REQUESTEDProduction: /cancel-transaction after /confirm was already called for the order. An order can only be cancelled before confirmation.
404OPERATOR_NOT_FOUNDNo operator found for the mobile number.
409TRANSACTION_NOT_PENDINGOnly PENDING transactions can be confirmed or cancelled. details.status has the current status. A repeated confirmation never executes the recharge twice.
409DUPLICATE_EXTERNAL_REF_IDThe external_ref_id of /mobile-recharge/orders is already used by another order. Send a new value for each order; on a retry, continue with details.transaction_id.
409IDEMPOTENCY_CONFLICTSandbox: the Idempotency-Key was already used with a different body. Use a new key for a new order.
422PRODUCT_NOT_FOUNDSandbox: unknown product_id for this number. Get valid ids from /mobile-recharge/lookup or /mobile-recharge/operator-switch.
403 / 404 / 409 / 422 / 500TOPUP_FAILEDProduction: the order was refused (product not found, transaction limit reached, invalid data…). Read error.message.
500INTERNAL_ERRORProduction: unexpected error while creating the order. Retry with the same Idempotency-Key and body.

Handling errors