CreateCommand
Creates a command. A command contains reusable configurations that can be applied before they are sent to the devices.
Request Syntax
PUT /commands/commandId HTTP/1.1
Content-type: application/json
{
"description": "string",
"displayName": "string",
"mandatoryParameters": [
{
"defaultValue": {
"B": boolean,
"BIN": blob,
"D": number,
"I": number,
"L": number,
"S": "string",
"UL": "string"
},
"description": "string",
"name": "string",
"type": "string",
"value": {
"B": boolean,
"BIN": blob,
"D": number,
"I": number,
"L": number,
"S": "string",
"UL": "string"
},
"valueConditions": [
{
"comparisonOperator": "string",
"operand": {
"number": "string",
"numberRange": {
"max": "string",
"min": "string"
},
"numbers": [ "string" ],
"string": "string",
"strings": [ "string" ]
}
}
]
}
],
"namespace": "string",
"payload": {
"content": blob,
"contentType": "string"
},
"payloadTemplate": "string",
"preprocessor": {
"awsJsonSubstitution": {
"outputFormat": "string"
}
},
"roleArn": "string",
"tags": [
{
"Key": "string",
"Value": "string"
}
]
}
URI Request Parameters
The request uses the following URI parameters.
- commandId
-
A unique identifier for the command. We recommend using UUID. Alpha-numeric characters, hyphens, and underscores are valid for use here.
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern:
[a-zA-Z0-9_-]+Required: Yes
Request Body
The request accepts the following data in JSON format.
- description
-
A short text decription of the command.
Type: String
Length Constraints: Maximum length of 2028.
Pattern:
[^\p{C}]*Required: No
- displayName
-
The user-friendly name in the console for the command. This name doesn't have to be unique. You can update the user-friendly name after you define it.
Type: String
Length Constraints: Maximum length of 64.
Pattern:
[^\p{C}]*Required: No
- mandatoryParameters
-
A list of parameters that are used by
StartCommandExecutionAPI for execution payload generation.Type: Array of CommandParameter objects
Array Members: Minimum number of 1 item.
Required: No
- namespace
-
The namespace of the command. The MQTT reserved topics and validations will be used for command executions according to the namespace setting.
Type: String
Valid Values:
AWS-IoT | AWS-IoT-FleetWiseRequired: No
- payload
-
The payload object for the static command.
You can upload a static payload file from your local storage that contains the instructions for the device to process. The payload file can use any format. To make sure that the device correctly interprets the payload, we recommend you to specify the payload content type.
Type: CommandPayload object
Required: No
- payloadTemplate
-
The payload template for the dynamic command.
Note
This parameter is required for dynamic commands where the command execution placeholders are supplied either from
mandatoryParametersor whenStartCommandExecutionis invoked.Type: String
Length Constraints: Maximum length of 32768.
Required: No
- preprocessor
-
Configuration that determines how
payloadTemplateis processed to generate command execution payload.Note
This parameter is required for dynamic commands, along with
payloadTemplate, andmandatoryParameters.Type: CommandPreprocessor object
Required: No
- roleArn
-
The IAM role that you must provide when using the
AWS-IoT-FleetWisenamespace. The role grants IoT Device Management the permission to access IoT FleetWise resources for generating the payload for the command. This field is not supported when you use theAWS-IoTnamespace.Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Required: No
-
Name-value pairs that are used as metadata to manage a command.
Type: Array of Tag objects
Required: No
Response Syntax
HTTP/1.1 200
Content-type: application/json
{
"commandArn": "string",
"commandId": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- commandArn
-
The Amazon Resource Number (ARN) of the command. For example,
arn:aws:iot:<region>:<accountid>:command/<commandId>Type: String
- commandId
-
The unique identifier for the command.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 64.
Pattern:
[a-zA-Z0-9_-]+
Errors
- ConflictException
-
The request conflicts with the current state of the resource.
- resourceId
-
A resource with the same name already exists.
HTTP Status Code: 409
- InternalServerException
-
Internal error from the service that indicates an unexpected error or that the service is unavailable.
HTTP Status Code: 500
- ServiceQuotaExceededException
-
Service quota has been exceeded.
HTTP Status Code: 402
- ThrottlingException
-
The rate exceeds the limit.
- message
-
The message for the exception.
HTTP Status Code: 400
- ValidationException
-
The request is not valid.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: