V2.5 Create Command Jobs¶
Create tasks to send commands to a batch of devices.
Request Format¶
POST https://{apigw-address}/connect-service/v2.5/commands?action=createJob
Request Parameters (URI)¶
Name  | 
Location (Path/Query)  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|---|
orgId  | 
Query  | 
Mandatory  | 
String  | 
The organization ID which the asset belongs to. How to get orgId>>  | 
Request Parameters (Body)¶
Name  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|
name  | 
Mandatory  | 
StringI18n  | 
The job name. For more details on the structure and locales supported, see Internationalized name struct.  | 
targetScope  | 
Mandatory  | 
Struct  | 
See TargetScope Struct.  | 
schedulePolicy  | 
Mandatory  | 
Struct  | 
|
timeoutPolicy  | 
Optional  | 
Struct  | 
See TimeoutPolicy Struct.  | 
retryPolicy  | 
Optional  | 
Struct  | 
See RetryPolicy Struct.  | 
desc  | 
Mandatory  | 
String  | 
The job description with no more than 100 characters.  | 
commandInfo  | 
Mandatory  | 
Struct  | 
See commandInfo Struct.  | 
TargetScope Struct ¶
Name  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|
targetType  | 
Mandatory  | 
String  | 
You can choose   | 
targetDevices  | 
Optional  | 
Struct  | 
The maximum number is 1000. The struct contains: 
  | 
SchedulePolicy Struct ¶
Name  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|
scheduleType  | 
Mandatory  | 
String  | 
You can choose   | 
disposableSchedulePolicy  | 
Optional  | 
Struct  | 
The struct contains   | 
TimeoutPolicy Struct ¶
Name  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|
inProgressTimeoutInSeconds  | 
Optional  | 
Integer  | 
From 1 to 900(30 by default)  | 
ttlTimeoutInSeconds  | 
Optional  | 
Integer  | 
From 0 to 172800(0 by default)  | 
RetryPolicy Struct ¶
Name  | 
Mandatory/Optional  | 
Data Type  | 
Description  | 
|---|---|---|---|
enableRetry  | 
Optional  | 
Boolean  | 
  | 
retryIntervalInSeconds  | 
Required when   | 
Number  | 
Automatic retry interval time (in seconds) after failure. Effective only when enableRetry is true. From 0 to 86400 (300 by default).  | 
retryCount  | 
Required when   | 
Number  | 
Maximum number of automatic retries. Effective only when enableRetry is true. From 1 to 10 (3 by default).  | 
CommandInfo Struct ¶
Name  | 
Data Type  | 
Description  | 
|---|---|---|
commandType  | 
String  | 
You can choose   | 
measurepointSetInfo  | 
Struct  | 
The struct contains 
  | 
serviceInvokeInfo  | 
Struct  | 
The struct contains 
  | 
Response Parameters¶
Name  | 
Data Type  | 
Description  | 
|---|---|---|
code  | 
Number  | 
Return code of a request.
+   | 
msg  | 
String  | 
The explanation to the return code. Its value is   | 
requestId  | 
String  | 
A unique ID to identify a request.  | 
data  | 
String  | 
Null.  | 
Samples¶
Request Sample¶
url: https://{apigw-address}/connect-service/v2.5/commands?action=createJob&orgId=yourOrgId
method: POST
requestBody:
{
    "timeoutPolicy": {
        "inProgressTimeoutInSeconds": 30,
        "ttlTimeoutInSeconds": 20
    },
    "retryPolicy": {
        "enableRetry": true,
        "retryCount": 3,
        "retryIntervalInSeconds": 300
    },
    "name": {
        "defaultValue": "commandJobName",
        "i18nValue": {
            "en_US": "name",
            "zh_CN": "中文名"
        }
    },
    "schedulePolicy": {
        "disposableSchedulePolicy": {
            "triggerTs": 1718952446317
        },
        "scheduleType": "DISPOSABLE"
    },
    "commandInfo": {
        "commandType": "SERVICE_INVOKE",
        "serviceInvokeInfo": {
            "inputData": {
                "input": 22
            },
            "serviceId": "serviceId"
        }
    },
    "targetScope": {
        "targetDevices": [{
            "deviceKey": "deviceKey",
            "productKey": "productKey"
        }],
        "targetType": "DEVICE_LIST"
    },
    "desc": "commandJobDescription"
}
Return Sample¶
{
    "code": 0,
    "msg": "OK",
    "requestId": "95c4bac0-476e-4d07-bd09-1ae096ea24a4",
    "data": "jobId"
}