# 404 on updating device tag

**URL:** <https://forums.balena.io/t/404-on-updating-device-tag/2608>\
**Category:** Product support\
**Created:** [February 22, 2018, 12:43am UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608 "2018-02-22T00:43:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aric-mira](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@aric-mira](https://forums.balena.io/u/aric-mira)\
**Post date:** [February 22, 2018, 12:43am UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608/1 "2018-02-22T00:43:41Z")

</div>

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](http://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.

---

<div class="post-metadata">

**Author:** ![izavits](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@izavits](https://forums.balena.io/u/izavits)\
**Post date:** [February 22, 2018, 1:13pm UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608/4 "2018-02-22T13:13:20Z")

</div>

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.

Best,  
ilias

---

<div class="post-metadata">

**Author:** ![aric-mira](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@aric-mira](https://forums.balena.io/u/aric-mira)\
**Post date:** [February 22, 2018, 9:10pm UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608/5 "2018-02-22T21:10:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![izavits](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@izavits](https://forums.balena.io/u/izavits)\
**Post date:** [February 23, 2018, 12:32pm UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608/11 "2018-02-23T12:32:11Z")

</div>

Hello,

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!

Best,  
ilias

---

<div class="post-metadata">

**Author:** ![aric-mira](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@aric-mira](https://forums.balena.io/u/aric-mira)\
**Post date:** [February 23, 2018, 6:14pm UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608/15 "2018-02-23T18:14:48Z")

</div>

That makes sense, thanks for the explanation!

---

<div class="post-metadata">

**Author:** ![thgreasi](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/thgreasi/32/454_2.png) [@thgreasi](https://forums.balena.io/u/thgreasi)\
**Post date:** [February 26, 2018, 8:50am UTC](https://forums.balena.io/t/404-on-updating-device-tag/2608/17 "2018-02-26T08:50:11Z")

</div>

Hi,  
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](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.
