Balance
Money balance & SMS credits
/v1/balanceDefault: money and smsCredits.total only. Exact decimal strings. Prepaid balance is booked funds, not a promise that all funds are spendable; holds and campaign reservations may restrict sending. For postpaid, balance is paid funds; request include=postpaid for available credit. Internal accounts return balance=null. No account ID can be supplied. SMS total spans scoped credits and does not imply eligibility for every destination. Each page is a fresh snapshot. Limited to one request per account per 10 seconds, in addition to general API limits.
/v1/balancecURL. The key is in the SENDSMS_API_KEY environment variable.
curl --max-time 30 --request GET \
--url 'https://api.sendsms.to/v1/balance' \
--header "X-API-Key: $SENDSMS_API_KEY"Node.js 18+ (built-in fetch).
const response = await fetch("https://api.sendsms.to/v1/balance", {
method: "GET",
headers: {
'X-API-Key': process.env.SENDSMS_API_KEY,
},
signal: AbortSignal.timeout(30000),
});
console.log(response.status, await response.text());Python 3.8+, standard library only.
import json
import os
import urllib.error
import urllib.request
request = urllib.request.Request(
"https://api.sendsms.to/v1/balance",
method="GET",
headers={
"X-API-Key": os.environ["SENDSMS_API_KEY"],
},
)
try:
with urllib.request.urlopen(request, timeout=30) as response:
print(response.status, response.read().decode("utf-8"))
except urllib.error.HTTPError as error:
print(error.code, error.read().decode("utf-8"))PHP with the cURL extension.
<?php
$ch = curl_init("https://api.sendsms.to/v1/balance");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SENDSMS_API_KEY'),
],
]);
$body = curl_exec($ch);
if ($body === false) {
throw new RuntimeException(curl_error($ch));
}
echo curl_getinfo($ch, CURLINFO_HTTP_CODE), PHP_EOL, $body, PHP_EOL;
curl_close($ch);Ruby 2.6+, standard library: net/http, uri.
require 'net/http'
require 'uri'
uri = URI('https://api.sendsms.to/v1/balance')
request = Net::HTTPGenericRequest.new('GET', false, true, uri.request_uri)
request['X-API-Key'] = ENV.fetch('SENDSMS_API_KEY')
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, open_timeout: 30, read_timeout: 30) { |http| http.request(request) }
puts "#{response.code} #{response.body}"Go, standard library.
package main
import (
"fmt"
"io"
"net/http"
"os"
"time"
)
func main() {
req, err := http.NewRequest("GET", "https://api.sendsms.to/v1/balance", nil)
if err != nil {
panic(err)
}
req.Header.Set("X-API-Key", os.Getenv("SENDSMS_API_KEY"))
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
fmt.Println(resp.StatusCode, string(data))
}.NET 6+ (HttpClient, top-level statements).
using System;
using System.Net.Http;
using System.Text;
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.sendsms.to/v1/balance");
request.Headers.Add("X-API-Key", Environment.GetEnvironmentVariable("SENDSMS_API_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");Java 11+ (java.net.http). File SendSmsExample.java.
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.UUID;
public class SendSmsExample {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sendsms.to/v1/balance"))
.timeout(Duration.ofSeconds(30))
.header("X-API-Key", System.getenv("SENDSMS_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
}
}Dart 2.12+, dart:io and dart:convert only.
import 'dart:convert';
import 'dart:io';
Future<void> main() async {
final client = HttpClient()..connectionTimeout = const Duration(seconds: 30);
final request = await client.openUrl('GET', Uri.parse('https://api.sendsms.to/v1/balance'));
request.headers.set('X-API-Key', Platform.environment['SENDSMS_API_KEY'] ?? '');
final response = await request.close().timeout(const Duration(seconds: 30));
final body = await response.transform(utf8.decoder).join();
print('${response.statusCode} $body');
client.close();
}#Parameters
| Field | Type | Description |
|---|---|---|
includeoptional | query · string | Optional comma-separated unique values: smsBreakdown,postpaid,account. Unknown, empty and duplicate values are rejected. postpaid is omitted for non-postpaid accounts. account adds snapshot time, account kind, payment mode, suspension status and balance meaning. |
limitoptional | query · integer | SMS scope page size; allowed only with include=smsBreakdown.minimum: 1maximum: 100default: 100 |
afteroptional | query · string | nextCursor from the previous page; allowed only with include=smsBreakdown. |
#Responses
200Current snapshot; Cache-Control: no-store
Response format
| Field | Type | Description |
|---|---|---|
moneyrequired | object | Monetary account snapshot calculated by SendSMS from its ledger. It is separate from SMS credits. |
money.balancerequired | string | null | Booked prepaid balance, or paid funds for postpaid. SendSMS returns a decimal string with 5 fractional digits in money.currency. This is not a spendable-funds promise: reservations and credit restrictions may apply. null for an internal account. |
money.currencyrequired | string | ISO 4217 currency code saved in the account settings by SendSMS. All monetary values in this money object use this currency; no client-side relabeling or implicit conversion.pattern: "^[A-Z]{3}$" |
money.postpaidoptional | object | Included only when include=postpaid is requested for a non-internal postpaid account. SendSMS calculates this object from the current billing-period limits and usage. Absence does not mean zero. |
money.postpaid.periodrequired | string | Billing month YYYY-MM calculated by SendSMS using the platform billing time zone. Not a Unix timestamp or the client device month.pattern: "^[0-9]{4}-[0-9]{2}$" |
money.postpaid.fixedLimitrequired | string | Configured fixed monthly credit limit. Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.fixedUsedrequired | string | Recorded usage of the fixed monthly limit. Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.fixedRemainingrequired | string | max(fixedLimit − fixedUsed, 0). Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.additionalLimitrequired | string | Additional credit granted for this billing period. Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.additionalUsedrequired | string | Recorded usage of the additional credit. Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.additionalRemainingrequired | string | max(additionalLimit − additionalUsed, 0). Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.availablerequired | string | fixedRemaining + additionalRemaining; excludes paid funds. Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
money.postpaid.totalAvailablerequired | string | money.balance + available; a calculated snapshot, not a reservation. Calculated/read by SendSMS. Decimal string with 5 digits in money.currency.pattern: "^-?[0-9]+\\.[0-9]{5}$" |
smsCreditsrequired | object | SMS quota snapshot maintained by SendSMS, separate from monetary funds. |
smsCredits.totalrequired | string | Sum of the account’s SMS credit quantities across scopes, calculated by SendSMS. Decimal string with 2 digits, in SMS credits, not currency or successfully delivered messages. Scope restrictions still apply.pattern: "^-?[0-9]+\\.[0-9]{2}$" |
smsCredits.itemsoptional | array<object> | Scope breakdown returned only with include=smsBreakdown. SendSMS returns at most limit items; an empty array means no matching rows on this page. |
smsCredits.items[].idrequired | string · uuid | UUID generated by the SendSMS database when the credit-balance scope row is created. Identifies that balance row, not a message or operator. |
smsCredits.items[].countryrequired | string | null | Country restriction stored for the credit scope, usually an ISO alpha-2 code. null means no country restriction on that row, not an unknown recipient country. |
smsCredits.items[].operatorIdrequired | string | null · uuid | Existing operator/provider UUID recorded in the scope by SendSMS. null means no operator restriction on this row. This ID does not itself identify the recipient’s current network. |
smsCredits.items[].operatorNamerequired | string | null | Operator/provider display name read from the SendSMS registry for operatorId; null when no name is available. Use operatorId for references, not this editable name. |
smsCredits.items[].quantityrequired | string | Stored remaining quota for this exact scope. SendSMS returns a decimal string with 2 fractional digits, in SMS credits.pattern: "^-?[0-9]+\\.[0-9]{2}$" |
smsCredits.items[].currencyrequired | string | Valuation currency stored with the SMS credit row. quantity remains a number of credits; this field does not turn credits into cash. |
smsCredits.nextCursoroptional | string | null · uuid | SendSMS copies the last returned row ID when another page exists. Pass it unchanged as after with include=smsBreakdown. null means no next page in this snapshot; not a new resource ID. |
asOfoptional | string · date-time | Present with include=account. SendSMS database statement timestamp of this balance snapshot, serialized as ISO 8601 UTC. Not the last top-up or message delivery time. |
accountKindoptional | string | With include=account: financial account classification stored by SendSMS. customer is a customer account; internal has no platform cash balance."customer" "internal" |
paymentModeoptional | string | With include=account: configured payment mode, prepaid or postpaid, read from SendSMS account settings."prepaid" "postpaid" |
billingSuspendedoptional | boolean | With include=account: SendSMS billing flag. true blocks new billable traffic; it does not mean this balance read failed. |
balanceTypeoptional | string | With include=account, computed by SendSMS: booked_prepaid = booked prepaid balance; paid_funds = paid postpaid funds, excluding credit; not_applicable = internal account with null money.balance."booked_prepaid" "paid_funds" "not_applicable" |
400Invalid parameters, including any account selector
Check required fields, value types and the request format.
Response format
| Field | Type | Description |
|---|---|---|
errorrequired | string | Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
messageoptional | string | Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
codeoptional | string | Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
statusCodeoptional | integer | Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |
401Missing, invalid, expired or revoked API key
Check the X-API-Key header and key status. Never expose the key in client-side code. The machine code is in the code field: api_key_missing or api_key_invalid.
Response format
| Field | Type | Description |
|---|---|---|
errorrequired | string | Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
messageoptional | string | Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
codeoptional | string | Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
statusCodeoptional | integer | Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |
403Key lacks balance.read; or the request came from an IP address not allowed for this key (ip_not_allowed)
Check API key permissions, account settings and channel availability.
Response format
| Field | Type | Description |
|---|---|---|
errorrequired | string | Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
messageoptional | string | Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
codeoptional | string | Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
statusCodeoptional | integer | Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |
404Account missing or archived
Check the resource ID and whether it belongs to the API key account.
Response format
| Field | Type | Description |
|---|---|---|
errorrequired | string | Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
messageoptional | string | Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
codeoptional | string | Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
statusCodeoptional | integer | Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |
429Rate limit; respect Retry-After
Reduce the request rate and delay retries. The general per-second limit: code = rate_limit_exceeded.
Response format
| Field | Type | Description |
|---|---|---|
errorrequired | string | Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
messageoptional | string | Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
codeoptional | string | Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
statusCodeoptional | integer | Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |
503Balance temporarily unavailable; respect Retry-After, never substitute zero
The service is temporarily unavailable. Before retrying an SMS submission, check whether the previous request was accepted.
Response format
| Field | Type | Description |
|---|---|---|
errorrequired | string | Error identifier or legacy human-readable text returned by SendSMS. Not every handler exposes a stable machine code here. Check HTTP status and documented identifiers; never parse translated prose as a permanent code. |
messageoptional | string | Optional explanation generated by SendSMS. Intended for people; wording/language may change. Absence means the handler supplied no separate explanation. |
codeoptional | string | Optional machine-readable code generated by SendSMS or its HTTP framework. Meaning depends on the operation; not a universal numeric provider code. |
statusCodeoptional | integer | Optional HTTP status number generated by the server framework for a framework-level error. The actual HTTP response status is authoritative. |