> For the complete documentation index, see [llms.txt](https://docs.cosmocloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cosmocloud.io/examples-how-to/accessing-auth-tokens-in-apis.md).

# Accessing Auth Tokens in APIs

You would have often faced times where you need to read the access token / auth token and read some certain values from the same (such as `user_id`).

To do this, we would first need to configure authentication in Cosmocloud and define the schema of the decoded token - mentioning what parameters can be expected in the token.

## Defining the token schema in Authentication Secret

While creating or updating the Authentication Secret, you can define the schema of the token there itself. For example -

<figure><img src="/files/HxchXlodYcDYYrLN4rX2" alt=""><figcaption></figcaption></figure>

As you can see above, our auth token can have fields such as `sub`, `orgId`, `name` and `age`. We say that `sub` is the field where the user's ID would also be present, hence we add `sub` to `User Id Key` field as well.

{% hint style="info" %}
For more details on how to configure Authentication and how to define the decoded token schema, please check this link.
{% endhint %}

## Accessing token properties in Flow Builder

Now, once we have defined the schema of our token in our Authentication Secret, we can now access these in our Flow Builder using [Magical Autocomplete](/flow-builder/cql-cosmocloud-query-language/magical-autocomplete.md), such as - `$.tokenData.sub`

### Token Properties

You can access any token property you set in the secret using the format - `$.tokenData.<key_name>`.

You can also access the **raw token**, sometimes useful to pass to another API call, using the syntax - `$.tokenData.rawToken`
