# How can I reuse hardcoded AppEUI and AppKey after I deleted an application?

**URL:** <https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113>\
**Category:** End Devices (Nodes)\
**Created:** [January 30, 2017, 5:59pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113 "2017-01-30T17:59:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rodger](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/r/c68b51/32.png) [@rodger](https://www.thethingsnetwork.org/forum/u/rodger)\
**Post date:** [January 30, 2017, 5:59pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/1 "2017-01-30T17:59:44Z")

</div>

I try ADEUNIS RF node to get the TTN network, but so far this does not succeed.  
I want to create a test setup.

When purchasing I got the DEVEUI, AppEUI and AppKEY

All codes have filled in, but received no activation of the device.  
I live 2 km from a gateway.  
I have also tried to put the node closer.  
I deleted the application;  
If I want to re-create the application, I can not use the same codes.  
There is a report that is already in use, while I remove the application.

How can I solve this

---

<div class="post-metadata">

**Author:** ![htdvisser](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/htdvisser/32/45312_2.png) [@htdvisser](https://www.thethingsnetwork.org/forum/u/htdvisser)\
**Post date:** [January 31, 2017, 7:26am UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/2 "2017-01-31T07:26:21Z")

</div>

Could you send me your AppID, DevID, AppEUI and DevEUI in a private message, then I might be able to help you out.

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [March 27, 2019, 8:11am UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/3 "2019-03-27T08:11:24Z")

</div>

@htdvisser, two years later, but this seems to be the proper topic to tell people how to proceed if things have changed:

- Can one delete an application that still has devices registered to it?

- If yes: would not deleting the devices before deleting an application orphan those devices, or would they be unregistered on the fly?

- Would re-using the same AppEUI, AppKey and DevEUI work when an earlier device registration with the same details once existed?

I know you once wrote on Slack:

> @htdvisser [Jan 11th 2019 4:24 PM]
> 
> We use the AppEUI+DevEUI combination as identifier for a device, so as long as you use different AppEUIs for devices with the same DevEUI, you should be fine for now (but you may encounter problems in v3 if you would use LoRaWAN 1.1 ReJoinRequests)

Also, when not deleting an application, one cannot register the same AppEUI and DevEUI twice:

> ![error message](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/5/c/5c198fda3b2ef0d29ee84f8c71834c4d6ab4aade.png)
> 
> **failed to register device**  
> Device with AppEUI and DevEUI already exists

Deleting an application that still has devices registered to it, does not mention those devices in its confirmation message, but I’ve not tried to see what happens when proceeding:

> ![confirmation](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/8/b/8b05c1c1091551ef6f125dceb51b3c0de57d48fc.png)

Finally, [on GitHub I see](https://github.com/TheThingsNetwork/ttn/issues/573#issuecomment-323752442) about `ttnctl`, emphasis mine:

> _ama9910 commented on 21 Aug 2017_
> 
> The issue I observed is that **when deleting an application with ttnctl, the devices remained active**. There is now no way to delete those devices using ttnctl, without first selecting the now deleted application - which can’t be done.  
> …
> 
> _johanstokking commented on 21 Aug 2017_
> 
> Yes, these are two separate things. We will take unarchiving into account for the next version of the account server. **When an application is deleted, it should be unregistered from the handler, which invokes deleting devices.**

---

<div class="post-metadata">

**Author:** ![htdvisser](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/htdvisser/32/45312_2.png) [@htdvisser](https://www.thethingsnetwork.org/forum/u/htdvisser)\
**Post date:** [March 27, 2019, 9:23am UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/4 "2019-03-27T09:23:58Z")

</div>

Devices need to be deleted in order to release their IDs/EUIs for future registrations. Due to the way our registries work, deleting an application does **not** implicitly delete devices under that application, so users need to delete their devices explicitly before deleting an application. The v2 console tries to delete devices, but there are not guarantees that this succeeds. The v2 CLI (ttnctl) does not try to delete devices.

The reason for all this is that in our v2 backend, applications are registered in the account server while end devices are registered in the networkserver (through the broker) and in the handler. The account server doesn’t know anything about end devices, so it also can’t check if a user deleted all their end devices before deleting the application. The networkserver and handler don’t know anything about applications other than the fact that a user is authorized to manage end devices with a certain application ID and read their traffic. As a result of this, the only effect of deleting an application is that a user is no longer authorized to manage those end devices or read their traffic. The end devices will not disappear, and the routing services will keep handling traffic for those devices

In our v3 stack, the situation is very similar to v2. Users (or clients like the CLI or console) will still be responsible for deleting registered devices before deleting an application. We will however be better able to detect if there are still devices registered, and refuse to delete the application if we do.

For v3 we are also thinking about some kind of mechanism for releasing identifiers of orphaned end devices or end devices that have exceeded their lifetime, but we don’t have anything concrete for this yet.

---

<div class="post-metadata">

**Author:** ![bfsl](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bfsl/32/25844_2.png) [@bfsl](https://www.thethingsnetwork.org/forum/u/bfsl)\
**Post date:** [November 16, 2020, 11:58am UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/5 "2020-11-16T11:58:39Z")

</div>

@htdvisser almost two years after I bump the topic again. As far as I understand (still a rookie though) v3 is out by now. I dont find a solution for revitalizing orphaned devices? My situation is that I have a Things Gateway, someone tried to set up some time ago. Since this happened in a school, its hardly possible to find that person. Is there any chance I can liberate the device?

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [November 16, 2020, 12:42pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/6 "2020-11-16T12:42:06Z")

</div>

> [@bfsl](#):
>
> As far as I understand (still a rookie though) v3 is out by now

The community network still runs V2 and will stay on V2 for months to come.

---

<div class="post-metadata">

**Author:** ![bfsl](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bfsl/32/25844_2.png) [@bfsl](https://www.thethingsnetwork.org/forum/u/bfsl)\
**Post date:** [November 16, 2020, 2:02pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/7 "2020-11-16T14:02:54Z")

</div>

My bad, I saw v3 published on Github. So I understand there is no chance to get the device back and I have to throw it away?

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [November 16, 2020, 2:05pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/8 "2020-11-16T14:05:38Z")

</div>

For a node the old application must be deleted to be able to reuse the existing values. I understand you can’t program new EUI and key?

---

<div class="post-metadata">

**Author:** ![bfsl](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bfsl/32/25844_2.png) [@bfsl](https://www.thethingsnetwork.org/forum/u/bfsl)\
**Post date:** [November 16, 2020, 2:10pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/9 "2020-11-16T14:10:32Z")

</div>

Oh - I realized I might post in the wrong topic. I actually tried to register The Things Gateway as Gateway. I am ending with the error `a gateway with id XXXXXXX already exists`. So there is no application, but the error message stays the same?

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [November 16, 2020, 4:23pm UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/10 "2020-11-16T16:23:41Z")

</div>

For The Things Gateway you can choose your own ‘name’ while registering so you shouldn’t have any issues with old registrations.

---

<div class="post-metadata">

**Author:** ![bfsl](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bfsl/32/25844_2.png) [@bfsl](https://www.thethingsnetwork.org/forum/u/bfsl)\
**Post date:** [November 17, 2020, 8:10am UTC](https://www.thethingsnetwork.org/forum/t/how-can-i-reuse-hardcoded-appeui-and-appkey-after-i-deleted-an-application/5113/11 "2020-11-17T08:10:05Z")

</div>

My bad, I entered the code on the RF-Module into the id field. Now I chose a different ID and it works. Thank you!
