Create a token for a subaccount

This method allows you to create a token for a subaccount.

POST

/token/account/:id

Query Parameters

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

Body Parameters

name
required
The token name
ttl The TTL in seconds. Default no expiration
allowed_ips Manage allowed ips to make request with this token (IPv4, IPv6, and cidr are compatible)

Examples


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

{
  "token":{
    "name": "Best token ever",
    "ttl": 2678400,
    "allowed_ips": [
        "2a01:cb1d:2b9:ef02:2521:4ed1:109a:8fae",
        "192.168.2.0/24",
        "192.168.2.2"
    ]
  }
}
            
            

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>
            
        

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>