Auto Subscribe

Update auto subscribe topic list

put/mqtt/auto_subscribe

Request

  • Base URL: https://docs.emqx.com/api/v5
  • URL: https://docs.emqx.com/api/v5/mqtt/auto_subscribe
  • Auth: one of:
    • HTTP basic
    • bearerAuth (a scheme the document does not define)

Request body

topicstring required

Topic name, placeholders are supported. For example: client/${clientid}/username/${username}/host/${host}/port/${port}<br/>Required field, and cannot be empty string

qosinteger

Default value 0. Quality of service.<br/>At most once (0)<br/>At least once (1)<br/>Exactly once (2)

rhinteger

Default value 0. This option is used to specify whether the server forwards the retained message to the client when establishing a subscription.<br/>Retain Handling is equal to 0, as long as the client successfully subscribes, the server will send the retained message.<br/>Retain Handling is equal to 1, if the client successfully subscribes and this subscription does not exist previously, the server sends the retained message. After all, sometimes the client re-initiate the subscription just to change the QoS, but it does not mean that it wants to receive the reserved messages again.<br/>Retain Handling is equal to 2, even if the client successfully subscribes, the server does not send the retained message.

rapinteger

Default value 0. This option is used to specify whether the server retains the RETAIN mark when forwarding messages to the client, and this option does not affect the RETAIN mark in the retained message. Therefore, when the option Retain As Publish is set to 0, the client will directly distinguish whether this is a normal forwarded message or a retained message according to the RETAIN mark in the message, instead of judging whether this message is the first received after subscribing(the forwarded message may be sent before the retained message, which depends on the specific implementation of different brokers).

nlinteger

Default value 0.<br/>MQTT v3.1.1: if you subscribe to the topic published by yourself, you will receive all messages that you published.<br/>MQTT v5: if you set this option as 1 when subscribing, the server will not forward the message you published to you.

Example request

[
  {
    "topic": "/clientid/${clientid}/username/${username}/host/${host}/port/${port}"
  }
]

Response

After the device logs in successfully, the subscription is automatically completed for the device through the pre-defined subscription representation. Supports the use of placeholders.

topicstring required

Topic name, placeholders are supported. For example: client/${clientid}/username/${username}/host/${host}/port/${port}<br/>Required field, and cannot be empty string

qosinteger

Default value 0. Quality of service.<br/>At most once (0)<br/>At least once (1)<br/>Exactly once (2)

rhinteger

Default value 0. This option is used to specify whether the server forwards the retained message to the client when establishing a subscription.<br/>Retain Handling is equal to 0, as long as the client successfully subscribes, the server will send the retained message.<br/>Retain Handling is equal to 1, if the client successfully subscribes and this subscription does not exist previously, the server sends the retained message. After all, sometimes the client re-initiate the subscription just to change the QoS, but it does not mean that it wants to receive the reserved messages again.<br/>Retain Handling is equal to 2, even if the client successfully subscribes, the server does not send the retained message.

rapinteger

Default value 0. This option is used to specify whether the server retains the RETAIN mark when forwarding messages to the client, and this option does not affect the RETAIN mark in the retained message. Therefore, when the option Retain As Publish is set to 0, the client will directly distinguish whether this is a normal forwarded message or a retained message according to the RETAIN mark in the message, instead of judging whether this message is the first received after subscribing(the forwarded message may be sent before the retained message, which depends on the specific implementation of different brokers).

nlinteger

Default value 0.<br/>MQTT v3.1.1: if you subscribe to the topic published by yourself, you will receive all messages that you published.<br/>MQTT v5: if you set this option as 1 when subscribing, the server will not forward the message you published to you.

Example response

[
  {
    "topic": "/clientid/${clientid}/username/${username}/host/${host}/port/${port}"
  }
]

Changes

No recorded changes to this operation across all 1 revision of this API.