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:
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:
{
"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.
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.
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"success": false,
"error": "invalid_client",
"error_description": "Client authentication failed."
}
| HTTP | error | Meaning |
|---|---|---|
| 400 | unsupported_grant_type | grant_type is not client_credentials. |
| 400 | invalid_request | client_id or client_secret missing. |
| 400 | invalid_scope | A requested scope is unknown or not allowed for your account. |
| 401 | invalid_client | Wrong, revoked or regenerated credentials; suspended application; inactive account. |
| 403 | unauthorized_client | Production 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
| HTTP | code | Meaning / what to do |
|---|---|---|
| 400 | BAD_REQUEST | Malformed request, e.g. a body that is not valid JSON. |
| 401 | UNAUTHENTICATED | No Authorization: Bearer header. |
| 401 | INVALID_TOKEN | Token expired, revoked or unknown. Request a new token. |
| 403 | INSUFFICIENT_SCOPE | The token lacks the scope in details.required_scope, or your account no longer has the permission. |
| 404 | NOT_FOUND | Unknown endpoint, or a resource that does not belong to you. |
| 405 | METHOD_NOT_ALLOWED | Wrong HTTP method. The Allow header lists the accepted ones. |
| 409 | CONFLICT | The request conflicts with the current state of the resource. |
| 413 | PAYLOAD_TOO_LARGE | The request body is too large. |
| 415 | UNSUPPORTED_MEDIA_TYPE | Send bodies as application/json (/oauth/token also accepts application/x-www-form-urlencoded). |
| 422 | VALIDATION_ERROR | Invalid fields; see details. |
| 429 | TOO_MANY_REQUESTS | Rate limit exceeded. Wait for Retry-After seconds. |
| 500 | INTERNAL_SERVER_ERROR | Unexpected error. Retry with backoff and contact support with the request_id. |
| 502 | PROVIDER_ERROR | An upstream service could not complete the request. Retry later with backoff. |
| 503 | SERVICE_UNAVAILABLE | Temporarily unavailable (e.g. maintenance). Retry after Retry-After seconds. |
Operation errors
| HTTP | code | Meaning / what to do |
|---|---|---|
| 400 | IDEMPOTENCY_KEY_REQUIRED | Send an Idempotency-Key header (max. 100 characters). |
| 403 | OPERATION_NOT_AVAILABLE | The operation is not available in this environment. |
| 409 | CONFIRMATION_ALREADY_REQUESTED | Production: /cancel-transaction after /confirm was already called for the order. An order can only be cancelled before confirmation. |
| 404 | OPERATOR_NOT_FOUND | No operator found for the mobile number. |
| 409 | TRANSACTION_NOT_PENDING | Only PENDING transactions can be confirmed or cancelled. details.status has the current status. A repeated confirmation never executes the recharge twice. |
| 409 | DUPLICATE_EXTERNAL_REF_ID | The 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. |
| 409 | IDEMPOTENCY_CONFLICT | Sandbox: the Idempotency-Key was already used with a different body. Use a new key for a new order. |
| 422 | PRODUCT_NOT_FOUND | Sandbox: unknown product_id for this number. Get valid ids from /mobile-recharge/lookup or /mobile-recharge/operator-switch. |
| 403 / 404 / 409 / 422 / 500 | TOPUP_FAILED | Production: the order was refused (product not found, transaction limit reached, invalid data…). Read error.message. |
| 500 | INTERNAL_ERROR | Production: unexpected error while creating the order. Retry with the same Idempotency-Key and body. |
Handling errors
- Branch on
error.code, not onerror.message(messages can change). - On
401 INVALID_TOKEN, request a new token once and retry the call. - Retry
429,502,503and other5xxwith exponential backoff. For orders, always retry with the sameIdempotency-Key, so a retry never creates a duplicate. - Do not retry
400,403,404,405,409,413,415or422without changing the request. - Log the
request_idof failed calls; it is the fastest way for support to investigate.