Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • Yandex SIEM
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 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
  • Sending a data message
  • Sending data from a device to a device topic
  • Sending data from a device to a registry topic
  • Sending a command message
  • Sending a command to one device
  • Sending a command to all devices added to the registry
  • Sending a message in a broker
  1. Step-by-step guides
  2. Sending messages

Sending messages

Written by
Yandex Cloud
Updated at August 10, 2026
View in Markdown
  • Getting started
    • Authentication
  • Sending a data message
    • Sending data from a device to a device topic
    • Sending data from a device to a registry topic
  • Sending a command message
    • Sending a command to one device
    • Sending a command to all devices added to the registry
  • Sending a message in a broker

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.

Yandex IoT Core provides two resource management models:

  • When using a broker, you can send and receive messages in any topics that do not start with $.
  • When using registries and devices, the available topics are limited.

For more information about the differences between brokers and device registries, see Resource relationships in Yandex IoT Core.

When using registries and devices, you can send messages of the following types:

  • Send data from a device to a registry using the $devices/<device_ID>/events or $registries/<registry_ID>/events topics.
  • Send data from a device to a registry using the retained $devices/<device_ID>/state or $registries/<registry_ID>/state topics.
  • Send commands from a registry to a device using the $devices/<device_ID>/commands or $registries/<registry_ID>/commands topics.
  • Send commands from a registry to a device using the retained $devices/<device_ID>/config or $registries/<registry_ID>/config topics.

To receive messages, you need to subscribe to the sender. Learn how to do this in Subscribing to messages.

To learn how to verify that the message was successfully sent and delivered, see Testing message delivery.

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.

Sending a data messageSending a data message

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.

Sending data from a device to a device topicSending data from a device to a device topic

A registry subscribed to this topic will know which device sent the data because the topic contains a unique device ID.

CLI
API

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.

  • Send data to a device topic using certificate-based authentication:

    yc iot mqtt publish \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$devices/<device_ID>/events' \
      --message 'Test data' \
      --qos 1
    
  • Send data to a device’s retained topic using certificate-based authentication:

    yc iot mqtt publish \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$devices/<device_ID>/state' \
      --message 'Test data' \
      --qos 1
    

    Where:

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

    yc iot mqtt publish \
      --username <device_ID> \
      --password <device_password> \
      --topic '$devices/<device_ID>/events' \
      --message 'Test data' \
      --qos 1
    
  • Send data to a device’s retained topic using username and password authentication:

    yc iot mqtt publish \
      --username <device_ID> \
      --password <device_password> \
      --topic '$devices/<device_ID>/state' \
      --message 'Test data' \
      --qos 1
    

    Where:

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

To send device data to a device topic, use the publish REST API method for the DeviceData resource or the DeviceDataService/Publish gRPC API call.

Sending data from a device to a registry topicSending data from a device to a registry topic

A registry subscribed to this topic will not know which device sent the data because the topic does not contain a unique device ID.

CLI
API
  • Send data to a registry topic using certificate-based authentication:

    yc iot mqtt publish \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$registries/<registry_ID>/events' \
      --message 'Test data' \
      --qos 1
    
  • Send data to a registry’s retained topic using certificate-based authentication:

    yc iot mqtt publish \
      --cert device-cert.pem \
      --key device-key.pem \
      --topic '$registries/<registry_ID>/state' \
      --message 'Test data' \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Registry topic for receiving data.
    • --message: Message text.
    • --qos: Quality of service (QoS) level.
  • Send data to a registry topic using username and password authentication:

    yc iot mqtt publish \
      --username <device_ID> \
      --password <device_password> \
      --topic '$registries/<registry_ID>/events' \
      --message 'Test data' \
      --qos 1
    
  • Send data to a registry’s retained topic using username and password authentication:

    yc iot mqtt publish \
      --username <device_ID> \
      --password <device_password> \
      --topic '$registries/<registry_ID>/state' \
      --message 'Test data' \
      --qos 1
    

    Where:

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

To send data from a device to a registry topic, use the publish REST API method for the DeviceData resource or the DeviceDataService/Publish gRPC API call.

Sending a command messageSending a command message

A registry can send a command message to one, multiple, or all devices added to it. Let’s consider all options.

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.

Sending a command to one deviceSending a command to one device

CLI
API
  • Send a command using certificate-based authentication:

    yc iot mqtt publish \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$devices/<device_ID>/commands' \
      --message 'Test command for first device' \
      --qos 1
    
  • Send a command using a retained topic and certificate-based authentication:

    yc iot mqtt publish \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$devices/<device_ID>/config' \
      --message 'Test command for first device' \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Device topic for receiving commands.
    • --message: Message text.
    • --qos: Quality of service (QoS) level.
  • Send a command using username and password authentication:

    yc iot mqtt publish \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$devices/<device_ID>/commands' \
      --message 'Test command for first device' \
      --qos 1
    
  • Send a command using a retained topic and username and password authentication:

    yc iot mqtt publish \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$devices/<device_ID>/config' \
      --message 'Test command for first device' \
      --qos 1
    

    Where:

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

To send a command to a single device, use the publish REST API method for the RegistryData resource or the RegistryDataService/Publish gRPC API call.

Sending a command to all devices added to the registrySending a command to all devices added to the registry

CLI
API
  • Send a command to all devices using certificate-based authentication:

    yc iot mqtt publish \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$registries/<registry_ID>/commands' \
      --message 'Test command for all devices' \
      --qos 1
    
  • Send a command to all devices using a retained topic and certificate-based authentication:

    yc iot mqtt publish \
      --cert registry-cert.pem \
      --key registry-key.pem \
      --topic '$registries/<registry_ID>/config' \
      --message 'Test command for all devices' \
      --qos 1
    

    Where:

    • --cert and --key: Certificate-based authentication parameters.
    • --topic: Registry topic for sending commands.
    • --message: Message text.
    • --qos: Quality of service (QoS) level.
  • Send a command to all devices using username and password authentication:

    yc iot mqtt publish \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$registries/<registry_ID>/commands' \
      --message 'Test command for all devices' \
      --qos 1
    
  • Send a command to all devices using a retained topic and username and password authentication:

    yc iot mqtt publish \
      --username <registry_ID> \
      --password <registry_password> \
      --topic '$registries/<registry_ID>/config' \
      --message 'Test command for all devices' \
      --qos 1
    

    Where:

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

To send a command to all devices added to a registry, use the publish REST API method for the RegistryData resource or the RegistryDataService/Publish gRPC API call.

Sending a message in a brokerSending a message in a broker

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

CLI
API
  • Send a message using username and password authentication:

    yc iot mqtt publish \
      --username <broker_ID> \
      --password <broker_password> \
      --topic /my/custom/topic \
      --message 'Test broker message'
      --qos 1
    

    Where:

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

    yc iot mqtt publish \
      --cert broker-cert.pem \
      --key broker-key.pem \
      --topic /my/custom/topic \
      --message 'Test broker message'
      --qos 1
    

    Where:

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

To send a message in a broker, use the publish REST API method for the BrokerData resource or the BrokerDataService/Publish gRPC API call.

Was the article helpful?

Previous
All guides
Next
Subscribing a device or registry to receive messages
© 2026 Direct Cursus Technology L.L.C.