There are several ways depending on the tools you have at your disposition and are willing to use.
The easies would just be to hit the API endpoint
https://api.particle.io/v1/devices/<deviceID>?access_token=<yourAccessToken> and check the
But that is relying on the device checking in regularly or when it fails to do so the cloud guessing the device being offline.
A similar approach would be the the enpoint to list devices https://docs.particle.io/reference/api/#list-devices
Another way would be to just send a request and see whether it can be serviced or will timeout.
Or your device publishes an event whenever it comes online or is about to go offline.
All of these hold some degree of uncertainty tho’
The more reliability you need, the more laborious you’d need to lay out the logic.