Message expiry enables IoT Platform to automatically discard cached messages after a configurable interval, preventing stale commands from reaching devices that reconnect after a delay.
How message expiry works
When you set the Message Expiry Interval (MEI) on a message, IoT Platform tracks how long the message has been cached. If the message is not delivered before the interval elapses, IoT Platform deletes it and does not push it when the device reconnects.
The following figure illustrates the end-to-end flow with a QoS 1 message and a 5-second MEI:

The business server pushes a QoS 1 message with an MEI of 5 seconds.
The first push attempt fails. The device does not return an ACK.
The message expires after 5 seconds, and IoT Platform deletes it.
-
When the device reconnects, no message is pushed.
NoteWhen the session expires, IoT Platform deletes all pending QoS 1 messages regardless of their remaining MEI.
When the session expires, retained messages are not deleted. To keep a message available after its MEI elapses, publish it as a retained message.
The MEI applies differently depending on message type:
|
Message type |
Behavior when MEI elapses |
|
QoS 1 |
IoT Platform deletes the cached message. If the session also expires, the message is deleted immediately — regardless of the remaining MEI. |
|
Retained message |
IoT Platform does not delete the retained message when the session expires. The retained message remains stored until its own MEI elapses. |
|
Will message |
IoT Platform discards the will message if it has not been triggered and pushed before the MEI elapses. |
Use cases
Message expiry is most useful when commands must be acted on promptly or not at all.
Remote control: If you push a command to open a door and the device is temporarily offline, the door must not open minutes later when connectivity returns. Set an MEI that matches the window in which the command is still meaningful.
Time-sensitive notifications: Alerts triggered by real-time sensor readings (such as a temperature threshold breach) lose their value quickly. An MEI prevents the device from receiving and acting on an outdated alert.