Menu
Introduction Getting started SMS Promotional - Large campaigns Transactional - Basic Transactional (Alerts) - Virtual Number Route Transactional (Alerts) - Priority Routing Transactional (OTPs & Alerts) - Special route International route to Nigeria International route to Other Countries SMS DLR SMS DLR Webhooks Voice Voice OTP Voice Broadcasts Voice DLR Units Transfer Units to Sub-Account Transfer Units to Other Account Check Units Balance Sender IDs Register Sender IDs Check Sender ID status Categories Add Customer Remove Customer Virtual Number Inbox webhook Carrier Billing Run USSD Query Run Shortcode Query Query Status Carrier Callback Tools Create Sub-Account Check DND Status Check Service Status 3rd-party integrations ZOHO
Check SMS Units Balance The API is used when you want to programatically check your sms units balance.
GET
https://api.textng.xyz/smsbalance/?key=YOUR-ACCOUNT-KEY&checkbalance=1
PHP code
<?php
  // Variables
  $key="YOUR-ACCOUNT-KEY";
  $arrContextOptions=array(
        "ssl"=>array(
            "verify_peer"=>false,
            "verify_peer_name"=>false,
        ),
    );
    $data = file_get_contents("https://api.textng.xyz/smsbalance/?key=$key&checkbalance=1", false, stream_context_create($arrContextOptions));
    $decode = json_decode($data);
    $extracted_data = $decode->D->details;
    foreach ($extracted_data as $extracted_data_info) {
        echo $key = $extracted_data_info->key;
        echo $unitsbalance = $extracted_data_info->unitsbalance;
        echo $timechecked = $extracted_data_info->time;
        echo $status = $extracted_data_info->status;
    }
?>
Parameters
Parameters Example Description
Key xxxxxx-xxxxx-xxxxx This can be found in the Developers page of your dashboard. The key authorizes the transaction.
Responses
Your transaction response will appear in JSON format as shown below.
Successful (JSON)
{
    "D":{
        "details":[{
            "key":"XXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "unitsbalance":"XXX",
            "time":"2000-01-01 01:10:15",
            "status":"successful"
            }]
        }
    }
Error - Invalid balance code (JSON)
{
    "D":{
        "details":[
        {
            "status":"invalid-balance-code"
        }]
    }
}
Error - Invalid key (JSON)
{
    "D":{
        "details":[
            {
            "status":"key-invalid"
            }
        ]
    }
}