Create a token

API Tokens are a great way to authenticate to our API while being separate from your username and password. We strongly recommend you to use them. You'll find here how to manage your API tokens. You can create a token with our API or on our platform in the Developer menu.

POST

/token

Body Parameters

name
required
The token name

Examples


POST /token HTTP/1.1
Host: api.smsfactor.com
Authorization: your.token
Accept: application/json

{
  "token":{
    "name": "Best token ever"
  }
}
          
        

POST /token HTTP/1.1
Host: api.smsfactor.com
Authorization: your.token
Accept: application/xml

<?xml version="1.0" encoding="UTF-8" ?>
<token>
  <name>Best token ever</name>
</token>
        
      

$response = \SMSFactor\Token::create([
    'token' => [
      'name' => 'Best token ever'
    ]
]);
$token = $response->token;
$token_id = $response->token_id;
        
      

Result Format


{
  "status": 1,
  "message": "OK",
  "token": "yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMTY1NiIsImlhdCI6MTUxOTEyMDg2NX0.ZnGgbDC0OI3hPm2UXyl4rxU9JlpMTMBcTJT8RVgJbtQ",
  "token_id": "2"
}
          
        

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <status>1</status>
    <message>OK</message>
    <token>yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMTY1NiIsImlhdCI6MTUxOTEyMDg2NX0.ZnGgbDC0OI3hPm2UXyl4rxU9JlpMTMBcTJT8RVgJbtQ</token>
    <token_id>2</token_id>
</response>
        
      

Create a token for a subaccount

POST

/token/account/:accountID

Query Parameters

accountID
required
The account ID you wish to create a token for

Body Parameters

name
required
The token name

Examples


POST /token/account/12542 HTTP/1.1
Host: api.smsfactor.com
Authorization: your.token
Accept: application/json

{
  "token":{
    "name": "Best token ever"
  }
}
          
        

POST /token/account/12542 HTTP/1.1
Host: api.smsfactor.com
Authorization: your.token
Accept: application/xml

<?xml version="1.0" encoding="UTF-8" ?>
<token>
  <name>Best token ever</name>
</token>
        
      

Result Format


{
  "status": 1,
  "message": "OK",
  "token": "yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMTY1NiIsImlhdCI6MTUxOTEyMDg2NX0.ZnGgbDC0OI3hPm2UXyl4rxU9JlpMTMBcTJT8RVgJbtQ",
  "token_id": "2"
}
          
        

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <status>1</status>
    <message>OK</message>
    <token>yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMTY1NiIsImlhdCI6MTUxOTEyMDg2NX0.ZnGgbDC0OI3hPm2UXyl4rxU9JlpMTMBcTJT8RVgJbtQ</token>
    <token_id>2</token_id>
</response>