Efficient way to get a device`s id at preauthorisation

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 ?

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 :+1:
I hope that helps.