Broadcasts a message to all devices of a specified product or all devices that subscribe to a specified topic.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes PubBroadcast

The operation that you want to perform. Set the value to PubBroadcast.

MessageContent String Yes aGVsbG93b3JsZA

The body of the message to be sent. The maximum size of a message is 64 KB.

To generate the message body, you must convert the raw message into binary data and perform Base64 encoding.

ProductKey String Yes aldeji3*****

The key of the product. The message is broadcasted to the devices that are specified by this parameter.

IotInstanceId String No iot_instc_pu****_c*-v64********

The ID of the instance. This parameter is not required for public instances. However, the parameter is required for the instances that you have purchased.

TopicFullName String No /broadcast/UPqSxj2vXXX/xxx

Valid values:

  • If you do not specify this parameter, messages are pushed to all online devices that are specified by the ProductKey parameter. Devices receive the message from the following broadcast topic: /sys/${productKey}/${deviceName}/broadcast/request/${MessageId}. The MessageId variable is generated by IoT Platform.
  • If you specify this parameter, messages are pushed to the devices that are specified by the ProductKey parameter and subscribe to the specified broadcast topic. You must specify a topic by using the following syntax: /broadcast/${productKey}/A custom field. Replace ${productKey} with the ProductKey parameter of the devices that receive the broadcast message. For the custom field, you can specify a value based on your needs.
Note
  • When you develop devices, use code to define a broadcast topic. You do not need to create a broadcast topic in the IoT Platform console.
  • A maximum of 1,000 devices can subscribe to a broadcast topic. If the number of devices exceeds the limit, you can divide the devices into different groups. For example, you can divide 5,000 devices into five groups each containing 1,000 devices. In this case, you need to call the broadcast topic 5 times and set the value of the custom field to group 1, group 2, group 3, group 4, and group 5, respectively. Then, configure the devices so that each group of devices subscribes to the corresponding broadcast topic.

In addition to the preceding exclusive request parameters, you must specify common request parameters when calling this API operation. For more information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
Code String iot.system.SystemException

The error code returned if the call failed. For more information about error codes, see Error codes.

ErrorMessage String A system exception occurred.

The error message returned if the call failed.

MessageId Long 1234291569964771840

The message ID generated by IoT Platform when the message is sent.

RequestId String BB71E443-4447-4024-A000-EDE09922891E

The globally unique ID generated by Alibaba Cloud for the request.

Success Boolean true

Indicates whether the call was successful. true indicates that the call was successful. false indicates that the call failed.

Examples

Sample requests

https://iot.cn-shanghai.aliyuncs.com/?Action=PubBroadcast
&ProductKey=al**********
&TopicFullName=/broadcast/UPqSxj2vXXX/xxx
&MessageContent=aGVsbG93b3JsZA
&<Common request parameters>

Sample success responses

XML format

<PubBroadcastResponse>
        <RequestId>BB71E443-4447-4024-A000-EDE09922891E</RequestId>
        <MessageId>1234291569964771840</MessageId>
        <Success>true</Success>
  </PubBroadcastResponse>

JSON format

{
      "RequestId":"BB71E443-4447-4024-A000-EDE09922891E",
      "MessageId":1234291569964771840,
      "Success":true
}

Error codes

For a list of error codes, visit the API Error Center.