Share via


Devices - Run Command

Run a device command
Run a command on a device.

POST https://{subdomain}.{baseDomain}/api/devices/{deviceId}/commands/{commandName}?api-version=2022-07-31

URI Parameters

Name In Required Type Description
baseDomain
path True

string

The base domain for all Azure IoT Central service requests.

commandName
path True

string

Name of this device command.

deviceId
path True

string

Unique ID of the device.

subdomain
path True

string

The application subdomain.

api-version
query True

string

The version of the API being called.

Request Body

Name Type Description
connectionTimeout

integer (int32)

minimum: 0
maximum: 30

Connection timeout in seconds to wait for a disconnected device to come online. Defaults to 0 seconds.

request

The payload for the device command, support any primitive types or object.

responseTimeout

integer (int32)

minimum: 5
maximum: 30

Response timeout in seconds to wait for a command completion on a device. Defaults to 30 seconds.

Responses

Name Type Description
201 Created

DeviceCommand

Success

Other Status Codes

Error

An error response received from the IoT Central Service.

Headers

x-ms-error-code: string

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Send command

Sample request

POST https://appsubdomain.azureiotcentral.com/api/devices/mx1/commands/CoolDown?api-version=2022-07-31

{
  "request": {
    "tempVal": 30
  }
}

Sample response

{}

Definitions

Name Description
DeviceCommand

The device command definition.

Error

The response error definition.

ErrorDetails

The detail information of the error.

DeviceCommand

The device command definition.

Name Type Description
connectionTimeout

integer (int32)

minimum: 0
maximum: 30

Connection timeout in seconds to wait for a disconnected device to come online. Defaults to 0 seconds.

id

string

The request ID of the device command execution.

request

The payload for the device command, support any primitive types or object.

response

The payload of the device command response, support any primitive types or object.

responseCode

integer (int32)

The status code of the device command response.

responseTimeout

integer (int32)

minimum: 5
maximum: 30

Response timeout in seconds to wait for a command completion on a device. Defaults to 30 seconds.

Error

The response error definition.

Name Type Description
error

ErrorDetails

Error details for current request.

ErrorDetails

The detail information of the error.

Name Type Description
code

string

Error code.

message

string

Error message details.

requestId

string

Correlation Id for current request.

time

string (date-time-rfc1123)

The time that error request failed.