# Efficient way to get a device\`s id at preauthorisation

**URL:** <https://hub.mender.io/t/efficient-way-to-get-a-device-s-id-at-preauthorisation/4512>\
**Category:** General Discussions\
**Created:** [January 20, 2022, 5:54pm UTC](https://hub.mender.io/t/efficient-way-to-get-a-device-s-id-at-preauthorisation/4512 "2022-01-20T17:54:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rlaybourn](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rlaybourn](https://hub.mender.io/u/rlaybourn)\
**Post date:** [January 20, 2022, 5:54pm UTC](https://hub.mender.io/t/efficient-way-to-get-a-device-s-id-at-preauthorisation/4512/1 "2022-01-20T17:54:45Z")

</div>

Hi I am looking to write a script to preauthorise devices and then apply a deployment to them , depending upon requirements. In order to deploy an artifact to a device it appears that I need to know the device ID bu the preauth API does not return this device ID . Currently I need to then pull down a list of devices and search through for the device with the unique id that I used in the identity data. This works but it seems very inefficient is there a better way to either get the ID given to the device at preauth or to find a device based upon it identity data ?

---

<div class="post-metadata">

**Author:** ![mzedel](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mzedel/32/261_2.png) [@mzedel](https://hub.mender.io/u/mzedel)\
**Post date:** [January 20, 2022, 6:20pm UTC](https://hub.mender.io/t/efficient-way-to-get-a-device-s-id-at-preauthorisation/4512/2 "2022-01-20T18:20:56Z")

</div>

Hi @rlaybourn,  
you should be able to get the device id in the response headers of the preauth call (the `POST` to `/api/management/v2/devauth/devices`). The header is called `location` 👍  
I hope that helps.
