Presence

A time period (session) that a user was detected in a space or location.

A presence object may be associated with a user resource directly, or with a device. If presence is associated to a device, that typically indicates that a person is sensed but cannot be identified. This is common when detecting presence using devices such as IR sensors.

Upon creation, the arrived_at attribute is initialized to the current time and the expired_at value is set to the TTL (time to live) added to the current time.

Each time presence is posted for a user or device that already has an active presence session (a session in the same space that hasn't expired) than the active session will be lengthened by the provided TTL. Otherwise a new presence session is created.

📘

Keep your presence TTL short

The maximum allowed TTL is 20 minutes, however for the best results we recommend using a value less than 5 minutes. In the future we may reduce the maximum allowed TTL.

Properties

PropertyTypeDescription
location_idIntegerThe ID of the location where the presence was detected.
space_idIntegerThe ID of the space where the presence was detected or null if the presence exists at the location (not space) level.
user_idIntegerThe ID of the user, or null if the presence is associated only to a device.
device_idIntegerThe ID of the device, or null if the presence is associated only to a user.
last_seen_atStringThe date and time when the presence was last seen, represented as an ISO-8601 date.
arrived_atStringThe date and time when the presence was first detected, represented as an ISO-8601 date.
expired_atStringThe date and time when the presence will expire, represented as an ISO-8601 date. (This should always be equal to the TTL added to the last_seen_at attribute)
session_activeBooleanIndicates whether the session is currently active.
userObjectThe user resource, if the presence is associated to a user.
deviceObjectThe Device resource, if the presence is associated to a device.

Example

{
  "location_id": 1,
  "space_id": 1,
  "user_id": 4,
  "device_id": 2,
  "last_seen_at": "2014-05-22T14:49:48+0000",
  "arrived_at": "2014-05-22T14:49:48+0000",
  "expired_at": "2014-05-22T14:50:18+0000",
  "session_ttl": 30,
  "session_active": true,
  "user": {
    "id": 1,
    "name": "Brian",
    "slug": "brian",
    "avatar": "",
    "created_at": "2014-05-05T16:06:58+0000",
    "updated_at": "2014-05-05T16:06:58+0000",
    "primary_email": {
      "email": "[email protected]",
      "is_verified": false
    }
  }
}