Get a Free WhatsApp Business Account – Includes Onboarding, API Access & Sandbox. Apply Now!

SMS API Documentation

Base URL

Authkey.io's GET APIs are exclusively served over HTTPS. This ensures that all data transmitted between your application and Authkey.io's servers is encrypted and protected.

Sample API CodesSMS API Documentation

Base SMS API URL:

Sending SMS using Authkey APIs is a breeze and lightning fast. You can simply pass the message body, message sender, mobile number & authkey in the API request to send sms instantly.

For Sending SMS in India

*For Users in India, due to DLT rules, you can setup your Principle Entity id & DLT Template id in the authkey portal by uploading DLT template CSV file or entering the DLT details one-by-one in the DLT Setup menu. Alternately, you can skip the DLT Setup and directly pass the entity & template ids in the API request itself:

SMS API with message template

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&sms=Hello, your OTP is 1234&sender=SENDERID&pe_id=ENTITY_ID&template_id=DLT_TEMPLATE_ID

*Note : If message content is Unicode kindly add parameter &is_unicode=1

SMS Templates:

You can also create templates in the authkey portal and use the template id in the API request. Templates are necessary when you need dynamic contents in your message text. For example, to send an OTP message, you can create a template as below:

Dear {#name#} , your otp is {#otp#} Authkey automatically adds your template dynamic values as API parameters and you can use them to change the content delivered to each recepient.

Example usage for above template, assuming template id generated is 1001

SMS API with SID

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&sid=1001&name=Twinkle&otp=1234

Here, 'name' and 'otp' parameters are auto-added to the API and their values shall be replaced in the template body {...}

You can also create Voice and Email templates and use them in the above API for parallel or fallback usages.

Parallel Usage:

If you wish to send both voice call and sms message to the recepientmobile, you can do that using below API:

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&sms=Hello, your OTP is 1234&sender=SENDERID&voice=Hello, your otp is 1234

*Note : If message content is Unicode kindly add parameter &is_unicode=1

Use Fallback:

If you wish to trigger fallback only if sms delivery fails, you can do that by using below API:

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&sms=Hello, your OTP is 1234&sender=SENDERID&fb1voice=Hello, your otp is 1234

*Note : If message content is Unicode kindly add parameter &is_unicode=1

Send SMS in Other Country (International):

Example Usage:

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&sms=Hello, your OTP is 1234&sender=SENDERID
Events:

Events are combinations of templates which you can create on the Authkey portal. Event definitions will include parallel sendings, fallback channels and setting up of requiredness of dynamic parameters in the chosen templates. Once created, you will have an event-id, which can be used to trigger the event using below API:

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&eid=EventId

Event APIs are generally shorter than all other APIs and can include parallel as well as fallback mechanisms on all the three channels.

All the dynamic content of the templates in an event shall be added automatically as API parameters and can be used to replace the dynamic values.

*Multiple templates with same dynamic values will be considered a single value.

While creating an event, you will get an option to choose which dynamic values are mandatory in the API request.

For example if you have 3 templates, one each for sms, voice and email as below:

SMS: Dear {#name#} , your otp is {#otp#}

Voice: Thank you for showing interest, your otp is {#otp#}

Email:

  • Subject: OTP from {#company#}
  • Body: Dear {#name#}, Thanks for choosing us. Your OTP is {#otp#}.

If we create an event using above three templates, the dynamic values shall be: name, otp & company Corresponding API request shall be:

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&email=RecepientEmail&country_code=CountryCode&eid=EventId&name=Ashish&otp=1234&company=Datagen

GET SMS API

https://api.authkey.io/request?authkey=AUTHKEY&mobile=RecepientMobile&country_code=CountryCode&sms=Hello, your OTP is 1234&sender=SENDERID&pe_id=ENTITY_ID&template_id=DLT_TEMPLATE_ID

Query Params

authkeyAUTHKEY
mobileRecepientMobile
country_codeCountryCode
smsHello, your OTP is 1234
senderSENDERID
pe_idENTITY_ID
template_idDLT_TEMPLATE_ID

Sample Code


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://console.authkey.io/restapi/requestjson.php',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>' {
    "country_code": "91",
    "mobile": "xxxxx",
    "sid": "**"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic <Api_Key>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

POST SMS API

POST sendSMS-SID

https://console.authkey.io/restapi/requestjson.php

send sms using sms template id created on authkey

Request Headers

Content-Typeapplication/json
AuthorizationBasic <Api_Key>
= Your authkey portal authkey

Body raw

{
    "country_code": "91",
    "mobile": "xxxxx",
    "sid": "**"
}

Sample Code


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://console.authkey.io/restapi/requestjson.php',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>' {
    "country_code": "91",
    "mobile": "xxxxx",
    "sid": "**"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic <Api_Key>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

POST sendSMS-SMS

https://console.authkey.io/restapi/requestjson.php

send sms using full content that you want to send . content should be approved on dlt platform

Request Headers

Content-Typeapplication/json
AuthorizationBasic <Api_Key>
= Your authkey portal authkey

Body raw

{
    "country_code": "91",
    "mobile": "xxxxx",
    "sid": "**"
 }

Sample Code


<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://console.authkey.io/restapi/requestjson.php',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>' {
    "country_code": "91",
    "mobile": "xxxxx",
    "sender": "**",
    "pe_id":"****",
    "template_id":"******"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic <Api_Key>'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;