NAV Navbar
Logo
shell python

Introduction

Welcome to the TempAlert Developer Portal. Here you will find information about the APIs that we offer as well as how to use them.

We have provided example language bindings in Shell and Python. You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Types

Date Format

Parameters of type date should be sent to (and are sent from) the service as a combined date and time in ISO 8601 format. Time zone information must be included, or the results of the API call are not defined.

All dates returned by the service are in UTC.

Numbers

Parameters of type integer (32 bit) are whole numbers that have a max value of 2147483647, while those with type integer (64 bit) are whole numbers that have a max value of 9,223,372,036,854,775,807. Parameters of type decimal may include a fractional portion separated by a decimal point.

Device ID

The deviceID field is a 20-digit number that is converted to string and transmitted. It is converted to string to ease interoperability.

Power Reading Values

A device reading type of Power indicates the status of a device’s power source. Values range from 0 to 10 for battery only devices (e.g. ZPoint Wireless Sensor). For AC powered devices with battery backup, the values range from 16 to 26 when the device is plugged in and 0 to 10 when not plugged in. A value of 16 indicates AC power only, while a value higher than 16 would indicate AC power plus some battery backup.

Results Paging

For API calls that may return large amounts of data, the results are broken up into “pages”. Each “page” contains a unique subset of the data, and may include a link to the next “page” if there is additional data.

The link to the next “page” is specified in the HTTP response header called next. All API calls are potentially subject to paging, so the response header should always be checked for the next “page” link. (see Devices)

processedDate vs. readingDate

readingDate specifies the point in time at which a reading was captured by a sensor or device-e.g., a temperature sensor recorded a temperature of 32.45°F on Friday, January 15th at 3:17pm, UTC.

processedDate specifies the point in time at which a reading was processed by Sensor Cloud.

Example: An external temperature sensor, attached to a device, records a temperature of 32.45°F on Friday, January 15th at 3:17pm, UTC. Due to an interruption in cellular service, the device is not able to send the reading to Sensor Cloud for five minutes. In this case the reading would have a processedDate of 3:22pm, but a readingDate of 3:17pm.

Applications using this API to capture all readings processed by Sensor Cloud should use the processedAfterDate filter to request new readings since the last request. (see Synchronizing Readings)

Rate Limiting

There is a limit to how many authenticated calls can be made in a given time period. The API limits are on a per minute basis and the count towards the limit is tied to the client identifier.

With each response there are two HTTP response headers. The first, Rate-Limit-Limit, indicates the number of allowed requests per minute. The second, Rate-Limit-Remaining, indicates the number of remaining requests in the current period. (see Devices)

Once the limit is reached, the API does not process any subsequent requests and instead responds with status of HTTP 429 to indicate too many requests.

Auth

Authentication

Sample /auth/oauth Request

curl --silent https://api.tempalert.io/auth/oauth \
  --data "grant_type=client_credentials" \
  --header "Accept: application/json"\
  --basic --user myclientid:myclientsecret
import json
import requests

client_id="myclientid"
client_secret="myclientsecret"
client_auth = (client_id, client_secret)
r = requests.post('https://api.tempalert.io/auth/oauth',
                  data = {'grant_type':'client_credentials'},
                  auth = client_auth,
                  headers={'Accept':'application/json'},
                  )
print (r.json())

Sample /auth/oauth Response:

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: application/json
Expires: -1
Date: Wed, 13 Jan 2016 17:46:54 GMT

{ 
  "access_token": "AW+kvNB8LR5Hqd60GNwY2MkkDooKvoGuQpHXoRm4DAYM", 
    "token_type": "Bearer", 
    "expires_in": 3600 
}

The Sensor Cloud REST API uses the client credentials portion of the OAuth2 specification to perform authentication and authorization. This requires the client of the API to possess a client identifier and a client “secret” (the “secret” should be considered confidential). Both the client ID and “secret” together make up the client credentials.

TempAlert provides client credentials for clients of the API. Once you have acquired credentials, make a call to the TempAlert authorization endpoint (https://api.tempalert.io/auth/oauth) to obtain a token.

Client Credentials Scope

The client credentials are bound at creation time to a specific Sensor Cloud account ID and user ID. Currently, client credentials have access to all data available to the Sensor Cloud user ID.

Using API Client Credentials To Obtain an Access Token

As per the OAuth2 specification, client credentials can be used by the API client to obtain an “access token”. This “access token” can then be used for authorizing API calls (until the token expires). To obtain an “access token”, the client makes a POST request to /auth/oauth, as described in https://tools.ietf.org/html/rfc6749#section-4.4.2.

To summarize section 4.4.2 of the OAuth2 specification: pass grant_type=client_credentials in the body of the request (form-urlencoded), and use HTTP Basic authentication to provide the client ID and client secret.

To use the sample code, you must replace myclientid and myclientsecret with your personal API client ID and secret.

Authorization

To authorize with the TempAlert API you need to pass a Bearer token obtained using the Authentication process. The bearer token must be included in the Authorization header for all API requests and must look like the following:

Authorization: Bearer TOKEN_FROM_TEMPALERT

You must replace TOKEN_FROM_TEMPALERT with your personal API token from the Authorization process.

SCIM

Sensor Cloud User Management With SCIM

To ease managing of Sensor Cloud users, TempAlert provides a set of endpoints that conform to the SCIM standard.

The SCIM User Resource is mapped directly to a Sensor Cloud login.

Anatomy of a User

Sensor Cloud supports the following portion of the SCIM User schema:

Attribute Sub Attribute Type Description
userName string The name the user will use to log into Sensor Cloud
name object The components of the user’s name.
givenName string The user’s first (given) name
familyName string The user’s last (family) name
entitlements array[multiValueAttribute] The user’s entitlements.
emails array[multiValueAttribute] List of this user’s email addresses. Currently only the first or primary address is saved.
urn:ietf:params:scim:schemas:tempalert:1.0:User object The attributes set on from the TempAlertUser enterprise user schema extension
roles array[multiValueAttribute] The roles that the user has. Default: Viewer

TempAlert Enterprise User

Sensor Cloud provides the following schema extension for the Core User Schema:

Attribute Required Type Default Description
managedExternally no boolean false If “Managed Externally” is true the user will not support edits from inside Sensor Cloud.

Entitlements

SCIM user entitlements are used to grant users access to various aspects of a Sensor Cloud account.

Groups Entitlement

The Groups entitlement allows restricting the devices in an account to which a user has access.

Devices in a Sensor Cloud account can be organized into groups, and users can optionally be granted access to a subset of these groups. When logged into Sensor Cloud, a user is only able to see devices in the group(s) to which he or she has access.

The Device Group entitlement has a type of Groups and a value that consists of a list of Sensor Cloud Group IDs to which the user should be granted access. (see create)

Roles

SCIM Users can be assigned a single role when they are created. If roles are not passed in the default Viewer role is assigned. See the below chart for more information about roles:

Role Name Description
Administrator An unrestricted user with access to all features
AlertsEditor Can edit alerts, but not device information
ApiUser Can access this API, but cannot log into Insights. Contact us to get an access token
ChecklistUser Can access and complete checklists and can respond to incidents
Editor Can edit devices and alerts
GroupAdmin Has Administrator level access scoped to a group or groups
Installer Is an Install Application User and cannot log into Insights
Owner Owns the account. This value cannot be set via the API
Responder Can respond to incidents, but cannot modify devices or alerts
Viewer Read only access to all features

Users

The following endpoints allow API clients to perform CRUD operations on SCIM users:

Create User

Sample Create User Request


curl --silent "https://api.tempalert.io/scim/users" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\
  --request POST \
  --data '{
   "userName": "apiUser",
   "name": {
      "givenName": "John",
      "familyName": "Doe"
   },
   "entitlements":[
      {
         "type": "groups",
         "value": [
           1,
           2,
           3
         ]
      }
   ],
   "emails":[
      {
         "type": "work",
         "value": "jdoe@tempalert.io"
      }
   ],
    "roles": [
        {
            "value": "Viewer",
            "type": "Role"
        }
    ],
   "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
      "managedExternally": true
   },
   "schemas":[
      "urn:ietf:params:scim:schemas:core:2.0:User",
      "urn:ietf:params:scim:schemas:tempalert:1.0:User"
   ]
}'


