Getting Started with Alcodes

With this page you will get started with Alcodes. In no time, you'll be up and running on the dot!


Introduction to Alcodes Api

You can use these APIs for sending Transactional and OTP SMS to single or multiple list of numbers and performing other actions like getting your balance information, getting approved senderId list, group List etc.

We have language bindings in cURL, Java, .NET, PHP, Python, Node and other programmjng languages. You can view the ready code in different languages in the code samples section.


Prerequisite

To start sending SMS using given APIs, you need:

  1. API_KEY :-- This is your account authentication id and is unique for every user account. It is generated after signup. You can get the API_KEY from dashboard menu link "Get API key" once you are logged in to alcodes. You can also change the ApiKey as and when required using the "Re-Generate Api Key" Option

  2. SENDER_ID :-- Sender ID is your identity from which the message is sent. For example, when you receive a general SMS from your friend, their name is displayed. Similarly, in case of Sender ID, the ID that you choose on the panel, or the one that is given to you, serves as your identity while sending messages.

Sender ID for Promotional SMS is numeric and fixed from the operator.But for sending Transactional and OTP Sms, You need to Apply for a valid Sender Id from the dashboard Menu 'Sender Ids'.

Sender ID is 6 character, alphabetic in India,example NOTIFY, MSGIND. You also need to upload a valid document explaining the use of the sender Id, For example If you are applying sender Id for use in a school, you can upload the school registration or identity document, Or if you are using it in your application for sending transaction notifications or OTP to users, you can upload your company registration or service document. This is just to ensure that your sender Id is not a copy of some other product or service and will be used solely by you for the mentioned purpose.

The default sender Id for all users is AUTHMS, which can be used for OTP verification SMS.

API Reference

https://www.alcodes.com/api

Input Parameters

Input Parameters
user Your unique Api Key generated for you (view the Prerequisite section above for details) . Just replace the [API_Key] with your actual Api key.
countryCode Where messages will be delivered. Default is IN for India.
smsSenderId Sender Identity from which messages are sent (view the Prerequisite section above for details)
is_otp Keep it true if you are sending an OTP (One Time Password) Sms because or keep it false for normal transactional sms
message Message text to send.
phoneNumbers Comma separated list of mobile numbers without country code.
smsTypeId This parameter denotes the type of message. Its value should be from below list.
  1. for Normal Sms
  2. for Flash Sms
  3. for Unicode (Hindi or other language) Sms
  4. for Unicode + Flash Sms
walletType Keep it default to DOMESTIC

Output Parameters :

Output Parameters
status This field contains the message submission status. It is 'success' if the sms is sent successfully and it will be 'fail' if there was an error sending the sms.
data This field contains the data of submitted or invalid mobile numbers. This is usefull when you have given multiple list of comma seperated numbers in the sms-compose api. It has below 2 sections :--
invalidMobileNumbers : It shows the list of invalid mobile numbers from the given list.
msgid : It shows all successful sent mobile numbers and there messageId.
error If the status is false, then this field shows the error reason otherwise it is null.
payload This field shows any extra information given by the SMSC, In most cases this is null.

[POST] Sms-Compose

/sms-compose

Compose New Sms Campaign.

					
/*Request Sample */

https://www.alcodes.com/api/sms-compose -- user [API_KEY] :passwd   
-H 'Cache-Control: no-cache' -H 'content-type: multipart/form-data' 
-F countryCode=IN -F smsSenderId=AUTHMS -F is_otp=true -F message=test-sms 
-F phoneNumbers=9829000044 -F smsTypeId=1 -F walletType=DOMESTIC

/* Api Response */

{
  "status": "success",
  "data": {
   "invalidMobileNumbers": [],
   "msgid": {
     "9829000044": 36
    }
   },
  "error": null,
  "payload": null
}
		

[GET] Sms-Compose

/sms-compose

 
/** Request Sample */
https://www.alcodes.com/api/sms-compose?message=test+sms&phoneNumbers=9829000044&countryCode=IN&smsSenderId=AUTHMS&smsTypeId
=1&otp=true&walletType=DOMESTIC&username=[API_KEY]&password=passwd

/** Api Response */
{
  "status": "success",
  "data": {
   "invalidMobileNumbers": [],
   "msgid": {
     "9829000044": 36
    }
   },
  "error": null,
  "payload": null
}	
		

[GET] User-Balance

/user-balance

This Api is used for retrieving User current sms credit Balance.

 
/** Request Sample */
https://www.alcodes.com/api/user-balance --user [API_KEY]:passwd  
-H 'content-type: multipart/form-data'
 
/** Api Response */
{
  "status": "success",
  "data": 100,
  "error": null,
  "payload": null
}
		

[GET] SenderId-List

/user/senderid/list

This Api is used for retrieving list of sender Ids approved for the user.

 
/**  Request Sample */
http://www.alcodes.com/api/user/senderid/list --user [API_KEY]:passwd  
-H 'content-type: multipart/form-data'
 
