Skip to main content

Device Actions

https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Below are the various requests that can be performed against the Device resource, as well as the expected parameters and the potential responses.

Command Stream​

Attach to a real time stream of command messages to this device using Server Sent Events (SSE)

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/commandStream

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.commandStream.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
keepAliveIntervalNNumber of seconds between keepalive messages2keepAliveInterval=2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/commandStream

SSE Stream for a Successful Response​

SSE stream of new command messages for this device

SSE Event NameTypeDescription
deviceCommandDevice CommandAn SSE event representing a single device command

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Delete​

Deletes a device

Method And Url​

DELETE https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Organization, all.Organization.bounded, all.User, all.User.bounded, device.*, or device.delete.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X DELETE \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Successful Responses​

CodeTypeDescription
200SuccessIf device was successfully deleted

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Export​

Creates a device data export. Defaults to all data.

Method And Url​

POST https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/export

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.export.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
startNStart time of export (ms since epoch - 0 means now, negative is relative to now)1start=1465790400000
endNEnd time of export (ms since epoch - 0 means now, negative is relative to now)0end=1465790400000
emailNEmail address to send export to. Defaults to current user's email.email=email@example.com
callbackUrlNCallback URL to call with export resultcallbackUrl=https://example.com/cburl
includeBlobDataNIf set will export any blob attributes in base64 form, otherwise they will be downloadable links which will expire.includeBlobData=true

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body​

The body of the request should be serialized JSON that validates against the Device Data Export schema. For example, the following would be a valid body for this request:

{
"email": "export@example.com",
"attributes": [
"voltage"
],
"end": 0,
"options": {
"includeDate": false,
"includeID": true
}
}

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/export

Successful Responses​

CodeTypeDescription
202Job Enqueued API ResultIf generation of export was successfully started

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Get​

Retrieves information on a device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.get.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
excludeConnectionInfoNIf set, do not return connection infoexcludeConnectionInfo=true
tagsAsObjectNReturn tags as an object map instead of an arraytagsAsObject=true
attributesAsObjectNReturn attributes as an object map instead of an arrayattributesAsObject=false

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Successful Responses​

CodeTypeDescription
200DeviceDevice information

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Get Command​

Retrieve the last known command(s) sent to the device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/command

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.getCommand.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
limitNMaximum number of command entries to return1limit=10
sinceN(deprecated) Look for command entries since this time (ms since epoch)since=1465790400000
sortDirectionNDirection to sort the command entries (by time). Accepted values are: asc, descdescsortDirection=desc
durationNDuration of time range to query in millisecondsduration=86400000
startNStart of time range to query in milliseconds since epochstart=1465790400000
endNEnd of time range to query in milliseconds since epochend=0

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/command

Successful Responses​

CodeTypeDescription
200Device CommandsRecent device commands

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Get Composite State​

Retrieve the composite last complete state of the device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/compositeState

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.getCompositeState.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
startNStart of time range to look at to build composite state1start=1465790400000
endNEnd of time range to look at to build composite state0end=1465790400000
attributesNComma-separated list of attributes to include. When not provided, returns all attributes.attributes=myAttr1,myAttr2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/compositeState

Successful Responses​

CodeTypeDescription
200Composite Device StateComposite last state of the device

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Get Log Entries​

Retrieve the recent log entries about the device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/logs

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.getLogEntries.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
limitNMaximum number of log entries to return1limit=10
sinceN(deprecated) Look for log entries since this time (ms since epoch)since=1465790400000
sortDirectionNDirection to sort the log entries (by time). Accepted values are: asc, descdescsortDirection=desc
durationNDuration of time range to query in millisecondsduration=86400000
startNStart of time range to query in milliseconds since epochstart=1465790400000
endNEnd of time range to query in milliseconds since epochend=0

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/logs

Successful Responses​

CodeTypeDescription
200Device LogRecent log entries

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Get State​

