Can I generate a device key through the API?


#1

I know how to generate the device key using the dashboard but is it possible to do that through the API … I have a bunch of devices and I’d really like to be able to generate those keys without all those clicks.


#2

Yes:

POST to /csr/sources with the deviceid parameter


#3

Thanks for that but that method gives me the “current” keys but doesn’t generate a key for a device that I haven’t generated one through the dashboard. When post without a deviceid parameter I get a list of all the devices that have a devicekey with their parameters … but only those I manually generated a key for. If I post with a deviceid that I haven’t set a key for on the dashboard, then I get a “success” but empty response.


#4

Hmm, are you sure you’re doing a POST and not a GET? I just tested and it seems to be working properly. I did a POST to /csr/sources with the deviceid as one of the parameters passed into the request for a device that didn’t have a device key and the response came back with the new device key.


#5

Yep, my mistake … was “getting” instead of "posting"
Life is good again, thanks!


#6

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.