Crea token

I token API sono un ottimo modo per autenticarsi sul nostro API mantenendo separati i tuoi username e password. Ti raccomandiamo caldamente di usarli. Qui imparerai come gestire i tuoi token. Potrai creare un token sulla nostra API oppure su La nostra piattaforma in the Developer menu.

POST

/token

Parametri del body

name
richiesto
Il nome del token

Esempi


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

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

POST /token HTTP/1.1
Host: api.smsfactor.com
Authorization: Bearer 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;
        
      

Formato della risposta


{
  "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>
        
      

Crea token per un sotto-account

POST

/token/account/:accountID

Parametri query

accountID
richiesto
L’id dell’account per il quale vuoi creare un token

Parametri del body

name
richiesto
Il nome del token

Esempi


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

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

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

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

Formato della risposta


{
  "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>