Loader

Authentication with Session IDs


Overview

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 after which 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: 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.

1
2
3
4
5
6
7
8
9
10

<?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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

<?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

1
2
3
4
5
6
7
8

<?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

1
2
3
4
5
6
7
8

<?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>

 

Did you find this information informative?

Other Resources

Ask the Community

Visit Stack Overflow to join our community of developers and find the answer you need

Contact Support

Contact our support team and one of our agents will be in touch with you to answer any questions you have