SMS API Authentication

The SMS API supports 2 different type of authentication mechanism for the API calls, they are:

  • HTTP Basic Authentication
  • Bearer Token Authentication

Either of these mechanism can be used to access SMS API as per your application requirement. All Code Snippets shown in the documentation, uses HTTP Basic Authentication.

The SMS API credentials are paired with your SMS project. You need to create a project to receive the API credentials. To create a project, log in to the EnableX portal and navigate to Projects > Create New Project. Alternatively, click the name of your project and navigate to the project dashboard to locate the access credentials: APP_ID and APP_KEY.

HTTP Basic Authentication

The SMS API supports HTTP Basic Authentication mechanism to authenticate the API calls. Each API call is validated via the Authentication header. To authenticate to the API, pass the following credentials in the Authorization header in the API call request:

  • Application ID or APP_ID as Username
  • Application Key or APP_KEY as Password
Authorization: Basic XXXXXXX
Content-Type: application/json

The Authorization header in this example contains a value XXXXX, which is a base64 encoded string of APP_ID:APP_KEY.

Bearer Token Authentication

SMS API also supports Bearer Token authentication. Using a Token, any number of API call can be made before it expires in 60 minutes since since its created.

Authorization: Bearer TTTTTTT
Content-Type: application/json

The Authorization header in this example contains a value TTTTTTT, which is a Token created using API Credentials i.e. APP_ID and APP_KEY through Token API.

Authentication Error

When authentication process fails, either while calling an API using Basic Auth/Expired Token or while creating a Token following error is returned:

"result" : "1",
"details" : "Authentication failed",
"desc" : "Authentication failed"

If the error is returned while calling api using Token, you must re-create a new token to retry.

Create Token API

If you are looking to use SMS API using Bearer Token, this API can be used to create a Token. The Token created can be used as Bearer Token in the Authorization Header for API requests.

Note that the API returns transactional Token with a validity of 60 minutes to access all SMS APIs. Any API call beyond the expiry time using the same Token will be denied. Therefore, you need to create another Token to continue using APIs.

This Token API call needs your Access Credentials i.e. APP-ID and APP-KEY.

  • API Route:
  • HTTP Request: POST
  • JSON Payload: Used as Raw Body
{ "app_id": "String",
"app_key": "String"
**Explanation of JSON Payload Keys**
|`app_id`|String. Required. Its Application ID of the SMS Project.|
|`app_key`|String. Required. Its Application Key of the SMS Project.|
**Request Example**
Content-Type: application/json
{ "app_id": "String",
"app_key": "String"

Response Example

{ "result": 0,
"token": "String"

Explanation of JSON Response

resultNumeric. 0 represents successful request.
tokenString. Its the token to be used in API call as Bearer Token.