# Query "last connected" time via management api

**URL:** <https://hub.mender.io/t/query-last-connected-time-via-management-api/3797>\
**Category:** General Discussions\
**Tags:** api, management-api\
**Created:** [June 25, 2021, 6:07pm UTC](https://hub.mender.io/t/query-last-connected-time-via-management-api/3797 "2021-06-25T18:07:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbheidebr](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mbheidebr](https://hub.mender.io/u/mbheidebr)\
**Post date:** [June 25, 2021, 6:07pm UTC](https://hub.mender.io/t/query-last-connected-time-via-management-api/3797/1 "2021-06-25T18:07:04Z")

</div>

Hello!

I have a question/feature request: I would like to be able to query the “last connected timestamp” that is visible on the hosted mender website, is that possible? I see that there is a way to get the current connection status of the unit: [Mender API docs](https://docs.mender.io/api/#management-api-device-connect)

To do this on my own I feel like I would:

- query that “connected” status on a set time interval
- add the connected status to a DB
- to get the last connected time I would then query the database for the most recent time the device was connected

I feel that doing this over a whole fleet of devices isn’t the best way to accomplish this task. Is there a better way to get the “last connected time”? I do notice there is also a time stamp for when the inventory for a device was last updated, maybe I should use that time stamp instead?

Thanks in advance for any help!

Matt

---

<div class="post-metadata">

**Author:** ![lramirez](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/lramirez/32/1195_2.png) [@lramirez](https://hub.mender.io/u/lramirez)\
**Post date:** [June 25, 2021, 11:38pm UTC](https://hub.mender.io/t/query-last-connected-time-via-management-api/3797/2 "2021-06-25T23:38:50Z")

</div>

Hi Matt,

I think you are looking for the “devices” endpoint: [Mender API docs](https://docs.mender.io/api/?shell#management-api-device-inventory)

For example, if you try with the following endpoint, you will receive the list of all the devices:  
$MENDER\_SERVER\_URI/api/management/v1/inventory/devices

You are looking for the “updated\_ts” property. It will contain the last the device reported that it was connected.

Hope it helps 🙂  
Luis

---

<div class="post-metadata">

**Author:** ![mbheidebr](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mbheidebr](https://hub.mender.io/u/mbheidebr)\
**Post date:** [June 26, 2021, 12:18am UTC](https://hub.mender.io/t/query-last-connected-time-via-management-api/3797/3 "2021-06-26T00:18:36Z")

</div>

Thanks Luis, I will use the `updated_ts` value for the last connected indicator. This issue is solved and can be closed. Much appreciated!
