Application tokens

To retrieve the necessary authentication token to use the emnify REST API, you must use an application token generated in your emnify account.

Application tokens are recommended for M2M communications as this doesn’t involve leaving user credentials on an application server or devices with programmatic API access. Other advantages of application tokens are that you can create multiple tokens, restrict their use to a specific IP address range or application, and configure an expiration date, after which the token is automatically revoked. Application tokens can also be revoked at any time on a per-token basis.

Create an application token

You can create an application_token via POST request to /api/v1/application_token.

POST
/api/v1/application_token
1curl -X POST https://cdn.emnify.net/api/v1/application_token \
2 -H "Authorization: Bearer <token>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "description": "Token with expiry date",
6 "expiry_date": "2021-05-29T00:00:00.000Z"
7}'
Response
1{
2 "application_token": "KAOp24TuMgjO2FpZmZ3ZFjSqpk7ea_mY8H2daMlMXF-lRbmMzLeQwSEX67-NFczI3GgHcHpCKTfAw"
3}

The application token can be revoked at any time.

You can also create and view application tokens in the emnify Portal. For step-by-step instructions, see Application tokens.

Authenticate with an application token

Once you create an application token, use /api/v1/authenticate to generate a JWT auth_token that authenticates subsequent API calls.

POST
/api/v1/authenticate
1curl -X POST https://cdn.emnify.net/api/v1/authenticate \
2 -H "Content-Type: application/json" \
3 -d '{
4 "application_token": "5cCI6IkpXVCJ9.."
5}'
Response
1{
2 "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
3}

The server only returns an auth_token. There’s no refresh_token included in the response.