SOAP API Authentication with Session IDs

The auth command can be used with the SOAP API to generate a session ID. Creating a session ID means that you can avoid having to re-send your username and password with every SOAP API request.

The session ID will expire after 15 minutes of inactivity; you will have to call this command again to create a new session ID. Alternatively, you can use the Ping command about every 10 minutes to ensure that the session ID is kept alive.

Note that any API command using a session ID will cause your session ID to remain active for another 15 minutes.

 

SOAP API Command

auth

 

auth Command Parameters

Parameter

Description

user

Your API username

password

Your API password

api_id

Your API ID

 

SOAP auth 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:auth>
			<api_id>123456</api_id>
			<user>MyUsername</user>
			<password>MyPassword</password>
		</ns1:auth>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

SOAP auth Code samples:

PHP:

<?php
$oClient = new SoapClient(
	'http://api.clickatell.com/soap/document_literal/webservice?wsdl',
	array(
		'trace' => true,
		'keep_alive' => true
	)
);

// Authenticate
$aResult = $oClient->auth(
	array(
		'api_id' => '123456',
		'user' => 'MyUsername',
		'password' => 'MyPassword'
	)
);

echo '<pre>' . print_r($aResult,true) . '</pre>';
?>

 

SOAP 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:authResponse>
			<return>OK: af25a6386301960c862278b980b02b29</return>
		</ns1:authResponse>
	</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:authResponse>
			<return>ERR: 001, Authentication failed</return>
		</ns1:authResponse>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

Return format

Successful SOAP API response:

OK: <session ID>

SOAP Error response:

ERR: <error code>, <error description>