import json
import requests

user= {
    "schemas": [
      "urn:ietf:params:scim:schemas:core:2.0:User",
      "urn:ietf:params:scim:schemas:tempalert:1.0:User"
    ],
    "meta": {
      "resourceType": "User"
    },
    "userName": "apiUser",
    "name": {
        "givenName": "John",
        "familyName": "Doe"
    },
    "emails": [
      {
        "value": "jdoe@tempalert.io",
        "type": "work"
      }
    ],
    "roles": [
        {
            "value": "Viewer",
            "type": "Role"
        }
    ],
    "entitlements":[
      {
         "type": "groups",
         "value": [
           1,
           2,
           3
         ]
      }
   ],
   "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
      "managedExternally": true
   }
 }
credential_token="TOKEN_FROM_TEMPALERT"
r = requests.post('https://api.tempalert.io/scim/users',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json',
                    'Content-Type': 'application/json'
                  },
                  json=user,
                  timeout=5
                )
print (r.json())

Sample Create User Response:


HTTP/1.1 201 Created
Location: /scim/users/D697FC3D-CA1F-4343-BBD6-9353105A5909

No Content

This endpoint creates a new user in Sensor Cloud. The username must be unique. On success, the SCIM API path of the new user is passed in the Location header of the response.

If your account is not configured to enable user creation without entitlements you will receive a forbidden action error.

POST /scim/users

Parameters
Name Location Type Description Required
user body user The user to create yes
Responses
Code Description
201 Success - User created
403 Forbidden - You do not have permission to create the user
409 Conflict - User already exists

Get All

Sample Get All Users Request


curl --silent "https://api.tempalert.io/scim/users?startIndex=1&count=5" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"


import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"
r = requests.get('https://api.tempalert.io/scim/users?startIndex=1&count=5',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get All Users Response:


{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "totalResults": 100,
  "resources": [
    {
      "userName": "scimUser1",
      "name": {
        "givenName": "John",
        "familyName": "Doe"
      },
      "emails": [
        {
          "value": "johndoe@tempalert.io",
          "type": "work"
        }
      ],
      "entitlements": [
        {
          "value": [
            1,
            2
          ],
          "type": "groups"
        }
      ],
      "roles": [
        {
          "value": "Viewer",
          "type": "Role"
        }
      ],
      "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
        "managedExternally": true
      },
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:tempalert:1.0:User"
      ],
      "id": "CE95BFD4-DDE8-4E29-9B3B-74620745C8DB",
      "meta": {
        "resourceType": "User",
        "location": "https://api.tempalert.io/scim/users/CE95BFD4-DDE8-4E29-9B3B-74620745C8DB"
      }
    },
    ...
    {
      "userName": "scimUser5",
      "name": {
        "givenName": "Jane",
        "familyName": "Doe"
      },
      "emails": [
        {
          "value": "janedoe@tempalert.io",
          "type": "work"
        }
      ],
      "entitlements": [
        {
          "value": [
            1,
            2
          ],
          "type": "groups"
        }
      ],
      "roles": [
        {
          "value": "Editor",
          "type": "Role"
        }
      ],
      "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
        "managedExternally": true
      },
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User",
        "urn:ietf:params:scim:schemas:tempalert:1.0:User"
      ],
      "id": "A39F0B6E-CACE-4330-B4F3-0E7A14D664DE",
      "meta": {
        "resourceType": "User",
        "location": "https://api.tempalert.io/scim/users/A39F0B6E-CACE-4330-B4F3-0E7A14D664DE"
      }
    }
  ],
  "startIndex": 1,
  "itemsPerPage": 5
}

This endpoint returns all users in your account. This call returns a paginated response of users.

GET /scim/users

Get All Parameters
name location type required description
username query string string no optional username filter. if provided, only users with this username will be returned.
givenName query string string no optional first/given name filter. if provided, only users with this given name will be returned.
familyName query string string no optional last/family filter. if provided, only users with this family name will be returned.
email query string string no optional email filter. if provided, only users with this email will be returned.
roles query string string no optional comma separated list of role names. if provided, only users with a role in the list will be returned.
startIndex query string int no optional 1-based index of the first query result. Defaults to 1.
count query string int no optional non-negative number of items to retrieve. Defaults to 100.

Get All Responses

Response Header
Code Description
200 Success
404 Not Found
Response Body
Property Type Description
totalResults int Total number of items that matched the query criteria
itemsPerPage int Number of items returned per page
startIndex int The starting index of this query
schemas array[string] The schema(s) of the response
resources array[user] Array of the users requested

Get One

Sample Get User Request


curl --silent "https://api.tempalert.io/scim/users/A39F0B6E-CACE-4330-B4F3-0E7A14D664" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"


