Create Configuration Tasks

Create config tasks to apply the configurations to remote devices. This is suitable for bulk devices or a wealth of configuration parameters. For single device and simple parameter updates, please refer to Update Device Properties Incrementally.

Request URL

POST {base_url}/device/openapi/v1/tasks

Request Parameters

Table 1. Header Parameters
Parameter Required Type Description
Authorization Yes String The valid access token for making API calls.

The format should be Bearer {access_token}.

Table 2. Body Parameters
Parameter Required Type Description
type Yes Enum <String> The config template type for Auto Provision.
Valid value:
deviceIds Yes Array<Long> The unique ID of devices, which is returned when you add the device. The device IDs can be separated with comma or semicolon.
Note: If you did NOT save the deviceIDs, you can query the device's ID using Search Specific Devices.
config Yes JSON

The configuration for Auto Provision, which is presented in below JSON format. You can get the configuration template by Copy the content of Config Template or Getting the Configuration API, and change the configurations as required. Beside, you can also below formats to generate the configurations.

  • When the type is PROFILE, use below format to apply the configurations:
    {
       "version":"v1.0",   //config version (optional)
       "values":[
        {
            "key": "",
            "value": 
         }
        {
            "key": "",
            "value": 
         }
              .......
         ]
    }
    The values content can be referred to Default Profile Templates.
  • When the type is TSL, use below format to apply the configurations:
    {
       "version":"v1.0",   //config version (optional)
        "type": "tsl",   //TSL version (optional)
       "properties":{
            "reporting_interval": 600, 
              .......
         }
    }

    The properties content can be referred to Configuration Properties.

Response Parameters

Parameter Type Description
data Object<Task_Create_Result> Information of the task.
status String The result of the API request.
  • Success
  • Failed
requestId String The unique ID of the request, which can be used to quickly locate the request.
Task_Create_Result
Parameter Type Description
deviceTaskRelations String The device lists and their related tasks.
deviceId Long The unique ID of this device on Milesight Development Platform.
taskId Long The unique ID of the Config task generated on Milesight Development Platform.

Examples

Request example
Create a Config task to apply configuration to a VS133-P device.
POST /device/openapi/v1/devices HTTP/1.1
Host: demo.milesight.cam
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InllYXN0b25lLWRlZmF1bHQta2V5LWlkIn0.eyJncmFudF90eXBlIjoiY2xpZW50X2NyZWRlbnRpYWxzIiwic2NvcGUiOlsib3BlbmFwaSJdLCJjbGllbnRfZXh0Ijp7ImFwcF9pZCI6IjE3MzY5NTQ4MDE3MTMzMjgxMzAifSwiZXhwIjoxNzAzMjEzMDk4LCJhdXRob3JpdGllcyI6WyJST0xFX0NMSUVOVCJdLCJqdGkiOiJiYjJjN2U4Yy03NGQwLTQ4NjEtODE3MS1iYTc0NWRlMGY0NmQiLCJjbGllbnRfaWQiOiI4OTNkNzdjNy1mMGNiLTRmMzQtOWNhMS03YzJhNGNmMTEzNDgiLCJ0cyI6MTcwMzIwOTQ5ODMzNH0
Content-Type: application/json

{
  "type": "PROFILE",
  "deviceIds": [
    "1904041077351141377"
  ],
  "config": {
    "values": [
      {
        "key": "install_height",
        "value": 3000
      },
      {
        "key": "min_target_height",
        "value": 1000
      }
    ]
  }
}
Response example
HTTP/1.1 200 OK
{
  "data": {
    "deviceTaskRelations": [
      {
        "deviceId": "1904041077351141377",
        "taskId": "1904498522747006977"
      }
    ]
  },
  "status": "Success",
  "requestId": "de178ad55e213624facc3d82bb06cfe7"
}