Retrieve the last known state(s) of the device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/state

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.getState.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
limitNMaximum number of state entries to return1limit=10
sinceN(deprecated) Look for state entries since this time (ms since epoch)since=1465790400000
sortDirectionNDirection to sort the state entries (by time). Accepted values are: asc, descdescsortDirection=desc
durationNDuration of time range to query in millisecondsduration=86400000
startNStart of time range to query in milliseconds since epochstart=1465790400000
endNEnd of time range to query in milliseconds since epochend=0

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/state

Successful Responses​

CodeTypeDescription
200Device StatesRecent device states

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Patch​

Updates information about a device

Method And Url​

PATCH https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Organization, all.Organization.bounded, all.User, all.User.bounded, device.*, or device.patch.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
tagsAsObjectNReturn tags as an object map instead of an arraytagsAsObject=true
attributesAsObjectNReturn attributes as an object map instead of an arrayattributesAsObject=false

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body​

The body of the request should be serialized JSON that validates against the Device Patch schema. For example, the following would be a valid body for this request:

{
"name": "My Updated Device",
"description": "Description of my updated device",
"tags": [
{
"key": "TagKey",
"value": "TagValue"
}
],
"attributes": [
{
"name": "voltage",
"dataType": "number"
}
],
"deviceClass": "standalone"
}

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X PATCH \
-d '{"name":"My Updated Device","description":"Description of my updated device","tags":[{"key":"TagKey","value":"TagValue"}],"attributes":[{"name":"voltage","dataType":"number"}],"deviceClass":"standalone"}' \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID

Successful Responses​

CodeTypeDescription
200DeviceUpdated device information

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Payload Counts​

Returns payload counts for the time range specified for this device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/payloadCounts

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.payloadCounts.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
startNStart of range for payload count query (ms since epoch)-2592000000start=0
endNEnd of range for payload count query (ms since epoch)0end=1465790400000

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/payloadCounts

Successful Responses​

CodeTypeDescription
200Device Payload CountsPayload counts, by type

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Payload Counts Breakdown​

Returns payload counts per resolution in the time range specified for this device

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/payloadCountsBreakdown

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.payloadCountsBreakdown.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
startNStart of range for payload count query (ms since epoch)-2592000000start=0
endNEnd of range for payload count query (ms since epoch)0end=1465790400000
resolutionNResolution in milliseconds. Accepted values are: 86400000, 360000086400000resolution=86400000

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/payloadCountsBreakdown

Successful Responses​

CodeTypeDescription
200Payload Counts BreakdownSum of payload counts by date

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Remove Data​

Removes all device data for the specified time range. Defaults to all data.

Method And Url​

DELETE https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/data

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Organization, all.Organization.bounded, all.User, all.User.bounded, device.*, or device.removeData.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
startNStart time of export (ms since epoch - 0 means now, negative is relative to now)1start=1465790400000
endNEnd time of export (ms since epoch - 0 means now, negative is relative to now)0end=1465790400000

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X DELETE \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/data

Successful Responses​

CodeTypeDescription
202Job Enqueued API ResultIf data removal was successfully started

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Send Command​

Send a command to a device

Method And Url​

POST https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/command

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Device, all.Organization, all.Organization.bounded, all.User, all.User.bounded, device.*, or device.sendCommand.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body​

The body of the request should be serialized JSON that validates against the Device Command schema. For example, the following would be a valid body for this request:

{
"time": "2016-06-13T04:00:00.000Z",
"name": "myCommand",
"payload": [
1,
1,
2,
3,
5
]
}

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-d '{"time":"2016-06-13T04:00:00.000Z","name":"myCommand","payload":[1,1,2,3,5]}' \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/command

Successful Responses​

CodeTypeDescription
200SuccessIf command was successfully sent

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Send State​

Send the current state of the device

Method And Url​

POST https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/state

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Device, all.Organization, all.Organization.bounded, all.User, all.User.bounded, device.*, or device.sendState.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body​

The body of the request should be serialized JSON that validates against the Device State or States schema. For example, the following would be a valid body for this request:

{
"time": "2016-06-13T04:00:00.000Z",
"data": {
"voltage": 22.4
}
}

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-d '{"time":"2016-06-13T04:00:00.000Z","data":{"voltage":22.4}}' \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/state

Successful Responses​

