Overview

To access the API, application should first authenticate using the credentials. The credentials have to be generated by the taxpayers and get the auth token issued. Same auth token is to be used to access subsequent APIs. Validity of the auth token will be 360 minutes. Any hits to this API within these 360 minutes will return the same token, hence there is no need to hit the API unless the token has expired. However, there is a provision to forcefully generate a new token within the last 10 minutes of expiry by calling this API with "ForceRefreshAccessToken" set to "True". On expiry, same authentication API needs to be invoked to issue new auth Token.

Sequence Diagram

The format and details of a sample API request is depicted in following table.

URL <URL>/api/auth

Content-Type

application/json

Method

POST

Request Header


Attributes
Description

client_id

client id to be provided by E-Invoice System

client_secret

client secret to be provided by E-Invoice System

Request Payload

Attributes Description
UserName Username of Tax payer as created on E-Invoice portal for API Integration
Password Password of Tax payer as in E-Invoice portal for API Integration Encrypt(password, EInvoice Public Key)
AppKey Any 32 character random unique id generated by user, identifying unique user session. App_key will be encrypted using Public key of E-Invoice using RSA algorithm
ForceRefreshAccessToken The value of this attribute to be set true, if client needs to refresh the token 10 minutes before expiry

Response Payload

Attributes Description
Status Status of the authentication request(values 1-Success and 0- Failure)
Data If Status is ‘1’
ClientId Client Id
UserName User Name
AuthToken Authorization token
Sek Session Encryption Key generated using AES 256(AES/ECB/PKCS7Padding) algorithm. Encrypted () with AppKey
TokenExpiry Token Expiry time. Date format is ‘yyyy-MM-dd HH:mm:ss ’
ErrorDetails If Status is ‘0’
ErrorCode Unique error code
ErrorMessage Error Description
InfoDtls Any additional message to be conveyed would be passed.

Sample JSON (Request)

Authentication Request

{
"data":{
"UserName":"testuser",
"Password":"<Password encrypted using eInvoice public key>",
"AppKey":"<AppKey encrypted using eInvoice public key>",
"ForceRefreshAccessToken": true

}
}

Sample JSON (Response)

Authentication Response (Success)

{
"Status": 1,
"Data": {
"ClientId": "testclientid",
"UserName": "testuser",
"AuthToken": "5 GGo3hKqPSvbHwRImTjIxeMKQ",
"Sek": "EmLpFzYohZLstcXCSX9C9XIHVLb+QcsjMO1mk+qAjW8hyXmEBQnCAYsmbluF Fu+Z",
"TokenExpiry": "2019-11-30 14:18:00"
},
"ErrorDetails": null,
"InfoDtls": " < alert message > "
}

JSON(in case of error)


"status": "0",
"Data": null,
"ErrorDetails":"<Errors JSON>",
"InfoDtls": "<alert message >"
}

Frequently Asked Questions

1. Getting error 'Invalid Auth Token' while generating an e-Invoice through API and it is getting expired within 6 Hours.
A. Auth Token will be active for 6 hours since the first successful login. Even if the the Auth API is called again before 6 hours, same token will be returned and the time is not reset. Hence you can generate new Auth token only when it expires after 6 hours. For example: If you have authenticated at 12:00, token will be active till 06:00 If auth API is called at 02:00, still the same token will be active till 06:00 and not till 08:00