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.
In order to create your first token, you need to go on our platform
POST
/token
Body Parameters
name
required
|
The token name |
ttl | The TTL in seconds (default unlimited) |
allowed_ips | Manage allowed ips to make request with this token (IPv4, IPv6, and cidr are compatible) |
Examples
POST /token HTTP/1.1
Host: api.smsup.ch
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 HTTP/1.1
Host: api.smsup.ch
Authorization: Bearer your.token
Accept: application/xml
<?xml version="1.0" encoding="UTF-8" ?>
<token>
<name>Best token ever</name>
<ttl>2678400</ttl>
</token>
Result Format
{
"status": 1,
"message": "OK",
"token": "yJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMTY1NiIsImlhdCI6MTUxOTEyMDg2NX0.ZnGgbDC0OI3hPm2UXyl4rxU9JlpMTMBcTJT8RVgJbtQ",
"token_id": "2",
"allowed_ips": [
"2a01:cb1d:2b9:ef02:2521:4ed1:109a:8fae",
"192.168.2.0/24",
"192.168.2.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 |
ttl | The TTL in seconds (default unlimited) |
Examples
POST /token/account/12542 HTTP/1.1
Host: api.smsup.ch
Authorization: Bearer your.token
Accept: application/json
{
"token":{
"name": "Best token ever"
}
}
POST /token/account/12542 HTTP/1.1
Host: api.smsup.ch
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>