Admin

Makes a signed token for a client. SensApp does not keep tokens: the answer is the only time the token is shown, it cannot be listed or revoked, and it is valid until it expires or until the secret that signed it is rotated out (see SENSAPP_JWT_PREVIOUS_SECRETS). Requires the admin scope. An admin token cannot make another admin token: those come from sensapp generate-token, which needs the secret. Not available when authentication is disabled.

post/api/v1/admin/tokens

Request

  • The document declares no server URL.
  • Auth: HTTP bearer

Request body

duration_secondsinteger required

Validity of the token, in seconds, at most SENSAPP_TOKEN_MAX_DURATION_SECONDS (a year by default).

scopestring[] required

What the token may do, among read, write and delete. admin tokens are only made with sensapp generate-token.

sensorsstring[] nullable

Names of the sensors the token may access. Leave it out for every sensor.

subjectstring required

Who or what the token is for: a service, a device, a person. It is in the logs of every request the token makes.

Example request

{
  "duration_seconds": 86400,
  "scope": [
    "read",
    "write"
  ],
  "sensors": [
    "temperature",
    "humidity"
  ],
  "subject": "edge-device-7"
}

Response

The token

expires_atinteger required

Expiration time, Unix timestamp in seconds

jtistring required

Unique id of the token, in the logs of the requests it makes

scopestring[] required
sensorsstring[] nullable
subjectstring required
tokenstring required

The token, to use as Authorization: Bearer <token>. This is the only time it is shown: SensApp does not keep tokens.

Changes