import json
import requests

user_id='A39F0B6E-CACE-4330-B4F3-0E7A14D664DE'
credential_token="TOKEN_FROM_TEMPALERT"
r = requests.get('https://api.tempalert.io/scim/users/' + user_id,
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get User Response:


  {
    "userName": "scimUser2",
    "name": {
      "givenName": "Jane",
      "familyName": "Doe"
    },
    "emails": [
      {
        "value": "janedoe@tempalert.io",
        "type": "work"
      }
    ],
    "entitlements": [
      {
        "value": [
          1,
          2
        ],
        "type": "groups"
      }
    ],
    "roles": [
        {
            "value": "Administrator",
            "type": "Role"
        }
    ],
    "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
      "managedExternally": true
    },
    "schemas": [
      "urn:ietf:params:scim:schemas:core:2.0:User",
      "urn:ietf:params:scim:schemas:tempalert:1.0:User"
    ],
    "id": "A39F0B6E-CACE-4330-B4F3-0E7A14D664DE",
    "meta": {
      "resourceType": "User",
      "location": "https://api.tempalert.io/scim/users/A39F0B6E-CACE-4330-B4F3-0E7A14D664DE"
    }
  }

GET /scim/users/{userID}

This endpoint retrieves a single user.

Get User Parameters
Name Location Description Required
userID path ID of the user to retrieve Yes
Get User Responses
Code Description
200 Success
404 Not Found
Body Description
user The user requested

Update User

Sample Update User Request


curl --silent "https://api.tempalert.io/scim/users/A39F0B6E-CACE-4330-B4F3-0E7A14D664" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\
  --request PUT \
  --data '{
   "userName": "MySensorCloudUser",
   "name": {
      "givenName": "John",
      "familyName": "Doh"
   },
   "entitlements":[
      {
         "type": "groups",
         "value": [
           1,
           2,
           3
         ]
      }
   ],
   "emails":[
      {
         "type": "work",
         "value": "jdoh@tempalert.io"
      }
   ],
   "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
     "managedExternally": true
   },
   "schemas":[
      "urn:ietf:params:scim:schemas:core:2.0:User",
      "urn:ietf:params:scim:schemas:tempalert:1.0:User"
   ]
}'


import json
import requests

user_id='D697FC3D-CA1F-4343-BBD6-9353105A5909'
user= {
    "schemas": [
      "urn:ietf:params:scim:schemas:core:2.0:User",
      "urn:ietf:params:scim:schemas:tempalert:1.0:User"
    ],
    "meta": {
      "resourceType": "User"
    },
    "userName": "apiUser",
    "name": {
        "givenName": "John",
        "familyName": "Doh"
    },
    "emails": [
      {
        "value": "jdoh@tempalert.io",
        "type": "work"
      }
    ],
    "entitlements":[
      {
         "type": "groups",
         "value": [
           1,
           2,
           3
         ]
      }
   ],
   "urn:ietf:params:scim:schemas:tempalert:1.0:User": {
     "managedExternally": true
   }
 }
credential_token="TOKEN_FROM_TEMPALERT"
r = requests.put('https://api.tempalert.io/scim/users/' + user_id,
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json',
                    'Content-Type': 'application/json'
                  },
                  json=user,
                  timeout=5
                )
print (r.json())

Sample Update Uesr Response:


HTTP/1.1 204 No Content
Location: /scim/users/D697FC3D-CA1F-4343-BBD6-9353105A5909

No Content

PUT /scim/users/{userID}

This endpoint updates (replaces) a user with the new information in the request. On success, the SCIM API path of the updated user is passed in the Location header.

If your account is not configured to enable user creation without entitlements you will receive a forbidden action error.

Update User Parameters
Name Location Description Required
user body New value for user. Yes
userID path ID of the user to update Yes
Update User Responses
Code Description
204 Success - No Content
403 Forbidden - You do not have permission to create the user
404 Not Found

Delete User

Sample Delete User Request


curl --silent "https://api.tempalert.io/scim/users/D697FC3D-CA1F-4343-BBD6-9353105A5909"
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\
  --request DELETE


import json
import requests

user_id='D697FC3D-CA1F-4343-BBD6-9353105A5909'
credential_token="TOKEN_FROM_TEMPALERT"
r = requests.delete('https://api.tempalert.io/scim/users/' + user_id,
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json', 
                    'Content-Type': 'application/json'
                  },
                  json=user,
                  timeout=5
                )
print (r.json())

Sample Delete User Response


