JWTs

JSON Web Tokens (JWTs) are a signed JSON object sent in the Authorization header in all requests towards the API. Once users log in, they receive a JWT (referred to here as auth_tokens) allowing them to access APIs that are permitted with that token.

The following example shows how an auth_token is included in the Authorization request header (the Bearer type) when creating a new user.

POST
/api/v1/user
1import requests
2
3url = "https://cdn.emnify.net/api/v1/user"
4
5payload = {
6 "username": "eabbot@flatland.org",
7 "name": "Edwin Abbott",
8 "organisation": { "id": 123 },
9 "roles": [{ "id": 1 }, { "id": 2 }]
10}
11headers = {
12 "Authorization": "Bearer <token>",
13 "Content-Type": "application/json"
14}
15
16response = requests.post(url, json=payload, headers=headers)
17
18print(response.json())

An auth_token shouldn’t be confused with an application_token. Application tokens are long-lived tokens that are sent in a POST request body to retrieve an auth_token instead of using a user and password combination.