Yandex Cloud
Documentation
PresentationContact UsTry it for free
© 2026 Direct Cursus Technology L.L.C.
Yandex IoT Core
  • Service shutdown
    • All guides
    • Sending messages
    • Subscribing a device or registry to receive messages
    • Exporting messages to Data Streams
    • Viewing a connection log
    • Viewing operations with service resources
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes
  • FAQ

In this article:

  • Getting started
  • Authentication
  • Subscribing a registry to device topics
  • Subscribing a registry to a single device’s topic
  • Subscribing a registry to topics of all devices added to it
  • Subscribing a device to registry topics
  • Subscribing a device to topics for device-specific commands
  • Subscribing a device to topics for commands intended for all devices
  • Subscribing to broker topics
  1. Step-by-step guides
  2. Subscribing a device or registry to receive messages

Subscribing to messages

Written by
Yandex Cloud
Updated at November 2, 2026
View in Markdown
  • Getting started
    • Authentication
  • Subscribing a registry to device topics
    • Subscribing a registry to a single device’s topic
    • Subscribing a registry to topics of all devices added to it
  • Subscribing a device to registry topics
    • Subscribing a device to topics for device-specific commands
    • Subscribing a device to topics for commands intended for all devices
  • Subscribing to broker topics

Warning

Yandex IoT Core is no longer available to new users.

Current users can create resources until November 1, 2026. Afterwards, the service will go read-only and cease to operate on December 1, 2026. For more information on the timing and procedure, see Service shutdown.

With a broker, you can subscribe to any topic that does not start with $ using either a certificate or username and password.

For registries and devices, the available topics are limited. You can subscribe:

  • Registry to device events using the $devices/<device_ID>/events or $registries/<registry_ID>/events topics.
  • Registry to device events using the $devices/<device_ID>/state or $registries/<registry_ID>/state persistent topics.
  • Device to registry commands using the $devices/<device_ID>/commands or $registries/<registry_ID>/commands topics.
  • Device to registry commands using the $devices/<device_ID>/config or $registries/<registry_ID>/config persistent topics.
  • Registry or device to device monitoring data using the $monitoring/<device_ID>/json topic.

To learn more about messaging, see Sending messages.

Warning

Registry topics and device topics are independent of each other. If a device sends data to a device telemetry topic, you can only receive this data by subscribing to that topic. The same applies to registry topics.

Getting startedGetting started

Set up resources:

  1. Optionally, create registry and device certificates.
  2. Create a registry.
  3. Add a certificate to the registry.
  4. Create a device.
  5. Add a certificate to the device.

AuthenticationAuthentication

To send messages, you need to get authenticated. You can use an X.509 certificate or a username and password for authentication. This section provides examples for both authentication methods.

Subscribing a registry to device topicsSubscribing a registry to device topics

You can subscribe a registry to topics of one, multiple, or all devices added to it.

Note

If you encounter an error while running a command, add the --debug flag and retry the command. This flag outputs a debug log when running the command, which helps troubleshoot the issue.

Subscribing a registry to a single device’s topicSubscribing a registry to a single device’s topic

CLI

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id.

If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  • Subscribe a registry to a device topic using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$devices/<device_ID>/events' \
      --qos 1
    
  • Subscribe a registry to a device’s persistent topic using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$devices/<device_ID>/state' \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Device topic for sending data.
    • --qos: Quality of service (QoS) level.
  • Subscribe a registry to a device topic using username and password authentication:

    yc iot mqtt subscribe \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$devices/<device_ID>/events' \
      --qos 1
    
  • Subscribe a registry to a device’s persistent topic using username and password authentication:

    yc iot mqtt subscribe \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$devices/<device_ID>/state' \
      --qos 1
    

    Where:

    • --username and --password: Username and password authentication parameters.
    • --topic: Device topic for sending data.
    • --qos: Quality of service (QoS) level.

Subscribing a registry to topics of all devices added to itSubscribing a registry to topics of all devices added to it

The registry will only receive data from devices that send messages to the $registries/<registry_ID>/events or $registries/<registry_ID>/state topic.

