# Token Expiry: after X days the token auto deletes

**URL:** <https://community.dynatrace.com/t/token-expiry-after-x-days-the-token-auto-deletes/44208>\
**Category:** Open Q&A\
**Tags:** tokens\
**Created:** [February 20, 2024, 6:45pm UTC](https://community.dynatrace.com/t/token-expiry-after-x-days-the-token-auto-deletes/44208 "2024-02-20T18:45:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [February 20, 2024, 6:45pm UTC](https://community.dynatrace.com/t/token-expiry-after-x-days-the-token-auto-deletes/44208/1 "2024-02-20T18:45:25Z")

</div>

In order to maintain strict control over tokens we typically attach an expiration date where applicable now that we are in the DPS model. So we had a team who requested a PaaS token permission set, we put it to expire at the end of January. The team has since then requested an extension which has been granted. Yes, you cannot edit/alter token access after they are formulated. So I wont be able to extend the expiry date, which is fine. But what I can do is clone the token and provide a new one with another month window.

This is where things get odd… Dynatrace doesn’t mention in any documentation that I found that it will auto delete token after it expires for x amount of days.

Here is the original token:

 ![ChadTurner_0-1708454234917.png](https://global.discourse-cdn.com/dynatrace/original/3X/a/a/aab3365e57bcbaa881ead1d52cb34adf6073a889.png)

2 weeks after the expiry the team requested a token extension. To which I tossed in the Token ID but it was no where to be found in the system. Which prompted me to pull the audit log where we find this:

![ChadTurner_1-1708454367924.png](https://global.discourse-cdn.com/dynatrace/optimized/3X/c/8/c8a64678d98b5001d89210c7dcded1f20a90a22f_2_690x15.png)

Notice the Token worker has deleted the ‘Expired’ token on the 4th of February.

 ![ChadTurner_2-1708454432318.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/0/70ef3b9e444ef8ece9897f8b2e1b3e6d73ebc86e.png)

Now I’m all for keeping a clean environment, but this caught me off guard. The token expired on Jan. 27th and was auto deleted on Feb 4th, 6 days later.

It could have been a fluke… so we created a test one called “Poof - The Magic Token” by Wednesday/Thursday we will see if the system deleted the token. Its already marked as expired:

 ![ChadTurner_3-1708454626942.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/4/94dce8481a6a29163dee80f3b7164b7725b7fd97.png)

 ![ChadTurner_4-1708454681934.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/6/d64a7a62e796026fb8e3ef2e7a296d3311ce20b2.png)

Please let me know what you may have run into with this as well.

---

<div class="post-metadata">

**Author:** ![JoseRomero](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/joseromero/32/19486_2.png) [@JoseRomero](https://community.dynatrace.com/u/JoseRomero)\
**Post date:** [February 20, 2024, 11:40pm UTC](https://community.dynatrace.com/t/token-expiry-after-x-days-the-token-auto-deletes/44208/2 "2024-02-20T23:40:28Z")

</div>

When a token expires, it ceases to function, meaning attempts to use it for authentication will result in a 401 error. Despite this, the token remains visible in the UI and is accessible through the token API endpoints (/api/v1/tokens/\<ID\> or /api/v2/apiTokens/\<ID\>). Seven days after its expiration, the token is automatically deleted, at which point it will no longer appear in the UI, and the token API will return a 404 error for that specific token ID.

It’s also worth noting that a token’s status can be changed to disabled, either via the API or by altering the “Enabled” toggle within the token UI.
