Devices - Execute Command

Execute a device command
Execute a command on a device.

POST https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/commands/{command_name}

URI Parameters

Name In Required Type Description
centralDnsSuffixInPath
path True
  • string

The DNS suffix used as the base for all Azure IoT Central service requests.

command_name
path True
  • string

Name of this device command.

device_id
path True
  • string

Unique ID of the device.

subdomain
path True
  • string

The application subdomain.

Request Body

Name Type Description
connectionTimeout
  • integer

Connection Timeout in seconds to wait for a disconnected device to come online. Acceptable timeout values are from 0 to 30 seconds. Defaults to 0 seconds.

request

The payload for the device command.

responseTimeout
  • integer

Response Timeout in seconds to wait for a command completion on a device. Acceptable timeout values are from 5 to 30 seconds. Defaults to 30 seconds.

Responses

Name Type Description
201 Created

Success

Examples

Send command

Sample Request

POST https://appsubdomain.azureiotcentral.com/api/preview/devices/mx1/commands/CoolDown
{
  "connectionTimeout": 10,
  "responseTimeout": 10,
  "request": {
    "tempVal": 30
  }
}

Sample Response

{
  "request": {
    "tempVal": 30
  },
  "connectionTimeout": 10,
  "responseTimeout": 10,
  "response": "Sample response value",
  "responseCode": 200
}

Definitions

DeviceCommand

Name Type Description
connectionTimeout
  • integer

Connection Timeout in seconds to wait for a disconnected device to come online. Acceptable timeout values are from 0 to 30 seconds. Defaults to 0 seconds.

id
  • string

The request ID of the device command execution.

request

The payload for the device command.

response

The payload of the device command response.

responseCode
  • integer

The status code of the device command response.

responseTimeout
  • integer

Response Timeout in seconds to wait for a command completion on a device. Acceptable timeout values are from 5 to 30 seconds. Defaults to 30 seconds.