CodeTypeDescription
200SuccessIf state was successfully received

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Set Connection Status​

Set the current connection status of the device

Method And Url​

POST https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/setConnectionStatus

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Device, all.Organization, all.Organization.bounded, all.User, all.User.bounded, device.*, or device.setConnectionStatus.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Request Body​

The body of the request should be serialized JSON that validates against the Device Connection Status schema. For example, the following would be a valid body for this request:

{
"status": "connected"
}

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X POST \
-d '{"status":"connected"}' \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/setConnectionStatus

Successful Responses​

CodeTypeDescription
200SuccessIf connection status was successfully applied

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

State Stream​

Attach to a real time stream of state messages from this device using Server Sent Events (SSE)

Method And Url​

GET https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/stateStream

Authentication​

A valid API access token is required to access this endpoint. The token must include at least one of the following scopes: all.Application, all.Application.bounded, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.bounded, all.Organization.read, all.User, all.User.bounded, all.User.read, device.*, or device.stateStream.

Request Path Components​

Path ComponentDescriptionExample
APPLICATION_IDID associated with the application575ec8687ae143cd83dc4a97
DEVICE_IDID associated with the device575ecf887ae143cd83dc4aa2

Request Query Parameters​

NameRequiredDescriptionDefaultExample
keepAliveIntervalNNumber of seconds between keepalive messages2keepAliveInterval=2

Request Headers​

NameRequiredDescriptionDefault
AuthorizationYThe token for authenticating the request, prepended with Bearer

Curl Example​

curl -H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_API_ACCESS_TOKEN' \
-X GET \
https://api.losant.com/applications/APPLICATION_ID/devices/DEVICE_ID/stateStream

SSE Stream for a Successful Response​

SSE stream of new state messages for this device

SSE Event NameTypeDescription
deviceStateDevice StateAn SSE event representing a single device state

Error Responses​

CodeTypeDescription
400ErrorError if malformed request
404ErrorError if device was not found

Schemas​

Composite Device State​

Schema for a composite Device state

