Authenticate with Application Tokens

To retrieve the necessary authentication token to use the emnify 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 https://cdn.emnify.net/api/v1/application_token

Request header

Authorization: Bearer kNTktNTA1My00YzdhLT...

Request body

{
  "description": "Token with expiry date",
  "expiry_date": "2021-05-29"
}

Response

{
  "application_token": "KAOp24TuMgjO2FpZmZ3ZFjSqpk7ea_mY8..."
}

The application token can be revoked at any time.

Authenticate with an Application Token

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

POST https://cdn.emnify.net/api/v1/authenticate

Request body

{
  "application_token": "kNTktNTA1My00YzdhLT..."
}

Response

{
  "auth_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}