session.history

The session.history command is used to access and view session history.

Requires organization administrator privileges.

Session history can be requested by specifying:

  • a specific time period using a start and end date

  • a time period defined by the last period-of-time-style query (for example, "last":"24h")

  • the orgId to retrieve the session history for a specified organization

  • Using the showAll parameter with super administrator rights allows you to view the session histories of all organizations

TR50 Request

// Last period of time request
{
  "1": {
    "command": "session.history",
    "params": {
      "orgId": "540f438174e00c1427000022",
      "sort": "whoAmI",
      "last": "24h"
    }
  }
}


// Definite time period request
{
  "1": {
    "command": "session.history",
    "params": {
      "showAll": true,
      "limit": 20,
      "start": "2016-03-04T00:00:00Z",
      "end": "2016-03-04T23:59:59Z"
    }
  }
}

Request Parameters

Name

Type

Required

Description

start

String

 

When doing a definite time period request this is the timestamp for the start of the specified time window.

end

String

 

When doing a definite time period request this is the timestamp for the end of the specified time window.

last

String

 

When doing a last period of time request this specifies the last X amount of time in seconds (s), minutes (m), hours (h), or days (d).

offset

Integer

 

The starting list offset, used for pagination. Defaults to zero if not specified.

limit

Integer

 

Limit the number of results returned. Defaults to the configured maximum limit.

orgId

String

 

The object id identifying the organization.

sort

String

 

Sort parameter. Valid values are "startTime", "whoAmI", "hasSuperAdmin", "hasSuperOps", "hasOrgAdmin", and "orgKey".

showAll

Boolean

 

Valid values are true and false to indicate whether to show session histories for all organizations. Limited to super-admins.

TR50 Response

If the command is sent successfully a success message and the session records found are returned. Otherwise, an error and error message are returned.

The result array only contains non-empty fields. Some fields are specific to users, things, or both.

{
  "1": {
    "success": true,
    "params": {
      "count": 2,
      "result": [
        {
          "id": "56d9da9e421aa97f0b000020",
          "serverId": "localhost",
          "orgId": "540f438174e00c1427000022",
          "orgKey": "DEMO",
          "userId": "559d3290681fdc6b66003d22",
          "userName": "joe.doe@telit.com",
          "whoAmI": "joe.doe@telit.com",
          "hasSuperAdmin": true,
          "hasSuperOps": true,
          "hasOrgAdmin": false,
          "connInfo": {
            "protocol": "http",
            "remoteAddr": "172.27.9.141"
          },
          "ttl": 86400,
          "locale": "",
          "startTime": "2016-03-04T18:57:34.657Z",
          "endTime": "0001-01-01T00:00:00Z",
          "commandCount": 12,
          "lastAccessed": "0001-01-01T00:00:00Z"
        },
        {
          "id": "56d9dbd0681fdc76836e9b26",
          "serverId": "engr-open01",
          "orgId": "533ef300310046187700007f",
          "orgKey": "QWERTY",
          "appId": "533efbc2310046187700049e",
          "appName": "Gateway",
          "appToken": "pbqFLB0yvCybybcX",
          "thingKey": "012376000004002",
          "thingId": "533ff52c310046299601b86d",
          "thingDefId": "533efba0310046187700047c",
          "whoAmI": "012376000004002",
          "hasSuperAdmin": false,
          "hasSuperOps": false,
          "hasOrgAdmin": true,
          "connInfo": {
            "protocol": "MQTT (TLSv10)",
            "remoteAddr": "174.47.40.235:38069"
          },
          "ttl": 90,
          "locale": "",
          "startTime": "2016-03-04T19:02:40.835Z",
          "endTime": "0001-01-01T00:00:00Z",
          "commandCount": 6,
          "lastAccessed": "0001-01-01T00:00:00Z"
        },
        {
          "id": "56d9da78421aa97f0b000009",
          "serverId": "localhost",
          "orgId": "534c36e53100460721000051",
          "orgKey": "DEV",
          "userId": "559d3290681fdc6b66003d22",
          "userName": "joe.doe@telit.com",
          "whoAmI": "joe.doe@telit.com",
          "hasSuperAdmin": true,
          "hasSuperOps": true,
          "hasOrgAdmin": false,
          "connInfo": {
            "protocol": "http",
            "remoteAddr": "172.27.9.141"
          },
          "ttl": 86400,
          "locale": "",
          "startTime": "2016-03-04T18:58:56.361Z",
          "endTime": "0001-01-01T00:00:00Z",
          "orgSwitches": [
            {
              "orgId": "540f438174e00c1427000022",
              "ts": "2016-03-04T18:59:14.216Z"
            }
          ],
          "commandCount": 18,
          "lastAccessed": "0001-01-01T00:00:00Z"
        }
      ]
    }
  }
}

Response Parameters

Name

Type

Description

count

Integer

The total number of records matching the start-end/last date criteria.

result

Array

The array of session records.

Result Array Object

Name

Type

Description

id

String

The ID of the session record

serverId

String

The server on which the session resides.

orgId

String

The user or app token object id of the current organization.

orgKey

String

The key for the organization.

appId

String

The object id of the thing's app.

appName

String

The name of the application.

appToken

String

The application token used during authentication.

thingKey

String

The thing key used during authentication.

thingId

String

The object id of the thing.

thingDefId

String

The object id of the thing definition of the thing.

userId

String

The object id of the user.

userName

String

The username of the user.

whoAmI

String

The thing key or user name associated with the session.

hasSuperAdmin

Boolean

Whether the thing or user has super-admin permission.

hasSuperOps

Boolean

Whether the thing or user is super-ops.

hasOrgAdmin

Boolean

Whether the thing or user is an organization admin.

connInfo

Struct

A struct containing the connection protocol and remote address.

ttl

Integer

Time to live (used by Redis).

startTime

String

Start time of the session.

commandCount

Integer

Number of commands carried out related to the session.

failureReason

String

The description of the authentication failure.