# Okta API Token Format

**URL:** <https://devforum.okta.com/t/okta-api-token-format/25375>\
**Category:** Questions\
**Created:** [September 21, 2023, 2:21pm UTC](https://devforum.okta.com/t/okta-api-token-format/25375 "2023-09-21T14:21:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmd](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mmd](https://devforum.okta.com/u/mmd)\
**Post date:** [September 21, 2023, 2:21pm UTC](https://devforum.okta.com/t/okta-api-token-format/25375/1 "2023-09-21T14:21:44Z")

</div>

I am wondering if there is a set format for Okta API tokens. Our team is interested in adding a RegEx for Okta API tokens to one of our tools which scans our pipeline output for exposed credentials. It seems to start with two zeros and have a total of 42 chars that can be [A-Za-z0-9-_] so the regex would be /00[\w\d-_]{40}/

Will the format ever change? For instance three zeros or 1 zero at the start?

---

<div class="post-metadata">

**Author:** ![dzeller](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dzeller/32/2790_2.png) [@dzeller](https://devforum.okta.com/u/dzeller)\
**Post date:** [September 21, 2023, 2:33pm UTC](https://devforum.okta.com/t/okta-api-token-format/25375/2 "2023-09-21T14:33:18Z")

</div>

You should not assume a set structure for Okta’s API tokens. We do not currently have plans on changing this but that is not to say that it will _not_ change in the future.

A different approach you could use would be to start using OAuth Bearer tokens which have the benefit of being short-lived, and then you could be scanning your pipeline for private keys.

> **[Implement OAuth for Okta with a service app | Okta Developer](https://developer.okta.com/docs/guides/implement-oauth-for-okta-serviceapp/main/)**
>
> Secure, scalable, and highly available authentication and user management for any app.

---

<div class="post-metadata">

**Author:** ![mmd](https://avatars.discourse-cdn.com/v4/letter/m/c77e96/32.png) [@mmd](https://devforum.okta.com/u/mmd)\
**Post date:** [September 21, 2023, 2:49pm UTC](https://devforum.okta.com/t/okta-api-token-format/25375/3 "2023-09-21T14:49:59Z")

</div>

Okay that is helpful to know. We do have plans to switch to OAuth Bearer tokens in the future. Just to be 100% certain, when you say scan the pipeline for private keys you mean set a RegEx to match any JWK format (or PEM if applicable)? Would that RegEx ever have any false positives do you think?

---

<div class="post-metadata">

**Author:** ![dzeller](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dzeller/32/2790_2.png) [@dzeller](https://devforum.okta.com/u/dzeller)\
**Post date:** [September 21, 2023, 3:15pm UTC](https://devforum.okta.com/t/okta-api-token-format/25375/4 "2023-09-21T15:15:27Z")

</div>

Private keys have a very well-known structure, so I’d suggest scanning whichever form that you are making use of that in, whether it be JWK or PEM/X.509.  
The JWK might be a little harder to get a regex built for, but scanning for private keys is a good practice no matter what they are acting as credentials for.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [September 22, 2023, 3:15pm UTC](https://devforum.okta.com/t/okta-api-token-format/25375/5 "2023-09-22T15:15:37Z")

</div>

Closed on September 22, 2023, 3:15pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
