Generate Access Token
POST /accessToken/token
DEPRECATED
This endpoint belongs to the legacy 2FA / API-key generation flow and is deprecated. It will be removed in a future release.
Please migrate to the new OAuth-based flow: generate your API Key and Secret via the Samco Trade API Web Dashboard and use those credentials with the new login flow.
The Token API is used to generate an access token using a valid user ID and the secret API key received from the Secret Key Generator API on your registered email ID.
This token is valid for one day.
- It expires before 8:00 AM the next day.
- If the access token expires, you can generate a new access token using the same secret API key.
Parameter
| Name | Type | Required | Description |
|---|---|---|---|
uid | string | true | The unique identification code assigned to you by SAMCO upon the successful opening of your trading account. |
secretApiKey | string | true | The secret API key received on the registered email ID. |
Sample Request Body
json
requestBody={
"uid" : "DV99999",
"secretApiKey" : "XXXXXXXXXXXXkUM9"
}Sample Code
js
var headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json'
};
$.ajax({
url : 'https://tradeapi.samco.in/accessToken/token',
method : 'post',
data : JSON.stringify(requestBody),
headers : headers,
success : function(data){
console.log(JSON.stringify(data));
},
error : function(error){
console.log(error);
}
})py
import requests
import json
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json'
}
r = requests.post('https://tradeapi.samco.in/accessToken/token',
data=json.dumps(requestBody),
headers = headers)
print (r.json())Sample Response
json
{
"serverTime": "17/12/25 10:15:08",
"msgId": "66b290f4-343e-4e08-85e5-67f708feb5f0",
"status": "Success",
"accessToken": "XXXXXXXXXXXXXiSUg_Ps6A942Lif"
}json
{
"serverTime": "17/12/25 10:16:26",
"status": "Failure",
"statusMessage": "Secret key does not match"
}Response Schema
Status Code 200
| Name | Type | Description |
|---|---|---|
serverTime | string | The date and time when the server generated the response. |
msgId | string | A unique identifier for the API response message. Useful for tracking or debugging purposes. |
status | string | The status of the API response. Possible values are 'Success', 'Error', or 'Failure'. |
statusMessage | string | A message describing the result of the API call. |
accessToken | string | A unique access token generated for the user. This token is valid for one day. It expires before 8:00 AM the next day. |