Composite Device State Schema​

  • ▶
    {} 4 keys
    • "http://json-schema.org/draft-07/schema#"
    • "object"
    • ▶
      {} 1 key
      • false

    Composite Device State Example​

    • ▶
      {} 2 keys
      • ▶
        {} 2 keys
        • ▶
          {} 2 keys

        Device​

        Schema for a single Device

        Device Schema​

        • ▶
          {} 3 keys
          • "http://json-schema.org/draft-07/schema#"
          • "object"
          • ▶
            {} 18 keys
            • ▶
              {} 2 keys
              • ▶
                {} 2 keys
                • ▶
                  {} 2 keys
                  • ▶
                    {} 2 keys
                    • ▶
                      {} 2 keys
                      • ▶
                        {} 2 keys
                        • ▶
                          {} 3 keys
                          • ▶
                            {} 2 keys
                            • ▶
                              {} 1 key
                              • ▶
                                {} 1 key
                                • ▶
                                  {} 2 keys
                                  • ▶
                                    {} 2 keys
                                    • ▶
                                      {} 2 keys
                                      • ▶
                                        {} 2 keys
                                        • ▶
                                          {} 1 key
                                          • ▶
                                            {} 3 keys
                                            • ▶
                                              {} 3 keys
                                              • ▶
                                                {} 1 key

                                            Device Example​

                                            • ▶
                                              {} 12 keys
                                              • "575ecf887ae143cd83dc4aa2"
                                              • "575ecf887ae143cd83dc4aa2"
                                              • "575ec8687ae143cd83dc4a97"
                                              • "2016-06-13T04:00:00.000Z"
                                              • "2016-06-13T04:00:00.000Z"
                                              • "My Device"
                                              • "A device description"
                                              • ▶
                                                [] 2 items
                                                • ▶
                                                  [] 1 item
                                                  • "5d8a0da7ce2f3d37c205d0c5"
                                                  • "standalone"
                                                  • ▶
                                                    {} 2 keys

                                                  Device Command​

                                                  Schema for a command for a single Device

                                                  Device Command Schema​

                                                  • ▶
                                                    {} 5 keys
                                                    • "http://json-schema.org/draft-07/schema#"
                                                    • "object"
                                                    • ▶
                                                      {} 3 keys
                                                      • ▶
                                                        {} 1 key
                                                        • ▶
                                                          {} 3 keys
                                                          • {} 0 keys
                                                          • ▶
                                                            [] 1 item
                                                            • false

                                                          Device Command Example​

                                                          • ▶
                                                            {} 3 keys
                                                            • "2016-06-13T04:00:00.000Z"
                                                            • "myCommand"
                                                            • ▶
                                                              [] 5 items

                                                            Device Commands​

                                                            Schema for an array of Device Commands

                                                            Device Commands Schema​

                                                            • ▶
                                                              {} 3 keys
                                                              • "http://json-schema.org/draft-07/schema#"
                                                              • "array"
                                                              • ▶
                                                                {} 6 keys

                                                              Device Commands Example​

                                                              • ▶
                                                                [] 2 items
                                                                • ▶
                                                                  {} 3 keys
                                                                  • ▶
                                                                    {} 3 keys

                                                                  Device Connection Status​

                                                                  Schema for the body of a request to set a device's connection status

                                                                  Device Connection Status Schema​

                                                                  • ▶
                                                                    {} 4 keys
                                                                    • "http://json-schema.org/draft-07/schema#"
                                                                    • "object"
                                                                    • ▶
                                                                      {} 1 key
                                                                      • ▶
                                                                        [] 2 items

                                                                      Device Connection Status Example​

                                                                      • ▶
                                                                        {} 1 key
                                                                        • "connected"

                                                                      Device Data Export​

                                                                      Schema for exporting the data for a single device

                                                                      Device Data Export Schema​

                                                                      • ▶
                                                                        {} 4 keys
                                                                        • "http://json-schema.org/draft-07/schema#"
                                                                        • "object"
                                                                        • ▶
                                                                          {} 6 keys
                                                                          • ▶
                                                                            {} 3 keys
                                                                            • ▶
                                                                              {} 3 keys
                                                                              • ▶
                                                                                {} 3 keys
                                                                                • ▶
                                                                                  {} 1 key
                                                                                  • ▶
                                                                                    {} 1 key
                                                                                    • ▶
                                                                                      {} 2 keys
                                                                                    • false

                                                                                  Device Data Export Example​

                                                                                  • ▶
                                                                                    {} 4 keys
                                                                                    • "export@example.com"
                                                                                    • ▶
                                                                                      [] 1 item
                                                                                      • 0
                                                                                      • ▶
                                                                                        {} 2 keys

                                                                                      Device Log​

                                                                                      Log of connection information for a Device

                                                                                      Device Log Schema​

                                                                                      • ▶
                                                                                        {} 3 keys
                                                                                        • "http://json-schema.org/draft-07/schema#"
                                                                                        • "array"
                                                                                        • ▶
                                                                                          {} 2 keys

                                                                                        Device Log Example​

                                                                                        • ▶
                                                                                          [] 5 items
                                                                                          • ▶
                                                                                            {} 2 keys
                                                                                            • ▶
                                                                                              {} 5 keys
                                                                                              • ▶
                                                                                                {} 2 keys
                                                                                                • ▶
                                                                                                  {} 5 keys
                                                                                                  • ▶
                                                                                                    {} 2 keys

                                                                                                  Device Patch​

                                                                                                  Schema for the body of a Device modification request

                                                                                                  Device Patch Schema​

                                                                                                  • ▶
                                                                                                    {} 4 keys
                                                                                                    • "http://json-schema.org/draft-07/schema#"
                                                                                                    • "object"
                                                                                                    • ▶
                                                                                                      {} 9 keys
                                                                                                      • ▶
                                                                                                        {} 3 keys
                                                                                                        • ▶
                                                                                                          {} 2 keys
                                                                                                          • ▶
                                                                                                            {} 3 keys
                                                                                                            • ▶
                                                                                                              {} 3 keys
                                                                                                              • ▶
                                                                                                                {} 2 keys
                                                                                                                • ▶
                                                                                                                  {} 2 keys
                                                                                                                  • ▶
                                                                                                                    {} 1 key
                                                                                                                    • ▶
                                                                                                                      {} 3 keys
                                                                                                                      • ▶
                                                                                                                        {} 1 key
                                                                                                                      • false

                                                                                                                    Device Patch Example​

                                                                                                                    • ▶
                                                                                                                      {} 5 keys
                                                                                                                      • "My Updated Device"
                                                                                                                      • "Description of my updated device"
                                                                                                                      • ▶
                                                                                                                        [] 1 item
                                                                                                                        • ▶
                                                                                                                          [] 1 item
                                                                                                                          • "standalone"

                                                                                                                        Device Payload Counts​

                                                                                                                        Schema for the result of a device payload count request

                                                                                                                        Device Payload Counts Schema​

                                                                                                                        • ▶
                                                                                                                          {} 3 keys
                                                                                                                          • "http://json-schema.org/draft-07/schema#"
                                                                                                                          • "object"
                                                                                                                          • ▶
                                                                                                                            {} 6 keys
                                                                                                                            • ▶
                                                                                                                              {} 1 key
                                                                                                                              • ▶
                                                                                                                                {} 1 key
                                                                                                                                • ▶
                                                                                                                                  {} 1 key
                                                                                                                                  • ▶
                                                                                                                                    {} 1 key
                                                                                                                                    • ▶
                                                                                                                                      {} 1 key
                                                                                                                                      • ▶
                                                                                                                                        {} 1 key

                                                                                                                                    Device Payload Counts Example​

                                                                                                                                    • ▶
                                                                                                                                      {} 4 keys
                                                                                                                                      • 1244049
                                                                                                                                      • 12
                                                                                                                                      • 1016
                                                                                                                                      • 1016

                                                                                                                                    Device State​

                                                                                                                                    Schema for a single Device state

                                                                                                                                    Device State Schema​

                                                                                                                                    • ▶
                                                                                                                                      {} 5 keys
                                                                                                                                      • "http://json-schema.org/draft-07/schema#"
                                                                                                                                      • "object"
                                                                                                                                      • ▶
                                                                                                                                        {} 4 keys
                                                                                                                                        • ▶
                                                                                                                                          {} 1 key
                                                                                                                                          • {} 0 keys
                                                                                                                                            • ▶
                                                                                                                                              {} 3 keys
                                                                                                                                              • ▶
                                                                                                                                                {} 3 keys
                                                                                                                                              • ▶
                                                                                                                                                [] 1 item
                                                                                                                                                • false

                                                                                                                                              Device State Example​

                                                                                                                                              • ▶
                                                                                                                                                {} 2 keys
                                                                                                                                                • "2016-06-13T04:00:00.000Z"
                                                                                                                                                • ▶
                                                                                                                                                  {} 1 key

                                                                                                                                                Device State or States​

                                                                                                                                                Schema for a single device state or an array of device states

                                                                                                                                                Device State or States Schema​

                                                                                                                                                • ▶
                                                                                                                                                  {} 2 keys
                                                                                                                                                  • "http://json-schema.org/draft-07/schema#"
                                                                                                                                                  • ▶
                                                                                                                                                    [] 2 items

                                                                                                                                                  Device State or States Example​

                                                                                                                                                  • ▶
                                                                                                                                                    {} 2 keys
                                                                                                                                                    • "2016-06-13T04:00:00.000Z"
                                                                                                                                                    • ▶
                                                                                                                                                      {} 1 key

                                                                                                                                                    Device States​

                                                                                                                                                    Schema for an array of Device states

                                                                                                                                                    Device States Schema​

                                                                                                                                                    • ▶
                                                                                                                                                      {} 3 keys
                                                                                                                                                      • "http://json-schema.org/draft-07/schema#"
                                                                                                                                                      • "array"
                                                                                                                                                      • ▶
                                                                                                                                                        {} 6 keys

                                                                                                                                                      Device States Example​

                                                                                                                                                      • ▶
                                                                                                                                                        [] 2 items
                                                                                                                                                        • ▶
                                                                                                                                                          {} 2 keys
                                                                                                                                                          • ▶
                                                                                                                                                            {} 2 keys

                                                                                                                                                          Error​

                                                                                                                                                          Schema for errors returned by the API

                                                                                                                                                          Error Schema​

                                                                                                                                                          • ▶
                                                                                                                                                            {} 3 keys
                                                                                                                                                            • "http://json-schema.org/draft-07/schema#"
                                                                                                                                                            • "object"
                                                                                                                                                            • ▶
                                                                                                                                                              {} 3 keys
                                                                                                                                                              • ▶
                                                                                                                                                                {} 1 key
                                                                                                                                                                • ▶
                                                                                                                                                                  {} 1 key
                                                                                                                                                                  • ▶
                                                                                                                                                                    {} 2 keys

                                                                                                                                                                Error Example​

                                                                                                                                                                • ▶
                                                                                                                                                                  {} 2 keys
                                                                                                                                                                  • "NotFound"
                                                                                                                                                                  • "Application was not found"

                                                                                                                                                                Job Enqueued API Result​

                                                                                                                                                                Schema for the result of a job being queued

                                                                                                                                                                Job Enqueued API Result Schema​

                                                                                                                                                                • ▶
                                                                                                                                                                  {} 3 keys
                                                                                                                                                                  • "http://json-schema.org/draft-07/schema#"
                                                                                                                                                                  • "object"
                                                                                                                                                                  • ▶
                                                                                                                                                                    {} 3 keys
                                                                                                                                                                    • ▶
                                                                                                                                                                      {} 2 keys
                                                                                                                                                                      • ▶
                                                                                                                                                                        {} 2 keys
                                                                                                                                                                        • ▶
                                                                                                                                                                          {} 2 keys

                                                                                                                                                                      Job Enqueued API Result Example​

                                                                                                                                                                      • ▶
                                                                                                                                                                        {} 3 keys
                                                                                                                                                                        • true
                                                                                                                                                                        • "clnHvJbyVkOWAZwYAwLP4"
                                                                                                                                                                        • true

                                                                                                                                                                      Payload Counts Breakdown​

                                                                                                                                                                      Schema for the result of a payload counts breakdown request

                                                                                                                                                                      Payload Counts Breakdown Schema​

                                                                                                                                                                      • ▶
                                                                                                                                                                        {} 3 keys
                                                                                                                                                                        • "http://json-schema.org/draft-07/schema#"
                                                                                                                                                                        • "object"
                                                                                                                                                                        • ▶
                                                                                                                                                                          {} 3 keys
                                                                                                                                                                          • ▶
                                                                                                                                                                            {} 2 keys
                                                                                                                                                                            • ▶
                                                                                                                                                                              {} 2 keys
                                                                                                                                                                              • ▶
                                                                                                                                                                                {} 2 keys

                                                                                                                                                                            Payload Counts Breakdown Example​

                                                                                                                                                                            • ▶
                                                                                                                                                                              {} 3 keys
                                                                                                                                                                              • "1999-05-20T05:00:00.000Z"
                                                                                                                                                                              • "1999-06-20T04:59:59.999Z"
                                                                                                                                                                              • ▶
                                                                                                                                                                                [] 1 item

                                                                                                                                                                              Success​

                                                                                                                                                                              Schema for reporting a successful operation

                                                                                                                                                                              Success Schema​

                                                                                                                                                                              • ▶
                                                                                                                                                                                {} 3 keys
                                                                                                                                                                                • "http://json-schema.org/draft-07/schema#"
                                                                                                                                                                                • "object"
                                                                                                                                                                                • ▶
                                                                                                                                                                                  {} 1 key
                                                                                                                                                                                  • ▶
                                                                                                                                                                                    {} 2 keys

                                                                                                                                                                                Success Example​

                                                                                                                                                                                • ▶
                                                                                                                                                                                  {} 1 key
                                                                                                                                                                                  • true

                                                                                                                                                                                Was this page helpful?


                                                                                                                                                                                Still looking for help? You can also search the Losant Forums or submit your question there.