2026/05/28 - AWS IoT Data Plane - 3 new api methods
Changes Adding GetConnection, ListSubscriptions, and SendDirectMessage APIs to IoT Data Plane
Sends an MQTT message directly to a specific client identified by its client ID.
SendDirectMessage targets a single client ID. The receiving client does not need to subscribe to the topic, but the receiver's policy must allow iot:Receive on the specified topic.
Requires permission to access the SendDirectMessage action.
For more information about messaging costs, see Amazon Web Services IoT Core pricing.
See also: AWS API Documentation
Request Syntax
client.send_direct_message(
clientId='string',
topic='string',
contentType='string',
responseTopic='string',
confirmation=True|False,
timeout=123,
payload=b'bytes'|file,
userProperties={...}|[...]|123|123.4|'string'|True|None,
payloadFormatIndicator='UNSPECIFIED_BYTES'|'UTF8_DATA',
correlationData='string'
)
string
[REQUIRED]
The unique identifier of the MQTT client to send the message to.
Client IDs must not exceed 128 characters and can't start with a dollar sign ($). MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
string
[REQUIRED]
The topic of the outbound MQTT Publish message to the receiving client. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
string
The MQTT5 content type property forwarded to the receiving client (for example, application/json).
string
A UTF-8 encoded string that's used as the topic name for a response message. The response topic describes the topic which the receiver should publish to as part of the request-response flow. The topic must not contain wildcard characters. For more information, see Amazon Web Services IoT Core message broker and protocol limits and quotas.
boolean
A Boolean value that specifies whether to wait for delivery confirmation from the receiving client.
When set to true, the API delivers the message at QoS 1 and waits for the client to send a delivery confirmation (PUBACK) before returning a successful response. If delivery confirmation is not received within the specified timeout period, the API returns HTTP 504.
When set to false, the API delivers the message at QoS 0 and returns after Amazon Web Services IoT Core attempts to deliver the message.
Valid values: true | false
Default value: false
integer
An integer that represents the maximum time, in seconds, to wait for a delivery confirmation (PUBACK) from the receiving client after the message has been delivered. This parameter is only used when confirmation is set to true. If confirmation is false, this parameter is ignored.
The total API response time may be higher than this value due to internal processing. Set your HTTP client timeout to a value greater than this parameter.
Valid range: 1 to 15 seconds.
Default value: 5 seconds.
bytes or seekable file-like object
The message body. MQTT accepts text, binary, and empty (null) message payloads.
JSON serializable
A JSON string that contains an array of JSON objects. If you don't use Amazon Web Services SDK or CLI, you must encode the JSON string to base64 format before adding it to the HTTP header. userProperties is an HTTP header value in the API.
For MQTT 3.1.1 clients, user properties are silently dropped.
The following example userProperties parameter is a JSON string which represents two User Properties. Note that it needs to be base64-encoded:
[{"deviceName": "alpha"}, {"deviceCnt": "45"}]
string
An Enum string value that indicates whether the payload is formatted as UTF-8. payloadFormatIndicator is an HTTP header value in the API.
string
The base64-encoded binary data used by the sender of the request message to identify which request the response message is for when it's received. correlationData is an HTTP header value in the API.
dict
Response Syntax
{
'message': 'string',
'traceId': 'string'
}
Response Structure
(dict) --
The output from the SendDirectMessage operation.
message (string) --
The status message indicating the result of the operation.
traceId (string) --
A unique identifier for the request. Include this value when contacting Amazon Web Services Support for troubleshooting.
Returns a list of all subscriptions for MQTT clients with active sessions, including offline clients with persistent sessions.
Requires permission to access the ListSubscriptions action.
See also: AWS API Documentation
Request Syntax
client.list_subscriptions(
clientId='string',
nextToken='string',
maxResults=123
)
string
[REQUIRED]
The unique identifier of the MQTT client to list subscriptions for. The client ID can't start with a dollar sign ($).
MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.
string
To retrieve the next set of results, the nextToken value from a previous response; otherwise null to receive the first set of results.
integer
The maximum number of subscriptions to return in a single request. By default, this is set to 20.
dict
Response Syntax
{
'subscriptions': [
{
'topicFilter': 'string',
'qos': 123
},
],
'nextToken': 'string'
}
Response Structure
(dict) --
subscriptions (list) --
A list of topic filters and their associated Quality of Service (QoS) levels that the client is subscribed to.
(dict) --
Contains information about a subscription for an MQTT client, including the topic filter and Quality of Service (QoS) level.
topicFilter (string) --
The topic filter pattern that the client is subscribed to. May include MQTT wildcards such as + (single-level) and # (multi-level).
qos (integer) --
The Quality of Service (QoS) level for the subscription. Valid values are 0 (at most once) and 1 (at least once).
nextToken (string) --
The token to use to get the next set of results, or null if there are no additional results.
Retrieves connection information for the specified MQTT client.
Requires permission to access the GetConnection action.
See also: AWS API Documentation
Request Syntax
client.get_connection(
clientId='string',
includeSocketInformation=True|False
)
string
[REQUIRED]
The unique identifier of the MQTT client to retrieve connection information. The client ID can't start with a dollar sign ($).
MQTT client IDs must be URL encoded (percent-encoded) when they contain characters that are not valid in HTTP requests, such as spaces, forward slashes (/), and UTF-8 characters.
boolean
Specifies if socket information (sourcePort, targetPort, sourceIp, targetIp) should be included in the GetConnection response. Set to TRUE to include socket information. Set to FALSE to omit socket information. By default, this is set to FALSE. See the developer guide for how to authorize this parameter.
dict
Response Syntax
{
'connected': True|False,
'thingName': 'string',
'cleanSession': True|False,
'sourceIp': 'string',
'sourcePort': 123,
'targetIp': 'string',
'targetPort': 123,
'keepAliveDuration': 123,
'connectedSince': 123,
'disconnectedSince': 123,
'disconnectReason': 'string',
'sessionExpiry': 123,
'clientId': 'string',
'vpcEndpointId': 'string'
}
Response Structure
(dict) --
connected (boolean) --
The connection state of the client. Returns true if the client is currently connected, or false if the client is not connected.
thingName (string) --
The name of the thing associated with the principal of the MQTT client, if applicable.
cleanSession (boolean) --
Indicates whether the client is using a clean session. Returns true for clean sessions or false for persistent sessions.
sourceIp (string) --
The IP address of the client that initiated the connection.
sourcePort (integer) --
The client's source port.
targetIp (string) --
The IP address of the Amazon Web Services IoT Core endpoint that the client connected to. For clients connected to VPC endpoints, this is the private IP address of the network interface the client is connected to.
targetPort (integer) --
The port number of the Amazon Web Services IoT Core endpoint that the client connected to.
keepAliveDuration (integer) --
The keep-alive interval in seconds that the client specified when establishing the connection.
connectedSince (integer) --
Unix timestamp (in milliseconds) indicating when the client connected. Present only when connected is true.
disconnectedSince (integer) --
Unix timestamp (in milliseconds) indicating when the client disconnected. Present only when connected is false. This information is available for 30 minutes after the client disconnects.
disconnectReason (string) --
The reason for the last disconnection, if the client is currently disconnected. See the developer guide for valid disconnect reasons.
sessionExpiry (integer) --
The session expiry interval in seconds for the MQTT client connection. This is configured by the user. This value indicates how long the session will remain active after the client disconnects.
clientId (string) --
The unique identifier of the MQTT client. This is the same client ID that was used when the client established the connection.
vpcEndpointId (string) --
The ID of the VPC endpoint. Present for clients connected to IoT Core via a VPC endpoint.