Retrieve balance - SOAP API

This command will return the number of credits available on your account.

If you simply want to monitor your account balance, you can also receive SMS and email notices when your account balance reaches a certain amount. This can be configured within your Developers’ Central account.


Command

getbalance

Parameters

You need to supply the authentication parameters that are outlined in the Getting Started guide.


Examples

All examples below are for the document/literal based server.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.clickatell.com/soap/document_literal/webservice">
	<SOAP-ENV:Body>
		<ns1:getbalance>
		<api_id>123456</api_id>
		<user>MyUsername</user>
		<password>MyPassword</password>
		</ns1:getbalance>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Code Samples:

PHP:

<?php
 $oClient = new SoapClient(
 	'http://api.clickatell.com/soap/document_literal/webservice?wsdl',
	 array(
		 'trace' => true,
		 'keep_alive' => true
	 )
 );
 
 // Query balance
 $aResult = $oClient->getbalance(
	 array(
		 'api_id' => '123456',
		 'user' => 'MyUsername',
		 'password' => 'MyPassword',
	 )
 );
 
 echo '<pre>' . print_r($aResult,true) . '<
'; ?>

API Responses

Example Response:

Successful API response:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.clickatell.com/soap/document_literal/webservice">
	<SOAP-ENV:Body>
		<ns1:getbalanceResponse>
		<return>Credit: 1500.806</return>
		</ns1:getbalanceResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Error response:

><?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.clickatell.com/soap/document_literal/webservice">
	<SOAP-ENV:Body>
		<ns1:getbalanceResponse>
		<return>ERR: 001, Authentication failed</return>
		</ns1:getbalanceResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Return Format:

Successful API response:<

Credits: <balance>

Error response:

ERR: <error code>, <error description>