There is no REST API for getting a connection status of the device(s) in the IoT Central App. However, you can use the Device connectivity events in the Data export feature with a webhook destination to the Azure Event Grid custom topic as a CloudEvents message.
The following is an example of the exported CloudEvents message:
Data transformation:
if .messageSource == "deviceConnectivity" then
{
specversion:"1.0",
id:.applicationId,
source: .device.id,
subject: ("/" + .applicationId + "/" + .device.id + "/" + .messageSource),
type:.messageType,
time:.enqueuedTime,
dataschema:"#",
data:{
reportedProperties: .device.properties.reported,
cloudProperties: .device.cloudProperties
}
}
else
empty
end
CloudEvents message:
{
"data":{
"cloudProperties":[],
"reportedProperties":[]
},
"dataschema":"#",
"id":"2922a1f6-7214-490a-88bc-a1e1d4351d12",
"source":"device101",
"specversion":"1.0",
"subject":"/2922a1f6-7214-490a-88bc-a1e1d4351d12/device101/deviceConnectivity",
"time":"2022-07-06T10:27:05.829Z",
"type":"disconnected"
}
Note, that the webhook destination header Content-Type must be configured for application/cloudevents+json
UPDATE:
I have found an undocumented REST API to get the device twin with an extended info such as the connectionState, status, modelId, etc.
https://<applicationId>.azureiotcentral.com/system/iothub/devices/<deviceId>/get-twin?extendedInfo=true
Authorization: <apiToken>
Thanks
Roman