CLI
  • Subscribe a registry to topics of all devices using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$registries/<registry_ID>/events' \
      --qos 1
    
  • Subscribe a registry to persistent topics of all devices using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$registries/<registry_ID>/state' \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Registry topic for receiving data.
    • --qos: Quality of service (QoS) level.
  • Subscribe a registry to topics of all devices using username and password authentication:

    yc iot mqtt subscribe \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$registries/<registry_ID>/events' \
      --qos 1
    
  • Subscribe a registry to persistent topics of all devices using username and password authentication:

    yc iot mqtt subscribe \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$registries/<registry_ID>/state' \
      --qos 1
    

    Where:

    • --username and --password: Username and password authentication parameters.
    • --topic: Registry topic for receiving data.
    • --qos: Quality of service (QoS) level.

Subscribing a device to registry topicsSubscribing a device to registry topics

Registry commands can target a specific device or all devices in the registry. This involves using different topics.

Note

If you encounter an error while running a command, add the --debug flag and retry the command. This flag outputs a debug log when running the command, which helps troubleshoot the issue.

Subscribing a device to topics for device-specific commandsSubscribing a device to topics for device-specific commands

CLI
  • Subscribe a device to topics for device-specific commands using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$devices/<device_ID>/commands' \
      --qos 1
    
  • Subscribe a device to persistent topics for device-specific commands using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$devices/<device_ID>/config' \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Device topic for receiving commands.
    • --qos: Quality of service (QoS) level.
  • Subscribe a device to topics for device-specific commands using username and password authentication:

    yc iot mqtt subscribe \
      --username <device_ID> \
      --password <device_password> \
      --topic '$devices/<device_ID>/commands' \
      --qos 1
    
  • Subscribe a device to persistent topics for device-specific commands using username and password authentication:

    yc iot mqtt subscribe \
      --username <device_ID> \
      --password <device_password> \
      --topic '$devices/<device_ID>/config' \
      --qos 1
    

    Where:

    • --username and --password: Username and password authentication parameters.
    • --topic: Device topic for receiving commands.
    • --qos: Quality of service (QoS) level.

Subscribing a device to topics for commands intended for all devicesSubscribing a device to topics for commands intended for all devices

Only devices subscribed to the $registries/<registry_ID>/commands or $registries/<registry_ID>/config topic will receive commands.

CLI
  • Subscribe a device to command topics using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$registries/<registry_ID>/commands' \
      --qos 1
    
  • Subscribe a device to persistent command topics using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$registries/<registry_ID>/config' \
      --qos 2
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Registry topic for sending commands.
    • --qos: Quality of service (QoS) level.
  • Subscribe a device to command topics using username and password authentication:

    yc iot mqtt subscribe \
      --username <device_ID> \
      --password <device_password> \
      --topic '$registries/<registry_ID>/commands' \
      --qos 1
    
  • Subscribe a device to persistent command topics using username and password authentication:

    yc iot mqtt subscribe \
      --username <device_ID> \
      --password <device_password> \
      --topic '$registries/<registry_ID>/config' \
      --qos 1
    

    Where:

    • --username and --password: Username and password authentication parameters.
    • --topic: Registry topic for sending commands.
    • --qos: Quality of service (QoS) level.

Subscribing to broker topicsSubscribing to broker topics

When using a broker, you can subscribe to any topic using your username and password or any certificate assigned to the broker for authentication.

CLI
  • Subscribe to a topic using username and password authentication:

    yc iot mqtt subscribe \
      --username <broker_ID> \
      --password <broker_password> \
      --topic /my/custom/topic \
      --qos 1
    

    Where:

    • --username and --password: Username and password authentication parameters.
    • --topic: Topic name that matches the MQTT specification and does not start with $.
    • --qos: Quality of service (QoS) level.
  • Subscribe to a topic using certificate-based authentication:

    yc iot mqtt subscribe \
      --cert broker-cert.pem \
      --key broker-key.pem \
      --topic /my/custom/topic \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Topic name that matches the MQTT specification and does not start with $.
    • --qos: Quality of service (QoS) level.

Was the article helpful?

Previous
Sending messages
Next
Exporting messages to Data Streams
© 2026 Direct Cursus Technology L.L.C.