GetRetainedMessage - Amazon IoT
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).


Gets the details of a single retained message for the specified topic.

This action returns the message payload of the retained message, which can incur messaging costs. To list only the topic names of the retained messages, call ListRetainedMessages.

Requires permission to access the GetRetainedMessage action.

For more information about messaging costs, see Amazon IoT Core pricing - Messaging.

Request Syntax

GET /retainedMessage/topic HTTP/1.1

URI Request Parameters

The request uses the following URI parameters.


The topic name of the retained message to retrieve.

Required: Yes

Request Body

The request does not have a request body.

Response Syntax

HTTP/1.1 200 Content-type: application/json { "lastModifiedTime": number, "payload": blob, "qos": number, "topic": "string", "userProperties": blob }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.


The Epoch date and time, in milliseconds, when the retained message was stored by Amazon IoT.

Type: Long


The Base64-encoded message payload of the retained message body.

Type: Base64-encoded binary data object


The quality of service (QoS) level used to publish the retained message.

Type: Integer

Valid Range: Minimum value of 0. Maximum value of 1.


The topic name to which the retained message was published.

Type: String


A base64-encoded JSON string that includes an array of JSON objects, or null if the retained message doesn't include any user properties.

The following example userProperties parameter is a JSON string that represents two user properties. Note that it will be base64-encoded:

[{"deviceName": "alpha"}, {"deviceCnt": "45"}]

Type: Base64-encoded binary data object



An unexpected error has occurred.

HTTP Status Code: 500


The request is not valid.

HTTP Status Code: 400


The specified combination of HTTP verb and URI is not supported.

HTTP Status Code: 405


The specified resource does not exist.

HTTP Status Code: 404


The service is temporarily unavailable.

HTTP Status Code: 503


The rate exceeds the limit.

HTTP Status Code: 429


You are not authorized to perform this operation.

HTTP Status Code: 401

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: