Credit Check
Overview
Monitor your SMS account balance in real-time. Query the Credit Check API to retrieve your remaining account credit in euros before sending messages or bulk campaigns. This is essential for preventing failed shipments due to insufficient funds.
Use cases:
- Check balance before initiating SMS campaigns
- Implement automatic notifications when credit falls below a threshold
- Validate account status in application dashboards
- Prevent failed batch submissions due to low credit
Making a Request
Endpoint
GET https://secure.agiletelecom.com/services/sms/credit
Authentication
Choose one of three supported methods:
- Basic Auth: Provide your username and password encoded in the
Authorizationheader - API Key: Include your API key in the
X-Api-Keyheader - OAuth 1.1: Use OAuth 1.1 authentication in the
Authorizationheader
Code Examples
- cURL
- Python
- Node.js
- PHP
- Java
- C#
- Go
- Ruby
# Using API Key authentication
curl -X GET "https://secure.agiletelecom.com/services/sms/credit" \
-H "X-Api-Key: YOUR_API_KEY"
# Using Basic Auth authentication
curl -X GET "https://secure.agiletelecom.com/services/sms/credit" \
-H "Authorization: Basic $(echo -n 'username:password' | base64)"
import requests
# Using API Key
headers = {
"X-Api-Key": "YOUR_API_KEY"
}
response = requests.get(
"https://secure.agiletelecom.com/services/sms/credit",
headers=headers
)
data = response.json()
print(f"Your current credit: €{data['credit']}")
const axios = require('axios');
// Using API Key
const headers = {
'X-Api-Key': 'YOUR_API_KEY'
};
axios.get('https://secure.agiletelecom.com/services/sms/credit', { headers })
.then(response => {
console.log(`Your current credit: €${response.data.credit}`);
})
.catch(error => {
console.error('Error:', error.response?.data || error.message);
});
<?php
$apiKey = 'YOUR_API_KEY';
$ch = curl_init('https://secure.agiletelecom.com/services/sms/credit');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Api-Key: ' . $apiKey
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo "Your current credit: €" . $data['credit'];
} else {
echo "Error decoding response";
}
curl_close($ch);
?>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.json.JSONObject;
public class CreditCheck {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://secure.agiletelecom.com/services/sms/credit"))
.header("X-Api-Key", "YOUR_API_KEY")
.GET()
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
JSONObject json = new JSONObject(response.body());
System.out.println("Your current credit: €" + json.getDouble("credit"));
}
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
class CreditCheck {
static async Task Main() {
using (HttpClient client = new HttpClient()) {
client.DefaultRequestHeaders.Add("X-Api-Key", "YOUR_API_KEY");
try {
HttpResponseMessage response = await client.GetAsync(
"https://secure.agiletelecom.com/services/sms/credit");
string content = await response.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(content);
Console.WriteLine($"Your current credit: €{data.credit}");
} catch (Exception ex) {
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
package main
import (
"fmt"
"io"
"net/http"
"encoding/json"
)
type CreditResponse struct {
Credit float64 `json:"credit"`
}
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET",
"https://secure.agiletelecom.com/services/sms/credit", nil)
req.Header.Add("X-Api-Key", "YOUR_API_KEY")
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var data CreditResponse
json.Unmarshal(body, &data)
fmt.Printf("Your current credit: €%.3f\n", data.Credit)
}
require 'net/http'
require 'json'
uri = URI('https://secure.agiletelecom.com/services/sms/credit')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.path)
request['X-Api-Key'] = 'YOUR_API_KEY'
response = http.request(request)
data = JSON.parse(response.body)
puts "Your current credit: €#{data['credit']}"
Success Response (2XX)
When the request succeeds, the API returns your account balance in euros:
{
"credit": 10.324
}
| Field | Type | Description |
|---|---|---|
| credit | double | Account credit remaining (in euros) |
Error Response (5XX)
When a server-side error occurs:
{
"status": "error",
"message": "Number check service unavailable",
"code": 9
}
| Field | Type | Description |
|---|---|---|
| status | string | Always "error" for 5XX responses |
| message | string | Human-readable description of the server-side error |
| code | integer | Custom error code indicating the type of problem |
Error Codes
| Code | Description |
|---|---|
| 1 | Wrong credentials |
| 2 | Insufficient credit |
| 8 | Server error |
| 9 | Timeout |
| 100 | Source IP is not allowed |
Pro Tip
Implement credit monitoring in your application to automatically alert users when balance drops below a configurable threshold. This prevents unexpected service interruptions for high-volume SMS sending.
What's next?
- SMPP Protocol – Persistent connection protocol for high-volume messaging
- Inbound SMS – Receive SMS on your dedicated number
- MNP Lookup – Query mobile network information