# How to create a new API Token via postman or python?

**URL:** <https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161>\
**Category:** Questions\
**Created:** [September 15, 2021, 8:13pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161 "2021-09-15T20:13:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcmagno](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mcmagno](https://devforum.okta.com/u/mcmagno)\
**Post date:** [September 15, 2021, 8:13pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/1 "2021-09-15T20:13:18Z")

</div>

API Token expires after 30 days and we would want it to still be valid when needed to be used so we would want to automate new API token creation and old API token deletion via a script. Is that possible?

---

<div class="post-metadata">

**Author:** ![Lijia](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/lijia/32/2295_2.png) [@Lijia](https://devforum.okta.com/u/Lijia)\
**Post date:** [September 15, 2021, 10:09pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/2 "2021-09-15T22:09:38Z")

</div>

@mcmagno The only way to create API token is from Okta Security-\> API  
[https://developer.okta.com/docs/guides/create-an-api-token/create-the-token/](https://developer.okta.com/docs/guides/create-an-api-token/create-the-token/)  
API tokens are valid for 30 days and automatically renew every time they are used with an API request. So if you do not want to see it expired, just call it within 30 days.

---

<div class="post-metadata">

**Author:** ![mcmagno](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mcmagno](https://devforum.okta.com/u/mcmagno)\
**Post date:** [September 15, 2021, 10:21pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/3 "2021-09-15T22:21:26Z")

</div>

thank you for your answer! however, we would want to automate it. is there no other way to do that?

---

<div class="post-metadata">

**Author:** ![Lijia](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/lijia/32/2295_2.png) [@Lijia](https://devforum.okta.com/u/Lijia)\
**Post date:** [September 15, 2021, 11:26pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/4 "2021-09-15T23:26:38Z")

</div>

@mcmagno Np. You can set up an auto call to a related API token request every 30 days.

---

<div class="post-metadata">

**Author:** ![mcmagno](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mcmagno](https://devforum.okta.com/u/mcmagno)\
**Post date:** [September 16, 2021, 2:28pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/5 "2021-09-16T14:28:39Z")

</div>

can you share please the link to the documentation of this approach? thanks!

---

<div class="post-metadata">

**Author:** ![Lijia](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/lijia/32/2295_2.png) [@Lijia](https://devforum.okta.com/u/Lijia)\
**Post date:** [September 16, 2021, 6:23pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/6 "2021-09-16T18:23:18Z")

</div>

@mcmagno There are a lot related calls with API token.  
You can find it in Okta APIs.  
[https://developer.okta.com/docs/reference/#core-okta-api](https://developer.okta.com/docs/reference/#core-okta-api)  
as long as it includes the request parameter

```auto
SSWS ${api_token}

```

Here is more reference for API token management.  
[https://help.okta.com/en/prod/Content/Topics/Security/API.htm](https://help.okta.com/en/prod/Content/Topics/Security/API.htm)

---

<div class="post-metadata">

**Author:** ![Bergerson588](https://avatars.discourse-cdn.com/v4/letter/b/71e660/32.png) [@Bergerson588](https://devforum.okta.com/u/Bergerson588)\
**Post date:** [September 29, 2021, 7:14am UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/8 "2021-09-29T07:14:56Z")

</div>

I found out, that I am able to refresh the access token via oauth. So initially I use Selenium to get the access token for the first time via oauth2’s login page, simulating a human. When I got the key, I refresh it when the key expires[.](https://www.upsers.page/)

---

<div class="post-metadata">

**Author:** ![Lijia](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/lijia/32/2295_2.png) [@Lijia](https://devforum.okta.com/u/Lijia)\
**Post date:** [October 4, 2021, 7:17pm UTC](https://devforum.okta.com/t/how-to-create-a-new-api-token-via-postman-or-python/16161/10 "2021-10-04T19:17:04Z")

</div>

Closed on October 4, 2021, 7:17pm UTC


