Duplicate identifier on application server

Hello, I want to register an end device in the cloud, but that device was deleted before (probably with another device_id). I create it in the correct order on the IS, JS, NS and then it fails on the AS:

POST https://eu1.cloud.thethings.network:443/api/v3/applications/test-app/devices?

BODY {
  "end_device": {
    "ids": {
      "device_id": "b0b353fffe407a98-23720-7",
      "application_ids": {
        "application_id": "test-app"
      },
      "dev_eui": "B0B353FFFE407A98",
      "join_eui": "A100000000000000"
    },
    "name": "14200003",
    "description": "",
    "network_server_address": "eu1.cloud.thethings.network",
    "application_server_address": "eu1.cloud.thethings.network",
    "version_ids": {
      "brand_id": "23720",
      "model_id": "mbus-7",
      "hardware_version": ""
    },
    "join_server_address": "eu1.cloud.thethings.network"
  },
  "field_mask": {
    "paths": [
      "name",
      "description",
      "attributes",
      "network_server_address",
      "application_server_address",
      "join_server_address",
      "locations",
      "version_ids"
    ]
  }
}
PUT https://eu1.cloud.thethings.network:443/api/v3/js/applications/test-app/devices/b0b353fffe407a98-23720-7?

BODY {
  "end_device": {
    "ids": {
      "device_id": "b0b353fffe407a98-23720-7",
      "application_ids": {
        "application_id": "test-app"
      },
      "dev_eui": "B0B353FFFE407A98",
      "join_eui": "A100000000000000"
    },
    "network_server_address": "eu1.cloud.thethings.network",
    "application_server_address": "eu1.cloud.thethings.network",
    "root_keys": {
      "app_key": {
        "key": "XXXXXX"
      }
    }
  },
  "field_mask": {
    "paths": [
      "network_server_address",
      "application_server_address",
      "root_keys"
    ]
  }
}
PUT https://eu1.cloud.thethings.network:443/api/v3/ns/applications/test-app/devices/b0b353fffe407a98-23720-7?

BODY {
  "end_device": {
    "lorawan_version": "MAC_V1_0_2",
    "ids": {
      "device_id": "b0b353fffe407a98-23720-7",
      "application_ids": {
        "application_id": "test-app"
      },
      "dev_eui": "B0B353FFFE407A98",
      "join_eui": "A100000000000000"
    },
    "lorawan_phy_version": "PHY_V1_0_2_REV_A",
    "frequency_plan_id": "EU_863_870_TTN",
    "supports_join": true
  },
  "field_mask": {
    "paths": [
      "supports_join",
      "lorawan_version",
      "lorawan_phy_version",
      "frequency_plan_id"
    ]
  }
}
PUT https://eu1.cloud.thethings.network:443/api/v3/as/applications/test-app/devices/b0b353fffe407a98-23720-7?

BODY {
  "end_device": {
    "ids": {
      "device_id": "b0b353fffe407a98-23720-7",
      "application_ids": {
        "application_id": "test-app"
      },
      "dev_eui": "B0B353FFFE407A98",
      "join_eui": "A100000000000000"
    }
  }
}

Saying, the identifier would be duplicated:

{
  "code": 6,
  "message": "error:pkg/applicationserver/redis:duplicate_identifiers (duplicate identifiers)",
  "details": [
    {
      "@type": "type.googleapis.com/ttn.lorawan.v3.ErrorDetails",
      "namespace": "pkg/applicationserver/redis",
      "name": "duplicate_identifiers",
      "message_format": "duplicate identifiers",
      "correlation_id": "9220e38bf06b4f1b8b76ae718a6d92ae",
      "code": 6
    }
  ]
}

What can I do? How can I register the device?
Must the EUI be released after deletion? How can I achieve that?

I tried deleting the device by device_id on all servers:

"error:pkg/identityserver/store:end_device_not_found (end device with id `b0b353fffe407a98-23720-7` not found in application with id `test-app`)"
"error:pkg/joinserver:device_not_found (device not found)"
"error:pkg/networkserver:device_not_found (device not found)"
"error:pkg/identityserver/store:end_device_not_found (end device with id `b0b353fffe407a98-23720-7` not found in application with id `test-app`)"

Anyone?

What you are trying is rather esoteric - why would anyone register an app with an id of “test-app” - far too prone to clashing due to the EUI & ID constraints of the tenancy that TTN runs in.

TL;DR: Someone did, the docs will tell you about constraints + purging entities.

Did you ever find a solution to this? I am facing the same problem. I am using the API to add a device, deleted the device and then tried to add it again with a different ID and I am getting an error.

Thanks!