# Device auth API: device ID from preauthorize

**URL:** https://hub.mender.io/t/device-auth-api-device-id-from-preauthorize/698
**Category:** General Discussions
**Tags:** api
**Created:** [June 12, 2019, 12:15pm UTC](https://hub.mender.io/t/device-auth-api-device-id-from-preauthorize/698 "2019-06-12T12:15:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![guelfey](https://avatars.discourse-cdn.com/v4/letter/g/7feea3/32.png) [@guelfey](https://hub.mender.io/u/guelfey)
#### Post date: [June 12, 2019, 12:15pm UTC](https://hub.mender.io/t/device-auth-api-device-id-from-preauthorize/698/1 "2019-06-12T12:15:21Z")

</div>

I’m trying to use the device auth API to automatically authorize devices as part of a more complex provisioning process. I find it strange that the preauthorization API call ([https://docs.mender.io/2.0/apis/management-apis/device-authentication#devices-post](https://docs.mender.io/2.0/apis/management-apis/device-authentication#devices-post)) doesn’t return the ID of the created device. The ID would be very useful to later check that the device shows up as “authorized” when it connects to the backend or to remove the device again if something else goes wrong. The documentation also states that the Device resource should be returned if trying to preauthorize an existing device, but when testing using the demo setup on version 2.0.0, only an error is returned. A quick look at the source code ([https://github.com/mendersoftware/deviceauth/blob/master/api/http/api\_devauth.go#L216](https://github.com/mendersoftware/deviceauth/blob/master/api/http/api_devauth.go#L216)) seems to confirm this. This means that in order to determine the device ID, I’d have to manually list all the devices and search them for the public key that I just submitted. Is there a reason why the ID isn’t returned?

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [June 14, 2019, 4:41pm UTC](https://hub.mender.io/t/device-auth-api-device-id-from-preauthorize/698/2 "2019-06-14T16:41:04Z")

</div>

This is not really my area, but agree that there are some inconsistencies here that would need some additional clarifications.

I would suggest you to file a ticket here,

[http://tracker.mender.io/](http://tracker.mender.io/)

with your findings so far.

---

<div class="post-metadata">

### Author: ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)
#### Post date: [July 3, 2019, 11:22am UTC](https://hub.mender.io/t/device-auth-api-device-id-from-preauthorize/698/3 "2019-07-03T11:22:39Z")

</div>

I have created the following,

[https://tracker.mender.io/browse/MEN-2624](https://tracker.mender.io/browse/MEN-2624)

to address this,

> The documentation also states that the Device resource should be returned if trying to preauthorize an existing device, but when testing using the demo setup on version 2.0.0, only an error is returned
