---
title: "Execute Commands on a Device"
method: POST
path: "/devices/{deviceId}/commands"
tags: ["Devices"]
---

# Execute Commands on a Device

`POST /devices/{deviceId}/commands`

## Request

- Base URL: `https://api.smartthings.com/v1`
- URL: `https://api.smartthings.com/v1/devices/{deviceId}/commands`
- Auth: OAuth 2
  - Implicit: `https://auth-global.api.smartthings.com`
  - Scopes: `x:devices:*`
- TypeScript: <https://skmtc.dev/smartthings/apis/smartthings-api/docs/devices/:deviceId/commands/post.ts> (a function with typed inputs; its response is checked against the schema)

Execute a specified command on a device.

## Query parameters

- `ordered` boolean

## Request body

- DeviceCommandsRequest
  - `commands` DeviceCommand[]: An array of commands to execute on the device.
    - `component` string, ^[-_!.~'()*0-9a-zA-Z]{1,36}$: The name of the component on this device, default is 'main'. The component must be valid for the device.
    - `capability` string, required: Capability that this command relates to. This must be a capability of the component.
    - `command` string, required: Name of the command, this must be valid for the capability.
    - `arguments` object[]: Arguments of the command. All the required arguments defined in the capability's command argument definition must be provided. The type of the arguments are dependent on the type of the capability's command argument. Please refer to the capabilities definition at https://developer.smartthings.com/docs/devices/capabilities/capabilities-reference
    - `commandId` string: The id on the command that triggered this event, if applicable. Used for correlation of commands to events.

## Response `200`

Created commands.

- DeviceCommandsResponse
  - `results` CommandResult[]
    - `id` string, uuid: A UUID used for tracking the individual command.
    - `status` 'ACCEPTED' | 'COMPLETED' | 'FAILED': `ACCEPTED`: the command is processing but it's outcome is unknown `COMPLETED`: the command has successfully completed `FAILED`: the command has failed

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `403`: Forbidden
- `422`: Unprocessable Entity
- `429`: Too many requests
- `default`: Unexpected error

## Changes

- **2022-12-19** `adcacfc2749d`: 1 info
  - added the new optional `query` request parameter `ordered`

[Operation history](https://skmtc.dev/smartthings/apis/smartthings-api/changes/devices/:deviceId/commands/post.md)

---

[API](https://skmtc.dev/smartthings/apis/smartthings-api.md) - [All operations](https://skmtc.dev/smartthings/apis/smartthings-api/llms.txt) - [OpenAPI document](https://skmtc.dev/smartthings/apis/smartthings-api/revisions/2788a4236800?raw)
