Delete device tag via API results in Unauthorized

Hi,

when I try to delete a device tag, via either the REST api or node sdk, I get an Unauthorized error.

curl -i -X GET \
"https://api.balena-cloud.com/v4/device_tag(<id>)" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <bearer>"

where <id> is gotten from:

curl -X GET \
"https://api.balena-cloud.com/v4/device_tag?\$filter=device/uuid%20eq%20'<uuid>'" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <bearer>" 

Any ideas?

Hi,
I guess you are trying to delete the device tag from the device with the device API key? If so, our access control policy only allows creating and updating device tags with the device API key.

Hi,

Indeed I try to delete the device tag from within a service on the device with the api key. I think I missed that part in the documentation.

Is there a possibility to create another API token which can do this delete or what is the alternative to perform this action via a REST call? Create a developer user?

Ps: it is not required to perform this delete from within a service on the device itself. Even better if it could be done outside of it.

Hi,
An operator or developer collaborator on an application can delete device tags, using the same REST calls. You can create an API key in the dashboard and use this. It is usually not advisable to give such an API key to a device, because devices might be on customer sites, or even publicly accessible (depends on your use case of course). The idea would be to use it in a back end service.

1 Like

Perfect, this is working now! :ok_hand:

Can this be made more clear in the documentation, or did I just missed it?

Thanks

Hey there,

We’re glad it’s working fine now! I’ll make a note to check our docs and hopefully improve them. Thanks a lot!