HTTP/1.1 204 No Content`

No Content

DELETE /scim/users/{userID}

This endpoint deletes a user.

Delete Parameters
Name Location Description Required
userID path ID of the user to delete Yes
Delete Responses
Code Description
204 No Content
404 Not Found

Schemas

The /scim/schemas endpoints allow retrieving the SCIM schemas supported by TempAlert.

Get All

Sample Get All Schemas Request

curl --silent "https://api.tempalert.io/scim/schemas" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/scim/schemas',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json'
                  },
                )
print (r.json())

Sample Get All Schemas Response:

[
  [
    {
      "id": "urn:ietf:params:scim:schemas:core:2.0:User",
      "name": "User",
      "description": "User Account",
      "attributes": [
        ...
          ]
        ...
      ],
      "mutability": "readWrite",
      "returned": "default",
      "meta": {
        "resourceType": "Schema",
        "location": "/v2/Schemas/urn:ietf:params:scim:schemas:core:2.0:User"
      }
    }
  ],
  ...
]

This endpoint retrieves all the schemas supported by the server.

GET /scim/schemas

Parameters

None.

Responses

Code Description
200 Success

Get One

Sample Get Schema Request

curl --silent "https://api.tempalert.io/scim/schemas/urn:ietf:params:scim:schemas:core:2.0:User" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/scim/schemas/urn:ietf:params:scim:schemas:core:2.0:User',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json'
                  },
                )
print (r.json())

Sample Get Schema Response:

[
  {
    "id": "urn:ietf:params:scim:schemas:core:2.0:User",
    "name": "User",
    "description": "User Account",
    "attributes": [
      {
        "name": "userName",
        "type": "string",
        "multiValued": false,
        "description": "Unique identifier for the User, typically used by the user to directly authenticate to the service provider. Each User MUST include a non-empty userName value.  This identifier MUST be unique across the service provider's entire set of Users. REQUIRED.",
        "required": true,
        "caseExact": false,
        "mutability": "readWrite",
        "returned": "default",
        "uniqueness": "server"
      },
      {
        "name": "name",
        "type": "complex",
        "multiValued": false,
        "description": "The components of the user's real name. Providers MAY return just the full name as a single string in the formatted sub-attribute, or they MAY return just the individual component attributes using the other sub-attributes, or they MAY return both.  If both variants are returned, they SHOULD be describing the same name, with the formatted name indicating how the component attributes should be combined.",
        "required": true,
        "subAttributes": [
          {
            "name": "familyName",
            "type": "string",
            "multiValued": false,
            "description": "The family name of the User, or last name in most Western languages (e.g., 'Jensen' given the full name 'Ms. Barbara J Jensen, III').",
            "required": true,
            "caseExact": false,
            "mutability": "readWrite",
            "returned": "default",
            "uniqueness": "none"
          },
          {
            "name": "givenName",
            "type": "string",
            "multiValued": false,
            "description": "The given name of the User, or first name in most Western languages (e.g., 'Barbara' given the full name 'Ms. Barbara J Jensen, III').",
            "required": true,
            "caseExact": false,
            "mutability": "readWrite",
            "returned": "default",
            "uniqueness": "none"
          }
        ]
      },
      ...
    ],
    "mutability": "readWrite",
    "returned": "default",
    "meta": {
      "resourceType": "Schema",
      "location": "/v2/Schemas/urn:ietf:params:scim:schemas:core:2.0:User"
    }
  }
]

This endpoint retrieves a single schema.

GET /scim/schemas/{TYPE}

Parameters

Name Location Description Required
TYPE path Schema type to retrieve Yes

Responses

Code Description
200 Success
404 Not Found

Supported Types

Name Description
urn:ietf:params:scim:schemas:core:2.0:User The supported User schema
urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig The supported ServiceProviderConfig schema
urn:ietf:params:scim:schemas:core:2.0:ResourceType The supported ResourceType schema
urn:ietf:params:scim:schemas:core:2.0:Schema The supported Schema schema

ResourceTypes

/scim/resourceTypes endpoints allow retrieving SCIM resource types supported by the server.

Get All

Sample Get All Resource Types Request

curl --silent "https://api.tempalert.io/scim/resourceTypes" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/scim/resourceTypes',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json'
                  },
                )
print (r.json())

Sample Get All Resource Types Response:

[
  {
    "name": "User",
    "endpoint": "/Users",
    "schema": "urn:ietf:params:scim:schemas:core:2.0:User",
    "schemaExtensions": [
        {
            "schema": "urn:ietf:params:scim:schemas:tempalert:1.0:User",
            "required": false
        }
    ],
    "id": "User",
    "meta": {
      "resourceType": "ResourceType",
      "location": "https://api.tempalert.io/scim/resourceTypes/User"
    }
  }
]

This endpoint returns all resource types supported by the server.

GET scim/resourceTypes

Parameters

None.

Responses

Code Description
200 Success

Get One

Sample Get Resource Type Request

curl --silent "https://api.tempalert.io/scim/resourceTypes/User" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/scim/resourceTypes/User',
                 'Authorization':'Bearer ' + credential_token,
                  headers={'Accept':'application/json'},
                )
print (r.json())

Sample Get Resource Type Response:

{
  "name": "User",
  "endpoint": "/Users",
  "schema": "urn:ietf:params:scim:schemas:core:2.0:User",
  "schemaExtensions": [
      {
          "schema": "urn:ietf:params:scim:schemas:tempalert:1.0:User",
          "required": false
      }
  ],
  "id": "User",
  "meta": {
    "resourceType": "ResourceType",
    "location": "https://api.tempalert.io/scim/resourceTypes/User"
  }
}

This endpoint returns a single resource type.

GET /scim/resourceTypes/{TYPE}

Parameters

Name Location Description Required
TYPE path Resource type to retrieve Yes

Responses

Code Description
200 Success
404 Not Found

Devices

The /devices endpoint can be used to retrieve information about the devices in an account. The devices response includes information about what sensors are attached to the devices.

Get All

Sample Get All Devices Request

curl --silent "https://api.tempalert.io/devices" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/devices',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get All Devices Response

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 58
next: https://api.tempalert.io/devices?pageIDToken=ZBpSS45D2P
Date: Fri, 15 Jan 2016 17:52:38 GMT
Content-Length: 4393
{
   "devices": [
   {
      "deviceID": "23004000080793070793",
      "deviceName": "Pharmacy",
      "groupName": "West",
      "groupID": "104",
      "deviceType": "Node",
      "lastActivityDate": "2016-01-25T18:54:34.5970000Z",
      "sensors": [
        {
          "sensorType": "Temperature",
          "lastActivityDate": "2016-01-25T18:54:34.5970000Z",
          "port": 1,
          "displayName": "Rx Fridge 1"
        }
      ],
      "tags": [
        "Manager: Casey",
        "Type: freezer"
      ]
    },
    {
      "deviceID": "74012807612084533500",
      "deviceName": "Weather Station",
      "groupName": null,
      "groupID": null,
      "deviceType": "GateWay",
      "lastActivityDate": "2015-07-18T02:53:49.5670000Z",
      "sensors": [
        {
          "sensorType": "Wind Speed",
          "lastActivityDate": "2015-07-18T02:53:49.5670000Z",
          "port": 30,
          "displayName": "Wind Sensor",
          "serialNumber": "2813CBDF020000"
        },
        {
          "sensorType": "Flood",
          "lastActivityDate": "2015-07-18T02:53:49.5670000Z",
          "port": 80,
          "displayName": "Water Sensor",
          "serialNumber": null
        },
        {
          "sensorType": "Voltage",
          "lastActivityDate": "2015-07-18T02:53:49.5670000Z",
          "port": 90,
          "displayName": "Battery Level",
          "serialNumber": "2813CBDF020003"
        }
      ],
      "tags": []
    }
  ]
}

Get all of the active devices in the account to which the API client has access.

GET /devices

Parameters

None.

Output Fields

name type description
devices array Array of device data

The device data structure is as follows:

name type description
deviceID string (max 20) Unique identifier of the device.
deviceName string (max 50) The name of the device, as displayed on Sensor Cloud.
groupName string (max 255) Name of the group to which the device belongs. Will be null if the device does not belong to a group.
groupID integer(64 bit) Unique ID of the group. Will be 0 if the device does not belong to any group.
gatewayID string (max 20) The gateway through which this device is communicating, if applicable.
deviceType string (max 50) Indicates whether the device is a Node, Repeater, Gateway etc. May be null if the device has not yet contacted Sensor Cloud.
reportInterval integer (32 bit) Number of minutes the device is configured to wait between taking readings.
lastActivityDate datetime The last time the device contacted Sensor Cloud.
sensors array Array of sensor data
tags array Array of strings

The sensor data structure is as follows:

name type description
lastActivityDate datetime The last time the sensor contacted Sensor Cloud.
sensorType string (max 50) The type of the sensor: Humidity, Temperature, Flood, Pressure etc.
port integer (32 bit) The port number of the device this sensor is attached to.
displayName string (max 50) The name of the sensor as displayed on Sensor Cloud.
serialNumber string (max 15) The serial number of the sensor where supported.

Responses

Code Description
200 Success

Get One

Get the active device identified by deviceID.

GET /devices/{deviceID}

Parameters

name location type required description
deviceID path string yes Unique identifier of the device.

Output Fields

Same as /devices except the root devices array contains a single device.

Responses

Code Description
200 Success
404 Not Found

Sensor Readings

Get

Sample Get Sensor Readings Request

curl --silent 'https://api.tempalert.io/devices/11666000000072050861/sensors/0/readings?readingStartDate=2015-06-01T00:00:00Z&readingEndDate=2015-06-30T00:00:00Z&UnitSystem=US' \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/devices/11666000000072050861/sensors/0/readings?readingStartDate=2015-06-01T00:00:00Z&readingEndDate=2015-06-30T00:00:00Z&UnitSystem=US',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get Sensor Readings Response

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Date: Fri, 15 Jan 2016 18:37:40 GMT
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 58
next: https://api.tempalert.io/devices/11666000000072050861/sensors/0/readings?pageIDToken=eyJkZXZpY2VJRCI6bnVsbCwic2Vuc29yUG9ydElEIjpudWxsLCJ1bml0U3lzdGVtIjoiVVMiLCJyZWFkaW5nU3RhcnREYXRlIjoiMjAxNS0wNi0wM1QwMzo1MzoxMS43NTAwMDAwWiIsInJlYWRpbmdFbmREYXRlIjoiMjAxNS0wNi0zMFQwMDowMDowMC4wMDAwMDAwWiIsInByb2Nlc3NlZEFmdGVyRGF0ZSI6bnVsbCwicGFnZUlEVG9rZW4iOm51bGx9
Content-Length: 319
{
  "readings": [
    {
      "readingType": "Temperature",
      "unit": "F",
      "readingValue": 82.04,
      "readingDate": "2015-06-02T23:08:06.2270000Z",
      "alarm": false,
      "processedDate": "2015-06-02T23:08:06.2270000Z"
    },
    {
      "readingType": "Humidity",
      "unit": "%",
      "readingValue": 41,
      "readingDate": "2015-06-02T23:08:06.2270000Z",
      "alarm": false,
      "processedDate": "2015-06-02T23:08:06.2270000Z"
    },
    {
      "readingType": "Temperature",
      "unit": "F",
      "readingValue": 77.36,
      "readingDate": "2015-06-03T03:24:05.7330000Z",
      "alarm": false,
      "processedDate": "2015-06-03T03:24:05.7330000Z"
    },
    {
      "readingType": "Humidity",
      "unit": "%",
      "readingValue": 50,
      "readingDate": "2015-06-03T03:24:05.7330000Z",
      "alarm": false,
      "processedDate": "2015-06-03T03:24:05.7330000Z"
    },
    {
      "readingType": "Temperature",
      "unit": "F",
      "readingValue": 78.08,
      "readingDate": "2015-06-03T03:53:11.7500000Z",
      "alarm": false,
      "processedDate": "2015-06-03T03:53:11.7500000Z"
    }
  ]
}

This endpoint gets all readings for the active sensor attached to the specified port on the specified device.

GET /devices/{deviceID}/sensors/{sensorPortID}/readings

Parameters

name location type required description
deviceID path string (max 20) yes Unique identifier of the device for which the reading data is going to be fetched.
sensorPortID path integer (32 bit) yes Port number of the device to which the sensor is attached.
unitSystem query string string (max 6) no Indicates what unit system to use when returning reading values. Possible values are “Metric” or “US”. Default is Metric.
readingStartDate query string datetime no Limit the result set to readings with a readingDate greater than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
readingEndDate query string datetime no Limit the result set to readings with a readingDate less than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
processedAfterDate query string datetime no Limit the result set to readings that have been processed after the specified date. See processedDate vs. readingDate

Output Fields

name type description
readingType string (max 50) Specifies the type of reading. Example device reading types: Power, Signal Strength, etc. Example sensor reading types: Temperature, Humidity, Pressure, etc.
unit string (max 15) Specifies what unit the reading is being reported in. Examples are F, PSI, % etc.
readingValue decimal(9,4) Reading value.
readingDate datetime Date at which the reading was made.
alarm boolean Indicates if this reading violated an alert threshold configured in Sensor Cloud.
processedDate date Date at which the reading was processed by Sensor Cloud. See processedDate vs. readingDate

Responses

Code Description
200 Success
404 Not Found

Get Recent

This endpoint gets the most recent reading(s) for the sensor attached to the specified port on the specified device.

GET /devices/{deviceID}/sensors/{sensorPortID}/readings/last

Parameters

name location type required description
deviceID path string (max 20) yes Unique identifier of the device for which the reading data is going to be fetched.
sensorPortID path integer (32 bit) yes Port number of the device to which the sensor is attached.
unitSystem query string string (max 6) no Indicates what unit system to use when returning reading values. Possible values are “Metric” or “US”. Default is Metric.
count query string integer (8 bit) no Specify the number of recent readings to return, up to a maximum of 10. Default is 1. Multiple readings are returned in reverse chronological order.

Output Fields

Same as /devices/{deviceID}/sensors/{sensorPortID}/readings endpoint

Responses

Code Description
200 Success
404 Not Found

All Sensors

This endpoint gets readings for all active sensors in the account to which this API client has access.

Sample Request (All Sensors)

curl --silent 'https://api.tempalert.io/sensors/readings?readingStartDate=2016-04-01T00:04:00Z&readingEndDate=2016-04-01T00:10:00Z' \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\

Sample Response (All Sensors)

HTTP/1.1 200 OK
Content-Type: application/json
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 58
Content-Length: 841
{
  "sensors": [
    {
      "deviceID": "11666000000108238145",
      "port": 0,
      "readings": [
        {
          "readingDate": "2016-04-01T00:04:23.2130000Z",
          "readingType": "Temperature",
          "unit": "C",
          "processedDate": "2016-04-01T00:04:30.5740000Z",
          "alarm": false,
          "readingValue": 22.1
        }
      ]
    },
    {
      "deviceID": "11666000000108238145",
      "port": 3,
      "readings": [
        {
          "readingType": "Humidity",
          "unit": "%",
          "readingValue": 50,
          "readingDate": "2015-04-01T00:05:05.7330000Z",
          "alarm": false,
          "processedDate": "2015-06-03T03:24:05.7330000Z"
        },
        {
          "readingType": "Humidity",
          "unit": "%",
          "readingValue": 50,
          "readingDate": "2015-04-01T00:07:05.7330000Z",
          "alarm": false,
          "processedDate": "2015-06-03T03:24:05.7330000Z"
        }
      ]
    }
  ]
}

GET /sensors/readings

Parameters

name location type required description
unitSystem query string string (max 6) no Indicates what unit system to use when returning reading values. Possible values are “Metric” or “US”. Default is Metric.
readingStartDate query string datetime no Limit the result set to readings with a readingDate greater than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
readingEndDate query string datetime no Limit the result set to readings with a readingDate less than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
processedAfterDate query string datetime no Limit the result set to readings that have been processed after the specified date. See processedDate vs. readingDate

Output Fields

Same as /devices/{deviceID}/sensors/{sensorPortID}/readings endpoint

Responses

Code Description
200 Success

Device Readings

Some devices return their own readings, independent of any attached sensors (e.g. A cellular gateway records its signal strength and transmits it to the server). This information is available via the device readings endpoints.

Get

Sample Get Device Readings Request

curl --silent "https://api.tempalert.io/devices/11666000000108240789/readings" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"           
r = requests.get('https://api.tempalert.io/devices/11666000000108240789/readings',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get Device Readings Response

HTTP/1.1 200 OK
Content-Type: application/json
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 58
next: https://api.tempalert.io/devices/11666000000108240789/readings?pageIDToken=eyJkZXZpY2VJRCI6bnVsbCwic2Vuc29VtIjpudWxsLCJyZWFkaW5nU3RhcnREYXRlIjoiMjAxNS0wNy0wMVQxOToyNzo1Ny42NzAwMDAwWiIsInJlYWRpbmdFbmREYXRlIjpudWxsLCJwcm9jZXNzZWRBZnRlckRhdGUiOm51bGwsInBhZ2VJRFRva2VuIjpudWxsfQ==
Content-Length: 841
{
  "readings": [
    {
      "readingType": "Signal Strength",
      "unit": null,
      "readingValue": 7,
      "readingDate": "2015-07-01T19:18:02.4930000Z",
      "alarm": false,
      "processedDate": "2015-07-01T19:18:02.4930000Z"
    },
    {
      "readingType": "Power",
      "unit": null,
      "readingValue": 10,
      "readingDate": "2015-07-01T19:18:02.4930000Z",
      "alarm": false,
      "processedDate": "2015-07-01T19:18:02.4930000Z"
    },
    {
      "readingType": "Signal Strength",
      "unit": null,
      "readingValue": 7,
      "readingDate": "2015-07-01T19:22:58.0630000Z",
      "alarm": false,
      "processedDate": "2015-07-01T19:22:58.0630000Z"
    },
    {
      "readingType": "Power",
      "unit": null,
      "readingValue": 10,
      "readingDate": "2015-07-01T19:22:58.0630000Z",
      "alarm": false,
      "processedDate": "2015-07-01T19:22:58.0630000Z"
    },
    {
      "readingType": "Signal Strength",
      "unit": null,
      "readingValue": 7,
      "readingDate": "2015-07-01T19:27:57.6700000Z",
      "alarm": false,
      "processedDate": "2015-07-01T19:27:57.6700000Z"
    }
  ]
}

This endpoint gets device readings for the specified active device.

GET /devices/{deviceID}/readings

Parameters

name location type required description
deviceID path string (max 20) yes Unique identifier of the device for which the reading data is going to be fetched.
unitSystem query string string (max 6) no Indicates what unit system to use when returning reading values. Possible values are “Metric” or “US”. Default is Metric.
readingStartDate query string datetime no Limit the result set to readings with a readingDate greater than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
readingEndDate query string datetime no Limit the result set to readings with a readingDate less than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
processedAfterDate query string datetime no Limit the result set to readings that have been processed after the specified date. See processedDate vs. readingDate

Output Fields

name type description
readingType string (max 50) Specifies the type of reading. Example device reading types: Power, Signal Strength, etc. Example sensor reading types: Temperature, Humidity, Pressure, etc.
unit string (max 15) Specifies what unit the reading is being reported in. Examples are F, PSI, % etc.
readingValue decimal(9,4) Reading value.
readingDate datetime Date at which the reading was made.
alarm boolean Indicates if this reading violated an alert threshold configured in Sensor Cloud.
processedDate date Date at which the reading was processed by Sensor Cloud. See processedDate vs. readingDate

Responses

Code Description
200 Success
404 Not Found

Get Recent

This endpoint gets the most recent device reading(s) for the specified active device.

GET /devices/{deviceID}/readings/last

Parameters

name location type required description
deviceID path string (max 20) yes Unique identifier of the device for which the reading data is going to be fetched.
sensorPortID path integer (32 bit) yes Port number of the device to which the sensor is attached.
unitSystem query string string (max 6) no Indicates what unit system to use when returning reading values. Possible values are “Metric” or “US”. Default is Metric.
count query string integer (8 bit) no Specify the number of recent readings to return, up to a maximum of 10. Default is 1. Multiple readings are returned in reverse chronological order.

Output Fields

Same as /devices/{deviceID}/readings endpoint

Responses

Code Description
200 Success
404 Not Found

All Devices

This endpoint gets device readings for all active devices in the account to which this API client has access.

Sample Request (All Devices)

curl --silent "https://api.tempalert.io/devices/readings" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"

Sample Response (All Devices)

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 58
next: https://data.myalertlist.com/service/v4/devices/11666000000108240789/readings?pageIDToken=eyJkZXZpY2VJRCI6bnVsbCwic2Vuc29VtIjpudWxsLCJyZWFkaW5nU3RhcnREYXRlIjoiMjAxNS0wNy0wMVQxOToyNzo1Ny42NzAwMDAwWiIsInJlYWRpbmdFbmREYXRlIjpudWxsLCJwcm9jZXNzZWRBZnRlckRhdGUiOm51bGwsInBhZ2VJRFRva2VuIjpudWxsfQ==
Content-Length: 841
{
  "devices" : [
     {
       "deviceID" : "11666000000117952651",
       "readings" : [
            {
               "unit" : null,
               "readingValue" : 9,
               "readingType" : "Signal Strength",
               "processedDate" : "2016-04-13T15:59:20.6300000Z",
               "readingDate" : "2016-04-13T14:53:58.5370000Z",
               "alarm" : false
            }
         ]
      },
      {
         "deviceID" : "99270113184909686568",
         "readings" : [
            {
               "unit" : null,
               "readingType" : "Signal Strength",
               "readingValue" : 6,
               "processedDate" : "2016-04-13T15:34:29.3010000Z",
               "alarm" : false,
               "readingDate" : "2016-04-13T15:33:23.1470000Z"
            },
            {
               "unit" : null,
               "readingValue" : 25,
               "readingType" : "Power",
               "processedDate" : "2016-04-13T15:34:29.2550000Z",
               "alarm" : false,
               "readingDate" : "2016-04-13T15:33:23.1470000Z"
            },
            {
               "readingType" : "Signal Strength",
               "readingValue" : 6,
               "unit" : null,
               "readingDate" : "2016-04-13T15:44:35.7330000Z",
               "alarm" : false,
               "processedDate" : "2016-04-13T15:44:38.8250000Z"
            },
            {
               "alarm" : false,
               "readingDate" : "2016-04-13T15:44:35.7330000Z",
               "processedDate" : "2016-04-13T15:44:38.8090000Z",
               "readingType" : "Power",
               "readingValue" : 26,
               "unit" : null
           }
        ]
     }
   ]
}

GET /devices/readings

Parameters

name location type required description
unitSystem query string string (max 6) no Indicates what unit system to use when returning reading values. Possible values are “Metric” or “US”. Default is Metric.
readingStartDate query string datetime no Limit the result set to readings with a readingDate greater than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
readingEndDate query string datetime no Limit the result set to readings with a readingDate less than or equal to the specified date. In all cases, no readings older than 1 year will be returned.
processedAfterDate query string datetime no Limit the result set to readings that have been processed after the specified date. See processedDate vs. readingDate

Output Fields

Same as /devices/{deviceID}/readings endpoint

Responses

Code Description
200 Success

Group Types

Get All Group Types for Account

Sample Get All Group Types for Account Request

curl --silent "https://api.tempalert.io/grouptypes" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"
r = requests.get('https://api.tempalert.io/grouptypes',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get All Group Types for Account Response

HTTP/1.1 200 OK
Content-Type: application/json
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 58
Content-Length: 1152
{
    "groupTypes": [
        {
            "groupTypeName": "test",
            "groupTypeId": 1,
            "groupTypeKeys": [
                {
                    "groupTypeKeyId": 1,
                    "keyName": "keytest",
                    "isRequired": false,
                    "isEditable": false,
                    "valueType": "String"
                },
                {
                    "groupTypeKeyId": 26,
                    "keyName": "TestOnly- Phone",
                    "isRequired": true,
                    "isEditable": true,
                    "valueType": "Phone"
                }
            ]
        },
        {
            "groupTypeName": "Store",
            "groupTypeId": 6,
            "groupTypeKeys": [
                {
                    "groupTypeKeyId": 19,
                    "keyName": "Store Address",
                    "isRequired": false,
                    "isEditable": true,
                    "valueType": "String"
                },
                {
                    "groupTypeKeyId": 20,
                    "keyName": "Store City",
                    "isRequired": false,
                    "isEditable": true,
                    "valueType": "String"
                }
            ]
        }
    ]
}

Describes the Group Types that are configured for an account. This information can be used in conjunction with the Group endpoints to create and update groups through the API. Group metadata for your account is configured by the SmartSense onboarding team during account setup. Metadata values associated with individual groups are used by the alerting system to route notifications.

GET /accounts/grouptypes

Parameters

None

Output Fields

name type description
groupTypeName string Name of group type
groupTypeId long ID of group type
groupTypeKeys array An array describing the metadata keys that can be associated with this group type.
groupTypeKeys.groupTypeKeyId long ID of group type metadata key
groupTypeKeys.keyName string Human-readable name of the key
groupTypeKeys.isRequired bool Value required?
groupTypeKeys.isEditable bool Value editable?
groupTypeKeys.valueType string Type of field (e.g., String)

Groups

Get All Groups

Sample Get Groups Request

curl --silent "https://api.tempalert.io/groups" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"
import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"
r = requests.get('https://api.tempalert.io/groups',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

Sample Get Groups Response

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Rate-Limit-Limit: 60
Rate-Limit-Remaining: 59
Date: Tue, 26 Apr 2016 16:22:52 GMT
Content-Length: 2841
{
   "groups" : [
      {
         "groupID" : 10,
         "name" : "East Coast",
         "parentID" : null,
         "type" : null,
         "attributes" : {},
         "externalID": "ec1"
      },
      {
          "groupID" : 25691,
          "name" : "Massachusetts",
          "parentID" : 10,
          "type" : "state",
          "attributes" : {
              "area": "10,565 mi²"     
          },
          "externalID": null
      },
      {
          "groupID" : 25692,
          "name" : "Maine",
          "parentID" : 10,
          "type" : "state",
          "attributes" : {
            "area" : "35,385 mi²"
          },
          "externalID": "me1"
      },
      {
         "name" : "West Coast",
         "groupID" : 25693,
         "parentID" : null,
         "type" : null,
         "attributes" : {},
         "externalID": null
      },
      {
          "name" : "California",
          "groupID" : 25778,
          "parentID" : 25693,
          "type" : "state",
          "attributes" : {
            "area": "163,696 mi²"
          },
          "externalID": "ca1"
      },
      {
          "name" : "Los Angeles",
          "groupID" : 492,
          "parentID" : 25778,
          "type" : null,
          "attributes" : {},
          "externalID": null
      }
   ]
}

This endpoint gets all of the groups in the account to which the API client has access. Groups are returned as a flat list. The response may be broken up into pages, requiring multiple requests to retrieve all of the groups in the account.

GET /groups

GET Parameters

name location type required description
name query string string no Optional query parameter to filter groups by name. If specified, only groups whose name matches the parameter value are returned.
parentID query string integer (64 bit) no Optional query parameter to filter groups by parent ID. If specified only groups whose parent ID matches the parameter value are returned.
external ID path string (max 512) no Optional query parameter to filter groups by ExternalID. If specified only the group whose external ID matches the parameter value will be returned.

GET Output Fields

name type description
groupID integer (64 bit) Unique group identifier.
name string (max 255) Name of the group.
parentID integer (64 bit) ID of this group’s parent, if any, in the group hierarchy.
type string (max 50) This group’s “type” (may be null). The group type determines what attributes are available for this group.
attributes dictionary A dictionary of string key/value pairs. The set of valid key names is determined by the group type.
externalID string (max 512) Client specified identifier for a group. Unique per account,.

Get One

This endpoint gets a single group.

GET /groups/{groupID}

GET One Parameters

name location type required description
group ID path integer (64 bit) yes ID of group to retrieve.

GET One Output Fields

name type description
groupID integer (64 bit) Unique group identifier.
name string (max 255) Name of the group.
parentID integer (64 bit) ID of this group’s parent, if any, in the group hierarchy.
type string (max 50) This group’s “type” (may be null). The group type determines what attributes are available for this group.
attributes dictionary A dictionary of string key/value pairs. The set of valid key names is determined by the group type.
externalID string (max 512) Client specified identifier for a group. Unique per account,.

Create Group

Sample Create Group Request


curl --silent "https://api.tempalert.io/groups" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\
  --request POST \
  --data '{
        "name":"GroupName",
        "type":"Store",
        "parentGroupID":39794,
        "attributes":{
        "Store City":"CityName"
        }
    }'


import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"
payload = { 'name' : 'GroupName',
            'type' : 'Store',
            'parentGroupID' : 39794,
            'attributes' : {'Store City' : r"CityName"}
            }

r = requests.post('https://api.tempalert.io/groups',
                 headers={'Accept':'application/json', 'Authorization':'Bearer ' + credential_token},
                 json = payload,
                 timeout=5
                 )

print (r.text)

Sample Create Group Response:

HTTP/1.1 201 Created
Location: https://api.devalertlist.com/groups/39805

No Content

This endpoint creates a new group in Sensor Cloud. Upon success, the path to the new group is passed in the Location header of the response.

POST /groups

POST Parameters

name location type required description
name body string (max 255) yes Name of the group to create.
parentID body integer (64 bit) no If specified, the newly created group will be a subgroup of this parent group.
type body string (max 50) no Optional group type. Specified type must already exist.
attributes body dictionary no A dictionary of string key/value pairs. The set of valid key names is determined by the group type.
externalID body string (max 512) no Optional client specified identifier for a group. If provided, must be unique per account. Requests with non-unique values will be rejected.

POST Output Fields

name location type description
Location response header URI Path to the newly created group.

POST Responses

Code Description
201 Success - Group created
403 Forbidden - User does not have access to the specified parent group ID
404 Not Found - The specified group type does not exist
409 Conflict - A group already exists with that given parameters

Delete Group

This endpoint deletes a group. The group must not contain any devices or subgroups.

Sample Delete Group Request


curl --silent "https://api.tempalert.io/groups/12" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\
  --request DELETE

import json
import requests

credential_token="TOKEN_FROM_TEMPALERT"
r = requests.delete('https://api.tempalert.io/groups/12',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json',
                    'Content-Type': 'application/json'
                  },
                  timeout=5
                )
print (r.json())

DELETE /groups/{groupID}

DELETE Parameters

name location type required description
group ID path integer (64 bit) yes ID of group to be deleted

DELETE Output Fields

None.

DELETE Responses

Code Description
204 No Content
404 Not Found

Modify Group

This endpoint allows an existing group to be updated. When using this endpoint any new values specified are updated, while any values omitted are removed.

Sample Modify Group Request


curl --silent "https://api.tempalert.io/groups/12" \
  --header "Authorization: Bearer TOKEN_FROM_TEMPALERT" \
  --header "Accept: application/json"\
  --request PUT \
  --data '{ "name" : "New Group Name", 
              "parentID" : 26015, 
              "attributes" : {"Custom Time Zone" : "W. Central Africa Standard Time"} 
            }'


import json
import requests

parameters= { "name" : "New Group Name",
              "parentID" : 26015,
              "attributes" : {"Custom Time Zone" : "W. Central Africa Standard Time"}
            }
credential_token="TOKEN_FROM_TEMPALERT"
r = requests.put('https://api.tempalert.io/groups/12',
                  headers={
                    'Authorization':'Bearer ' + credential_token,
                    'Accept':'application/json',
                    'Content-Type': 'application/json'
                  },
                  json=parameters,
                  timeout=5
                )
print (r.json())

PUT /groups/{groupID}

PUT Parameters

name location type required description
name body string (max 255) yes New name of the group.
type body string (max 50) no Group type. Specified type must already exist.
attributes body dictionary no A dictionary of string key/value pairs. Valid key names are determined by the group type.
parentID body integer (64 bit) no ParentID of a group to move this group under. A group cannot be moved if it has subgroups.
externalID body string (max 512) no Optional client specified identifier for a group. If provided, must be unique per account. Requests with non-unique values will be rejected.

PUT Responses

Code Description
200 Success
404 Not Found
409 Conflict

Synchronizing Readings

Clients wishing to have their own copy of sensor or device readings can use the processedAfterDate query parameter to keep in sync with Sensor Cloud. Whenever the last “page” of results is returned from a query containing a processedAfterDate value, a header (nextProcessedAfterDate) is included in the response specifying the processedAfterDate value to use on the next query.

Example: Client Alice wants all sensor readings since March 1st, 2016 (UTC), as well as any readings that arrive after that point. Alice will poll Sensor Cloud every 15 minutes, using the processedAfterDate query parameter.

To begin, Alice makes the following request:

GET /sensors/readings?processedAfterDate="2016-03-01T00:00:00.00Z"

The response from the server may contain several “pages” of data. Each “page” (with the exception of the last “page”) will have a header in the response with a link to the next “page”. The final “page” will contain a nextProcessedAfterDate header with a datetime value. Alice saves this value as X.

After retrieving all “pages”, Alice now has a copy of all sensor readings from the account up to and including the datetime X.

After 15 minutes have passed, Alice once again queries Sensor Cloud for readings. This time, Alice uses a new value for processedAfterDate: specifically nextProcessedAfterDate value X from the last “page” of the previous request.
Sensor Cloud will then respond with any new readings that have arrived since Alice’s last query.

Alice continues to repeat this process every 15 minutes to stay in sync with Sensor Cloud.