/** Api Response */
{
  "status": "success",
  "data": [
    {
      "id": 2,
      "user": null,
      "senderKey": "TESTAP",
      "file": null,
      "type": "TRAN",
      "requestedAt": 1493192142000,
      "approvedAt": 1493192160000,
      "status": "approved",
      "countryCode": "IN"
    }
  ],
  "error": null,
  "payload": null
}

[GET] Group-List

/user/groups

This Api is used for retrieving list of groups created by the user.

 
/** Request Sample */
http://www.alcodes.com/api/user/groups --user [API_KEY]:passwd  
-H 'content-type: multipart/form-data'
 
/** Api Response */
{
  "status": "success",
  "data": [
    {
      "id": 3,
      "name": "alcodes",
      "countryCode": "IN",
      "mobileNumberCount": 355887,
      "groupEmpty": false
    }
  ],
  "error": null,
  "payload": null
}
											
		

Code samples for SMS compose post api

CURL

 
curl -X POST \
  https://www.alcodes.com/api/sms-compose \
  -H 'authorization: Enter basic authorization here' \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -H 'postman-token: 6d0a2902-c284-3b44-5b30-8749debaa086' \
  -F countryCode=IN \
  -F smsSenderId=AUTHMS \
  -F is_otp=true \
  -F message=test-sms \
  -F phoneNumbers=8949537689
  
		

PHP


<?php
$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->addForm(array(
  'countryCode' => 'IN',
  'smsSenderId' => 'AUTHMS',
  'is_otp' => 'true',
  'message' => 'test-sms',
  'phoneNumbers' => '8949537689'
), NULL);

$request->setRequestUrl('https://www.alcodes.com/api/sms-compose');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'postman-token' => '27e32dc2-ff66-30c4-c4e4-5adad49ff31c',
  'authorization' => 'Enter basic authorization here',
  'cache-control' => 'no-cache'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();

		

C#

	 
var client = new RestClient("https://www.alcodes.com/api/sms-compose");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "c7ee4432-b995-616b-c75e-f6e0ebf7d8cd");
request.AddHeader("authorization", "Enter basic authorization here");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
request.AddParameter("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW", "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"countryCode\"\r\n\r\nIN\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"smsSenderId\"\r\n\r\AUTHMS\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"is_otp\"\r\n\r\ntrue\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"message\"\r\n\r\ntest-sms\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"phoneNumbers\"\r\n\r\n8949537689\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

		

JAVA


OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"countryCode\"\r\n\r\nIN\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"smsSenderId\"\r\n\r\AUTHMS\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"is_otp\"\r\n\r\ntrue\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"message\"\r\n\r\ntest-sms\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"phoneNumbers\"\r\n\r\n8949537689\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--");
Request request = new Request.Builder()
  .url("https://www.alcodes.com/api/sms-compose")
  .post(body)
  .addHeader("content-type", "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW")
  .addHeader("cache-control", "no-cache")
  .addHeader("authorization", "Enter basic authorization here")
  .addHeader("postman-token", "fc379460-276a-64cd-699a-bb58cd33b4f1")
  .build();

Response response = client.newCall(request).execute();

	

JAVASCRIPT

 
var form = new FormData();
form.append("countryCode", "IN");
form.append("smsSenderId", "AUTHMS");
form.append("is_otp", "true");
form.append("message", "test-sms");
form.append("phoneNumbers", "8949537689");

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://www.alcodes.com/api/sms-compose",
  "method": "POST",
  "headers": {
    "cache-control": "no-cache",
    "authorization": "Enter basic authorization here",
    "postman-token": "235bd36d-5eb3-cbc8-84ff-b2da87381b39"
  },
  "processData": false,
  "contentType": false,
  "mimeType": "multipart/form-data",
  "data": form
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

	

NODE JS


var request = require("request");

var options = { method: 'POST',
  url: 'https://www.alcodes.com/api/sms-compose',
  headers: 
   { 'postman-token': '23657c18-c0d2-dc58-c20f-0c5e72398a3e',
     authorization: 'Enter basic authorization here',
     'cache-control': 'no-cache',
     'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
  formData: 
   { countryCode: 'IN',
     smsSenderId: 'AUTHMS',
     is_otp: 'true',
     message: 'test-sms',
     phoneNumbers: '8949537689' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

PYTHON

 
import requests

url = "https://www.alcodes.com/api/sms-compose"

payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"countryCode\"\r\n\r\nIN\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"smsSenderId\"\r\n\r\AUTHMS\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"is_otp\"\r\n\r\ntrue\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"message\"\r\n\r\ntest-sms\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"phoneNumbers\"\r\n\r\n8949537689\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
headers = {
    'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    'cache-control': "no-cache",
    'authorization': "Enter basic authorization here",
    'postman-token': "25303984-1446-5a56-d74c-e344975f2a79"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

					  

Postman Collection

click here to download the postman json collection file