Updated on 2024-06-27 GMT+08:00

Create a Device Proxy

Function

This API is used by an application to create a dynamic device proxy rule on the IoT platform for a child device to select a gateway to go online and report messages. That is, a child device under any gateway in the proxy group can go online through other devices in the proxy group. For details, see Gateway Updating Child Device Status) and Gateway Reporting Device Properties in Batches).

  • Max. device proxies for an instance: 10.

  • Max. TPS for an account to call this API: 1 (one request per second).

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v5/iot/{project_id}/device-proxies

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Parameter description: project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Parameter description: user token. You can obtain the token by calling the IAM API Obtaining a User Token Through Password Authentication. In the returned response header, X-Subject-Token is the desired user token. For details about how to obtain the token, see Token Authentication.

Instance-Id

No

String

Parameter description: instance ID. Unique identifier of each instance in the physical multi-tenant scenario. Mandatory for professional editions and recommended in other cases. Log in to the IoTDA console and choose Overview in the navigation pane to view the instance ID. For details, see Viewing Instance Details.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

proxy_name

Yes

String

Parameter description: device proxy name.

Minimum: 1

Maximum: 64

proxy_devices

Yes

Array of strings

Parameter description: device proxy list. All devices in the list share the gateway permission. That is, child devices under any gateway in the list can go online through any gateway in the group and report data. Value: Enter two to ten device IDs in the list. A device ID can contain up to 128 characters, including letters, digits, underscores (_), and hyphens (-). Recommended min. ID length: 4 characters.

effective_time_range

Yes

EffectiveTimeRange object

Parameter Description: validity period of a device proxy rule.

app_id

Yes

String

Parameter description: resource space ID, which specifies the resource space to which the created device belongs. Value: The value can contain a maximum of 36 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

Table 4 EffectiveTimeRange

Parameter

Mandatory

Type

Description

start_time

No

String

Time when the device proxy starts to take effect. Format (UTC time): yyyyMMdd'T'HHmmss'Z'.

end_time

No

String

Time when the device proxy expires. The value must be later than the value of start_time. Format (UTC time): yyyyMMdd'T'HHmmss'Z'.

Response Parameters

Status code: 201

Table 5 Response body parameters

Parameter

Type

Description

proxy_id

String

Parameter description: device proxy ID, which uniquely identifies a proxy rule.

proxy_name

String

Parameter description: device proxy name.

proxy_devices

Array of strings

Parameter description: device proxy group. All devices in the group share the gateway permission. That is, child devices under any gateway in the group can go online through any gateway in the group and report data.

effective_time_range

EffectiveTimeRangeResponseDTO object

Parameter Description: validity period of a device proxy rule.

app_id

String

Parameter description: resource space ID.

Table 6 EffectiveTimeRangeResponseDTO

Parameter

Type

Description

start_time

String

Time when the device proxy starts to take effect. Format (UTC time): yyyyMMdd'T'HHmmss'Z'.

end_time

String

Time when the device proxy expires. The value must be later than the value of start_time. Format (UTC time): yyyyMMdd'T'HHmmss'Z'.

Example Requests

Creates a device proxy.

POST https://{endpoint}/v5/iot/{project_id}/device-proxies

{
  "proxy_name" : "testAPP01",
  "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
  "proxy_devices" : [ "d4922d8a-6c8e-4396-852c-164aefa6638f", "d4922d8a-6c8e-4396-852c-164aefa6638g" ],
  "effective_time_range" : {
    "start_time" : "20200812T121212Z",
    "end_time" : "20210812T121212Z"
  }
}

Example Responses

Status code: 201

Created

{
  "proxy_id" : "04ed32dc1b0025b52fe3c01a27c2babc",
  "proxy_name" : "testAPP01",
  "app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka",
  "proxy_devices" : [ "d4922d8a-6c8e-4396-852c-164aefa6638f", "d4922d8a-6c8e-4396-852c-164aefa6638g" ],
  "effective_time_range" : {
    "start_time" : "20200812T121212Z",
    "end_time" : "20210812T121212Z"
  }
}

Status Codes

Status Code

Description

201

Created

400

Bad Request

401

Unauthorized

403

Forbidden

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.