API reference
All endpoints of Ecovoy API V2. Base URL:
https://api.ecovoy.com/api/v2Conventions
- JSON in and out. Send
Content-Type: application/jsonon requests with a body. - Authenticate with
Authorization: Bearer <access_token>(see Authentication). - Successful responses wrap the payload in
data; lists addmetawith pagination. - Errors are JSON:
{"success": false, "error": {"code", "message", "details"}}(see Error codes). Exception: the Production response of/mobile-recharge/confirm, described in that section. - Every authenticated response includes an
X-Request-Idheader. Include it when contacting support. - Optional header
X-External-Customer-Id: your own identifier for the end customer. On/mobile-recharge/ordersit is used when the body has noexternal_customer_id. - Rate limit: 120 requests per minute per application. Over the limit you get
429; wait for the number of seconds in theRetry-Afterheader.
POST /oauth/token
Exchanges client_id + client_secret for an access token. Full details in Authentication.
GET /me
Returns the application, environment and scopes of the current token. Scope: account:read.
curl https://api.ecovoy.com/api/v2/me -H "Authorization: Bearer $TOKEN"
<?php
$ch = curl_init('https://api.ecovoy.com/api/v2/me');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token]]);
$me = json_decode(curl_exec($ch), true);
const me = await fetch('https://api.ecovoy.com/api/v2/me', { headers: { Authorization: `Bearer ${token}` } }).then(r => r.json());
{
"data": {
"application": {
"id": "9b4e6a2e-3f0e-4d55-9a62-8f3c1d2b7a10",
"name": "My Store",
"status": "active",
"production_access": "not_requested"
},
"environment": "sandbox",
"scopes": ["account:read", "balance:read", "transactions:read", "topup:read", "topup:write"],
"token_expires_at": "2026-11-10T15:00:00+00:00",
"account": { "name": "Jane Doe" }
}
}
GET /balance
Available balance. Scope: balance:read.
- Production: the balance of the Ecovoy account that owns the application (central Ecovoy wallet).
- Sandbox: a fixed simulated balance (
"simulated": true).
curl https://api.ecovoy.com/api/v2/balance -H "Authorization: Bearer $TOKEN"
<?php
$ch = curl_init('https://api.ecovoy.com/api/v2/balance');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token]]);
$balance = json_decode(curl_exec($ch), true)['data'];
const { data: balance } = await fetch('https://api.ecovoy.com/api/v2/balance', {
headers: { Authorization: `Bearer ${token}` },
}).then(r => r.json());
{
"data": {
"available": 1000.00,
"currency": "USD",
"environment": "sandbox",
"simulated": true
}
}
GET /transactions
Paginated list, newest first. Scope: transactions:read.
| Query parameter | Default | Description |
|---|---|---|
page | 1 | Page number. |
per_page | 20 | Items per page, 1–100. |
- Sandbox: the simulated orders created by this application.
- Production: the mobile recharge transactions of the account that owns the application.
- Each item has the same fields as the order response.
curl "https://api.ecovoy.com/api/v2/transactions?per_page=20&page=1" -H "Authorization: Bearer $TOKEN"
<?php
$ch = curl_init('https://api.ecovoy.com/api/v2/transactions?per_page=20&page=1');
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token]]);
$page = json_decode(curl_exec($ch), true);
const page = await fetch('https://api.ecovoy.com/api/v2/transactions?per_page=20&page=1', {
headers: { Authorization: `Bearer ${token}` },
}).then(r => r.json());
{
"data": [
{
"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab",
"external_id": "ext_01jcz5k8v3m2q9w7e4r6t1y0ac",
"mobile_number": "+50944101111",
"status": "CONFIRMED",
"retail_amount": 2,
"retail_unit": "USD",
"formatted_amount": "2 USD",
"operator_name": "Sandbox Mobile Operator 2",
"product_id": "sbx-product-002",
"product_name": "200 TEST",
"external_ref_id": "ORDER-2026-000123",
"external_customer_id": "CUSTOMER-001",
"environment": "sandbox",
"created_at": "2026-11-13T14:05:12.000000Z",
"...": "same fields as the order response"
}
],
"meta": { "current_page": 1, "per_page": 20, "total": 1, "last_page": 1 }
}
GET /transactions/{transaction_id}
One transaction, by the transaction_id returned by /mobile-recharge/orders. Scope: transactions:read. Use it to follow an order until it reaches a final status (see Transaction statuses). Returns 404 NOT_FOUND if the transaction does not belong to your application (sandbox) or account (production).
Mobile recharge flow
A mobile recharge has four separate steps. Only the confirmation executes the recharge and debits the balance.
| Step | Endpoint | What it does | Creates a transaction? |
|---|---|---|---|
| 1. Automatic identification | POST /mobile-recharge/lookup | Ecovoy identifies the operator of the number and lists its products. | No |
| 2. Manual operator selection (optional) | POST /mobile-recharge/operator-switch | Lists the products of another operator chosen by your customer. | No |
| 3. Order creation | POST /mobile-recharge/orders | Registers the order with your external_ref_id and returns the Ecovoy transaction_id. Does not execute the recharge. | Yes |
| 4. Execution | POST /mobile-recharge/confirm | Executes the recharge for an existing transaction_id. | No (uses the existing one) |
| — or cancellation | POST /cancel-transaction | Cancels the order instead of confirming it. Only before /confirm. | No (uses the existing one) |
- Look up the number with
/lookup. - If the customer says the operator is wrong (for example, a ported number), call
/operator-switchwith the operator they chose. - Create the order with
/orders, using aproduct_idfrom the last response of step 1 or 2, theexternal_ref_idof the sale in your system, and a newIdempotency-Key. - Store the
transaction_idreturned by Ecovoy next to yourexternal_ref_id. - Request the execution with
/confirmand thattransaction_id. - Follow the result with
GET /transactions/{transaction_id}until the status is final.
A complete script is available in Code examples.
Identifiers
| Field | Who sets it | Use |
|---|---|---|
transaction_id | Ecovoy | Unique id of the transaction on the Ecovoy platform. Returned by /orders. It is the id accepted by /confirm, /cancel-transaction and /transactions/{id}. Store it. |
external_ref_id | You (required) | Reference of the transaction in your system (your order, sale or invoice number). One per transaction: it cannot be reused by another order. Stored with the order and returned in every response, so you can match each Ecovoy transaction to your own record. It does not replace transaction_id: /confirm, /cancel-transaction and /transactions/{id} accept only the transaction_id. |
external_customer_id | You (optional) | Id of the end customer in your system. Several orders can have the same value. Stored with the order and returned in the responses. Not used to find or confirm the transaction. |
external_id (response only) | Ecovoy | Internal Ecovoy reference used with the recharge network. You cannot set it. Do not use it to confirm or look up a transaction; use transaction_id. |
Idempotency-Key (header) | You (required) | Protects order creation against duplicates on retries. See Idempotency. It is not a transaction id. |
Transaction statuses
The status field of a transaction. Treat unknown values as "not final" and keep polling.
status | Meaning | Final? |
|---|---|---|
PENDING | Order created, waiting for /confirm, or recharge being processed. | No |
CONFIRMED, COMPLETED | Recharge executed successfully. | Yes — success |
DECLINED (Production), FAILED (Sandbox) | Recharge rejected. In the sandbox, failure_reason explains why. | Yes — failure |
CANCELLED | Order cancelled with /cancel-transaction, or expired without confirmation. | Yes |
Idempotency
POST /mobile-recharge/orders requires the header Idempotency-Key (any string up to 100 characters; a UUID is recommended). Without it the API returns 400 IDEMPOTENCY_KEY_REQUIRED.
- Same key + same body: returns the result of the first request (
200with headerIdempotent-Replayed: true). No new order is created. - Same key + different body:
409 IDEMPOTENCY_CONFLICT. Nothing is created. - New order: always use a new key.
- Connection failure or timeout (no response, or a
5xx): repeat the request with the same key and the same body.
The body is compared on mobile_number, product_id, external_ref_id and external_customer_id. Keys are scoped to your application.
The external_ref_id adds a second protection, in both environments: an order with an external_ref_id that already exists is refused with 409 DUPLICATE_EXTERNAL_REF_ID, and error.details.transaction_id tells you which order already uses it.
Production — current limitation. In Production the Idempotency-Key header is required and validated, but replay (Idempotent-Replayed) and IDEMPOTENCY_CONFLICT are not available yet. A retry with the same body is answered with 409 DUPLICATE_EXTERNAL_REF_ID instead: read error.details.transaction_id to recover the order created by the first request, and continue with that transaction_id. No duplicate order is created.
HTTP/1.1 200 OK
Content-Type: application/json
Idempotent-Replayed: true
{
"data": {
"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab",
"status": "PENDING",
"...": "the original order, unchanged"
}
}
HTTP/1.1 409 Conflict
Content-Type: application/json
{
"success": false,
"error": {
"code": "IDEMPOTENCY_CONFLICT",
"message": "This Idempotency-Key was already used with a different request body.",
"request_id": "req_1a2b3c4d5e6f4a7b8c9d0e1f2a3b4c5d"
}
}
HTTP/1.1 409 Conflict
Content-Type: application/json
{
"success": false,
"error": {
"code": "DUPLICATE_EXTERNAL_REF_ID",
"message": "This external_ref_id was already used by another order. Send a new external_ref_id for each order.",
"details": { "transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab" },
"request_id": "req_2b3c4d5e6f7a4b8c9d0e1f2a3b4c5d6e"
}
}
POST /mobile-recharge/lookup
Automatic identification. Ecovoy identifies the operator of a mobile number and returns the products of that operator. Read-only. Scope: topup:read.
| Field | Type | Description |
|---|---|---|
mobile_number required | string | International format: + followed by 8–15 digits, e.g. +50944103000. |
Response
operators: the operators Ecovoy knows for this number's country.identified: truemarks the operator identified automatically by Ecovoy. It is information only; your customer can still choose another operator with/operator-switch.products: the products of the identified operator. Useproducts[].idasproduct_idin/orders.price_retail_amount/price_retail_unitare the price charged to your balance (wallet currency).- Sandbox: two simulated operators per country (
sbx-{country}-001, identified, andsbx-{country}-002) with fixed test products. Production: real operators and catalogue.
curl -X POST https://api.ecovoy.com/api/v2/mobile-recharge/lookup \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"mobile_number": "+50944103000"}'
<?php
$ch = curl_init('https://api.ecovoy.com/api/v2/mobile-recharge/lookup');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['mobile_number' => '+50944103000']),
]);
$lookup = json_decode(curl_exec($ch), true)['data'];
const { data: lookup } = await fetch('https://api.ecovoy.com/api/v2/mobile-recharge/lookup', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ mobile_number: '+50944103000' }),
}).then(r => r.json());
{
"data": {
"mobile_number": "+50944103000",
"operators": [
{
"id": "sbx-ht-001",
"name": "Sandbox Mobile Operator 1",
"identified": true,
"logo_url": null,
"logo_url_subservice": null,
"country_name": "Haiti",
"country_iso": "HTI",
"country_flag_url": "https://ecovoy.com/assets/flags/4x3/ht.svg"
},
{
"id": "sbx-ht-002",
"name": "Sandbox Mobile Operator 2",
"identified": false,
"logo_url": null,
"logo_url_subservice": null,
"country_name": "Haiti",
"country_iso": "HTI",
"country_flag_url": "https://ecovoy.com/assets/flags/4x3/ht.svg"
}
],
"products": [
{
"id": "sbx-product-001",
"name": "100 TEST",
"display_price": "1 USD",
"display_destination_amount": "100 TEST",
"price_retail_amount": 1,
"price_retail_unit": "USD",
"price_wholesale_amount": 0.9,
"price_wholesale_unit": "USD",
"service_name": "Mobile",
"subservice_name": "Airtime",
"promotions": [],
"operator": { "id": "sbx-ht-001", "name": "Sandbox Mobile Operator 1", "country_name": "Haiti", "country_iso": "HTI" }
},
{ "id": "sbx-product-003", "name": "500 TEST", "display_price": "5 USD", "...": "..." },
{ "id": "sbx-product-005", "name": "1000 TEST", "display_price": "10 USD", "...": "..." }
],
"environment": "sandbox"
}
}
Errors: 404 OPERATOR_NOT_FOUND (no operator for the number), 422 VALIDATION_ERROR, 502 PROVIDER_ERROR (Production, upstream failure — retry later).
POST /mobile-recharge/operator-switch
Manual operator selection. Use it when the operator identified automatically by /lookup is not the real operator of the number — for example, the customer ported the number to another operator. It returns only the products of the operator you send. Read-only. Scope: topup:read.
| Field | Type | Description |
|---|---|---|
mobile_number required | string | International format, e.g. +50944103000. |
operator_id required | string ≤ 50 | The operator chosen by the customer: an operators[].id from /lookup. |
country_iso_code required | string, 2–3 letters | The country of that operator. Send the operators[].country_iso value returned by /lookup for the same operator (e.g. HTI). |
- Does not create a transaction and does not execute a recharge.
- Does not change the automatic identification. Nothing is stored: calling
/lookupagain returns the same automatically identified operator. Theidentifiedflag only has meaning in the/lookupresponse; in this response, rely on the operator you sent, not onidentified. - The response has the same shape as
/lookup. Use aproducts[].idfrom this response asproduct_idin/orders; the products of the previously identified operator are not valid for the operator you selected. - If the combination of number, operator and country has no products,
productsis empty ([]). Check it before showing products to the customer. This happens, for example, with an unknownoperator_idor with acountry_iso_codedifferent from the one returned by/lookup(in the sandbox,HTinstead ofHTI).
{
"mobile_number": "+50944103000",
"operator_id": "sbx-ht-002",
"country_iso_code": "HTI"
}
curl -X POST https://api.ecovoy.com/api/v2/mobile-recharge/operator-switch \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"mobile_number": "+50944103000", "operator_id": "sbx-ht-002", "country_iso_code": "HTI"}'
<?php
$ch = curl_init('https://api.ecovoy.com/api/v2/mobile-recharge/operator-switch');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'mobile_number' => '+50944103000',
'operator_id' => 'sbx-ht-002', // operators[].id from /lookup
'country_iso_code' => 'HTI', // operators[].country_iso from /lookup
]),
]);
$switch = json_decode(curl_exec($ch), true)['data'];
const { data: switched } = await fetch('https://api.ecovoy.com/api/v2/mobile-recharge/operator-switch', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
mobile_number: '+50944103000',
operator_id: 'sbx-ht-002', // operators[].id from /lookup
country_iso_code: 'HTI', // operators[].country_iso from /lookup
}),
}).then(r => r.json());
{
"data": {
"mobile_number": "+50944103000",
"operators": [
{ "id": "sbx-ht-002", "name": "Sandbox Mobile Operator 2", "country_iso": "HTI", "...": "..." },
{ "id": "sbx-ht-001", "name": "Sandbox Mobile Operator 1", "country_iso": "HTI", "...": "..." }
],
"products": [
{
"id": "sbx-product-002",
"name": "200 TEST",
"display_price": "2 USD",
"display_destination_amount": "200 TEST",
"price_retail_amount": 2,
"price_retail_unit": "USD",
"price_wholesale_amount": 1.8,
"price_wholesale_unit": "USD",
"service_name": "Mobile",
"subservice_name": "Airtime",
"promotions": [],
"operator": { "id": "sbx-ht-002", "name": "Sandbox Mobile Operator 2", "country_name": "Haiti", "country_iso": "HTI" }
},
{ "id": "sbx-product-004", "name": "1000 TEST", "display_price": "10 USD", "...": "..." },
{ "id": "sbx-product-006", "name": "2000 TEST", "display_price": "20 USD", "...": "..." }
],
"environment": "sandbox"
}
}
Errors: 404 OPERATOR_NOT_FOUND, 422 VALIDATION_ERROR (missing or invalid field; see details), 403 INSUFFICIENT_SCOPE (token without topup:read), 502 PROVIDER_ERROR (Production).
POST /mobile-recharge/orders
Order creation. Registers a recharge order and returns the transaction_id generated by Ecovoy. It does not execute the recharge and does not debit the balance: to execute it, call /mobile-recharge/confirm. Scope: topup:write.
| Field / header | Type | Description |
|---|---|---|
Idempotency-Key header required | string ≤ 100 | A new unique value for each order. See Idempotency. |
mobile_number required | string | International format, e.g. +50944101111. |
product_id required | string ≤ 50 | A products[].id from the last /lookup or /operator-switch response for this number. |
external_ref_id required | string ≤ 100 | Reference of this transaction in your system, e.g. your order number ORDER-2026-000123. Must be different for each order (unique per application in the sandbox, per Ecovoy account in Production). |
external_customer_id | string ≤ 100 | Optional. Id of the end customer in your system. |
Other body fields are ignored.
One external_ref_id per transaction
Send, in external_ref_id, the id that your system already uses for the sale — the order, cart or invoice number. Each order sent to Ecovoy has its own external_ref_id:
- New purchase → new
external_ref_id, even for the same customer, number and product. - Retry of the same purchase → same
external_ref_id(and sameIdempotency-Keyand body). Ecovoy never creates two orders with the sameexternal_ref_id. - Store the
transaction_idreturned by Ecovoy next to yourexternal_ref_id. Use thetransaction_idfor every later call; use theexternal_ref_idto find the operation in your system (it comes back in every response and inGET /transactions). - Do not use random values generated at send time: the value must point to a record in your system.
Your system Ecovoy API
------------------------------- -------------------------------------------------
Order #123 (customer pays $2) -> POST /orders external_ref_id: "ORDER-2026-000123"
<- transaction_id: "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab"
Order #124 (same customer) -> POST /orders external_ref_id: "ORDER-2026-000124"
<- transaction_id: "sbx_01jcz6a1b2c3d4e5f6g7h8j9kk"
Retry of order #124 (timeout) -> POST /orders external_ref_id: "ORDER-2026-000124"
(same Idempotency-Key and body)
<- same transaction_id, no new order
Save both ids together: ORDER-2026-000123 <-> sbx_01jcz5k8v3m2q9w7e4r6t1y0ab
Result of the order
- Production: the order is created with status
PENDINGand must be confirmed beforeconfirmation_expiration_date(15 minutes). After that it can no longer be confirmed. - Sandbox: the result is simulated by the last digits of
mobile_number. Use a number ending in1111to test the complete order → confirm flow.
| Sandbox number ends with | status returned by /orders | Next step |
|---|---|---|
1111 | PENDING | Call /confirm (→ CONFIRMED) or, instead, /cancel-transaction (→ CANCELLED). Same behaviour as Production. |
0000 | FAILED, with failure_reason | None. Test your failure handling. |
| anything else | COMPLETED | None: the simulated recharge is already final, and /confirm returns 409 TRANSACTION_NOT_PENDING. |
curl -X POST https://api.ecovoy.com/api/v2/mobile-recharge/orders \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 3f6c1e9a-7b2d-4c8e-9a51-0d2f4b6e8c10" \
-d '{"mobile_number": "+50944101111", "product_id": "sbx-product-002", "external_ref_id": "ORDER-2026-000123", "external_customer_id": "CUSTOMER-001"}'
<?php
// Generate the key ONCE per order and store it before sending,
// so a retry after a network error reuses it.
$idempotencyKey = bin2hex(random_bytes(16));
$body = json_encode([
'mobile_number' => '+50944101111',
'product_id' => 'sbx-product-002', // from /lookup or /operator-switch
'external_ref_id' => 'ORDER-2026-000123', // required: your reference for THIS order
'external_customer_id' => 'CUSTOMER-001', // optional
]);
$ch = curl_init('https://api.ecovoy.com/api/v2/mobile-recharge/orders');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
'Idempotency-Key: ' . $idempotencyKey,
],
CURLOPT_POSTFIELDS => $body,
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$transactionId = $response['data']['transaction_id']; // store it: you need it for /confirm
import { randomUUID } from 'node:crypto';
// Generate the key ONCE per order and store it before sending,
// so a retry after a network error reuses it.
const idempotencyKey = randomUUID();
const res = await fetch('https://api.ecovoy.com/api/v2/mobile-recharge/orders', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
'Idempotency-Key': idempotencyKey,
},
body: JSON.stringify({
mobile_number: '+50944101111',
product_id: 'sbx-product-002', // from /lookup or /operator-switch
external_ref_id: 'ORDER-2026-000123', // required: your reference for THIS order
external_customer_id: 'CUSTOMER-001', // optional
}),
});
const { data: order } = await res.json();
const transactionId = order.transaction_id; // store it: you need it for /confirm
HTTP/1.1 201 Created
Content-Type: application/json
X-Request-Id: req_7d2c4e1a9b3f4e6d8a0c2b4d6f8e0a1c
{
"data": {
"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab",
"external_id": "ext_01jcz5k8v3m2q9w7e4r6t1y0ac",
"mobile_number": "+50944101111",
"status": "PENDING",
"retail_amount": 2,
"retail_unit": "USD",
"formatted_amount": "2 USD",
"service_name": "Mobile",
"subservice_name": "Airtime",
"operator_name": "Sandbox Mobile Operator 2",
"operator_country": "Haiti",
"product_id": "sbx-product-002",
"product_name": "200 TEST",
"product_type": "FIXED_VALUE_RECHARGE",
"external_ref_id": "ORDER-2026-000123",
"external_customer_id": "CUSTOMER-001",
"environment": "sandbox",
"benefits": [
{
"additional_information": null,
"amount": { "base": 200, "promotion_bonus": 0, "total_excluding_tax": 200, "total_including_tax": 200 },
"type": "CREDITS",
"unit": "TEST",
"unit_type": "CURRENCY"
}
],
"promotions": [],
"can_retry": false,
"is_reverted": false,
"account_topup_reference": null,
"payment_reference": null,
"receipt_number": null,
"invoice_number": null,
"payment_method": null,
"created_at": "2026-11-13T14:05:12.000000Z",
"confirmation_expiration_date": null,
"creation_date": "2026-11-13T14:05:12.000000Z",
"confirmation_date": null,
"failure_reason": null
}
}
In Production the response is 200 and adds "success": true next to data. The data has the same fields (plus mobileNumber, a legacy copy of mobile_number), with "environment": "production" and a filled confirmation_expiration_date:
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"transaction_id": "48213097561",
"external_id": "TOPUP-6734a1f2c9e0b",
"mobileNumber": "+50944103000",
"mobile_number": "+50944103000",
"status": "PENDING",
"retail_amount": 2,
"retail_unit": "USD",
"formatted_amount": "2 USD",
"operator_name": "…",
"product_id": "…",
"product_name": "…",
"external_ref_id": "ORDER-2026-000123",
"external_customer_id": "CUSTOMER-001",
"environment": "production",
"created_at": "2026-11-13T14:05:12.000000Z",
"confirmation_expiration_date": "2026-11-13T14:20:12.000000Z",
"confirmation_date": null,
"...": "same fields as the sandbox response"
},
"success": true
}
Errors
| HTTP | code | When |
|---|---|---|
| 400 | IDEMPOTENCY_KEY_REQUIRED | Idempotency-Key missing or longer than 100 characters. |
| 409 | IDEMPOTENCY_CONFLICT | Sandbox: key already used with a different body. |
| 409 | DUPLICATE_EXTERNAL_REF_ID | The external_ref_id is already used by another order. details.transaction_id is that order. |
| 422 | VALIDATION_ERROR | Invalid mobile_number, missing product_id or external_ref_id, etc. See details. |
| 422 | PRODUCT_NOT_FOUND | Sandbox: product_id is not a product for this number. |
| 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. Retry with the same Idempotency-Key and body. |
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"success": false,
"error": {
"code": "IDEMPOTENCY_KEY_REQUIRED",
"message": "A valid Idempotency-Key header (max 100 chars) is required.",
"request_id": "req_0f1e2d3c4b5a4968a7b6c5d4e3f2a1b0"
}
}
POST /mobile-recharge/confirm
Execution. Executes the recharge of an order created by /orders. Send the transaction_id returned by Ecovoy. Scope: topup:write.
- Confirmation is a separate step from order creation. It never creates a new order; it acts only on the existing
transaction_id. - Only a
PENDINGorder can be confirmed. A second confirmation of the sametransaction_iddoes not execute the recharge again: it is rejected. If you lose the response of a confirmation, do not create a new order; checkGET /transactions/{transaction_id}. - Returns
404 NOT_FOUNDif the transaction does not belong to your application (sandbox) or account (production).
| Field | Environment | Description |
|---|---|---|
transaction_id required | Sandbox and Production | The transaction_id returned by /orders. |
amount required | Production | The retail_amount returned by /orders. |
converted_retail_amount required | Production | The retail_amount returned by /orders. A different value is rejected. |
converted_currency required | Production | The retail_unit returned by /orders (your wallet currency, 3 letters). |
Sandbox
- A
PENDINGorder becomesCONFIRMEDand the transaction is returned (200). - An order that is not
PENDINGreturns409 TRANSACTION_NOT_PENDINGwith the current status indetails.status.
Production
- Executes the recharge and debits the balance of the account that owns the application.
- The order must be
PENDINGand not expired (confirmation_expiration_date). - The response body of this endpoint in Production does not use the standard V2 envelope yet. Do not parse it to decide the result: check
GET /transactions/{transaction_id}until the status is final. Known error responses:400with"type": "insufficient_balance",403whenconverted_currencyis not your wallet currency,422 VALIDATION_ERRORfor missing fields.
# Sandbox
curl -X POST https://api.ecovoy.com/api/v2/mobile-recharge/confirm \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab"}'
# Production: also send the amount and currency returned by /orders
curl -X POST https://api.ecovoy.com/api/v2/mobile-recharge/confirm \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"transaction_id": "48213097561", "amount": 2, "converted_retail_amount": 2, "converted_currency": "USD"}'
<?php
// $order = the "data" object returned by POST /mobile-recharge/orders
$body = ['transaction_id' => $order['transaction_id']];
if ($order['environment'] === 'production') {
$body += [
'amount' => $order['retail_amount'],
'converted_retail_amount' => $order['retail_amount'],
'converted_currency' => $order['retail_unit'],
];
}
$ch = curl_init('https://api.ecovoy.com/api/v2/mobile-recharge/confirm');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $token, 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$result = json_decode(curl_exec($ch), true);
// order = the "data" object returned by POST /mobile-recharge/orders
const body = { transaction_id: order.transaction_id };
if (order.environment === 'production') {
Object.assign(body, {
amount: order.retail_amount,
converted_retail_amount: order.retail_amount,
converted_currency: order.retail_unit,
});
}
const res = await fetch('https://api.ecovoy.com/api/v2/mobile-recharge/confirm', {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
const result = await res.json();
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab",
"status": "CONFIRMED",
"mobile_number": "+50944101111",
"product_id": "sbx-product-002",
"environment": "sandbox",
"...": "same fields as the order response"
}
}
HTTP/1.1 409 Conflict
Content-Type: application/json
{
"success": false,
"error": {
"code": "TRANSACTION_NOT_PENDING",
"message": "Only pending transactions can be confirmed or cancelled.",
"details": { "status": "CONFIRMED" },
"request_id": "req_5e4d3c2b1a0f4e9d8c7b6a5f4e3d2c1b"
}
}
POST /cancel-transaction
Cancellation. Cancels an order created by /mobile-recharge/orders that has not been sent to /mobile-recharge/confirm. The order becomes CANCELLED and can no longer be confirmed. Nothing is charged. Scope: topup:write. Available in Sandbox and Production.
| Field | Type | Description |
|---|---|---|
transaction_id required | string | The transaction_id returned by /orders. |
- Only before
/confirm. Once you call/confirmfor atransaction_id, that order can no longer be cancelled, even while it is stillPENDING(recharge in progress) or if the confirmation was rejected. - Cancel and confirm exclude each other: if both are sent for the same order, only the first one is accepted.
- Use it when your customer gives up before paying, or when a retry created an extra order (see Idempotency).
- Production: a cancelled order is moved out of the active transactions; after cancelling,
GET /transactions/{transaction_id}returns404. Keep the cancellation response if you need the record.
{
"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab"
}
{
"data": {
"transaction_id": "sbx_01jcz5k8v3m2q9w7e4r6t1y0ab",
"status": "CANCELLED",
"...": "same fields as the order response"
}
}
Errors
| HTTP | code | When |
|---|---|---|
| 404 | NOT_FOUND | The transaction does not exist, does not belong to your application (sandbox) or account (production), or was already cancelled (production). |
| 409 | CONFIRMATION_ALREADY_REQUESTED | Production: /confirm was already called for this order. |
| 409 | TRANSACTION_NOT_PENDING | The order is not PENDING (already confirmed, completed, failed or cancelled). details.status has the current status. In the sandbox this is also the answer after a confirmation. |
| 422 | VALIDATION_ERROR | transaction_id missing. |
In the sandbox, use a number ending in 1111 to create a pending order you can cancel.