404 on updating device tag

Hi, when I update a device tag through the dashboard, I see the in the network tab that the POST to api.resin.io/v3/device_tag fails with a 404 error, with response “Unique key constraint violated”. The value does appear to be successfully updated though, as it persists when I refresh the page. Will the API be updated to return a 2xx for this case? I want to hit the endpoint directly to update tags in my application, and the 404 makes it a little inconvenient to check whether this call succeeded.

Hi there,

when updating a device tag a PATCH request is executed which returns a successful code 2xx. If you open the network tab you will see that indeed there is a PATCH request there with code 201. You can also inspect the request (or copy as cURL) to experiment further. On the other hand, when creating a new tag, you will see a POST request with code 2xx.


I see, I do see the PATCH request now. Is the recommended behavior for the client to attempt a POST, and then attempt a PATCH if the POST returns a 404?


this behavior is due to our rules-driven API engine that we use, which currently does not support upserts, so we make a POST request to see if the tag already exists. So, this is an expected behavior at the moment.
However, this is a situation that we’d like to improve in the future, as I was informed from the team!


That makes sense, thanks for the explanation!

Additionally let me share with you our playground repository that demonstrates how to set device tags from within your app: https://github.com/resin-io-playground/device-tags

In addition to demonstrating how to use the resin-sdk, it also contains some shell scripts that use CURL as an alternative method.