e Ecovoy Developers
ecovoy.com Log in

Authentication

API V2 uses the OAuth 2.0 client credentials flow: your application exchanges its client_id and client_secret for a short-lived access_token, and sends that token on every call.

Three different things

ItemWhat it identifiesWhere it is used
Ecovoy login (email + password)You, the personOnly to sign in to ecovoy.com and this portal. Never send it to the API.
client_id + client_secretYour application, in one environmentOnly on POST /oauth/token, from your server.
access_tokenA temporary authorization for your applicationThe Authorization: Bearer header of every API call.

1. Getting client_id and client_secret

  1. Log in with your Ecovoy account.
  2. Go to Dashboard → My applications and open (or create) an application.
  3. Click Generate sandbox credentials. For Production, the application must first be approved by an Ecovoy administrator.
ValueSandbox prefixProduction prefix
client_idecv_test_ecv_live_
client_secretecvs_test_ecvs_live_
access_tokenecvat_test_ecvat_live_

The client_secret is displayed only once, right after generation. Ecovoy stores only a hash of it and cannot show it again. Generating new credentials immediately revokes the previous pair and every token issued with it.

2. Requesting an access_token

POST https://api.ecovoy.com/api/v2/oauth/token — body as application/x-www-form-urlencoded or JSON.

ParameterRequiredDescription
grant_typeYesAlways client_credentials.
client_idYes*Your client ID.
client_secretYes*Your client secret.
scopeNoSpace-separated subset of your scopes. Omit it to receive every scope your account is entitled to.

* Or send them with HTTP Basic authentication (client_id:client_secret).

# Alternative: HTTP Basic authentication (client_id:client_secret)
curl -X POST https://api.ecovoy.com/api/v2/oauth/token \
  -u "$ECOVOY_CLIENT_ID:$ECOVOY_CLIENT_SECRET" \
  -d grant_type=client_credentials \
  -d "scope=balance:read topup:read"
Response · 200
{
  "access_token": "ecvat_test_9f2c...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "balance:read topup:read",
  "environment": "sandbox"
}

Errors on this endpoint follow the OAuth 2.0 format ({"success": false, "error": "...", "error_description": "..."}). See Error codes.

3. Using the token

Send the token in the Authorization header. Never put credentials or tokens in URLs or query strings.

curl https://api.ecovoy.com/api/v2/balance \
  -H "Authorization: Bearer $ECOVOY_ACCESS_TOKEN"

The token alone determines the application, the owner account and the environment. The API never accepts organization_id, application_id or an environment from the request body.

4. Expiration

<?php
// Reuse the token until shortly before it expires.
function ecovoyToken(): string
{
    static $cached = null;
    if ($cached && $cached['expires_at'] > time() + 60) {
        return $cached['access_token'];
    }
    $ch = curl_init('https://api.ecovoy.com/api/v2/oauth/token');
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POSTFIELDS => http_build_query([
            'grant_type'    => 'client_credentials',
            'client_id'     => getenv('ECOVOY_CLIENT_ID'),
            'client_secret' => getenv('ECOVOY_CLIENT_SECRET'),
        ]),
    ]);
    $t = json_decode(curl_exec($ch), true);
    $cached = ['access_token' => $t['access_token'], 'expires_at' => time() + $t['expires_in']];
    return $cached['access_token'];
}

5. Scopes and permissions

Scopes limit what a token can do. They follow the permissions your Ecovoy account already has: a token only receives the scopes your account is entitled to, and the permission is checked again on every call. If a permission is removed from your account, the related calls stop working right away.

ScopeAllows
account:readRead the application and account context of the token.
balance:readRead the account balance.
transactions:readList and read transactions.
topup:readLook up mobile operators and top-up products.
topup:writeCreate mobile top-up orders.

Calling an endpoint without the required scope returns 403 with "code": "INSUFFICIENT_SCOPE". Your application page in the dashboard shows which scopes your account currently has.

6. Environments

Sandbox

Test credentials (ecv_test_). Simulated responses and a simulated balance. No real operations, no charges, no providers called.

Production

Live credentials (ecv_live_), available only after manual approval by an Ecovoy administrator. Uses your real Ecovoy account and balance.

Security checklist