ClearBlade IoT Core

setState: projects.locations.registries.devices

Sets the device’s state.

Note: This is a regional API.

You can find the URL and SystemKey required in the call by clicking API Keys (key icon) at the top-right of the Registry Details page.

A ClearBlade-UserToken header is required to call this API. Its value is set as follows:

  • If using IoT Core Standard the value can be either…

    • The Token found under API Keys OR

    • A JWT generated as specified here and signed by the private key of the device specified in the name Query parameter (see below). A JWT for any other user or device will be rejected.

  • If using IoT Core Enterprise the value MUST be a JWT generated as specified here and signed by the private key of the device specified in the name Query parameter (see below). A JWT for any other user or device will be rejected.

HTTP request

POST {URL}/api/v/4/webhook/execute/{SystemKey}/cloudiotdevice_devices

Query parameters

Parameters

name

string 

The device’s name. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0

or

projects/p0/locations/us-central1/registries/registry0/devices/{numId}.

The device’s name can be set to the deviceId or numId (i.e., without the project, location, and registry info. prepended).

method

string 

The value must be setState

Header parameters

Parameters

ClearBlade-UserToken

See the note at the start of this document on where to find the token.

Request body

The request body contains data with this structure:

JSON representation

{
  "state": {
    object(DeviceState)
  },
  "gatewayInfo": {
    object(GatewayInfo)
  }
}

Fields

state

object(DeviceState)

The device state.

gatewayInfo

object(GatewayInfo)

Set if the message is sent through a gateway or a gateway is making the request on a device’s behalf.

Response status codes

Code

Meaning

204

Success

Response body

If successful, the response body will be empty.

DeviceState

The device state reported to ClearBlade IoT Core.

JSON representation

{
  "binaryData": string
}

Fields

binaryData

string (bytes format)

Data in binary format.

A base64-encoded string.