> For the complete documentation index, see [llms.txt](https://help.citrusad.com/retail-media-interface/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.citrusad.com/retail-media-interface/partner/pt-br/partner-api-authentication/user-key-authentication.md).

# Token da chave do usuário

## Solicitando tokens

Para receber o seu token de acesso necessário, faça uma solicitação para o `/user-key-token` endpoint adicionando os seguintes parâmetros usando o `application/x-www-form-urlencoded` formato com uma codificação de caracteres UTF-8 no corpo da solicitação HTTP.

```http
POST https://auth.<env>.citrusad.com/v2/user-key-token
Content-Type: application/x-www-form-urlencoded
user_key=<USER_KEY>
```

Você receberá uma resposta com um `accessToken`,`expiresIn`, e `tokenType`.

```json
{
    "accessToken": "ACCESS_TOKEN",
    "expiresIn": 84000,
    "tokenType": "Bearer"
}
```

{% hint style="info" %}
Seu token de **acesso** é usado para acessar a Epsilon Retail Media API.
{% endhint %}

## Atualizar token

Quando o seu token de acesso expirar, você receberá um erro de token inválido da API da campanha. Neste caso, você fará uma solicitação para o `/token` endpoint com o seu token de atualização conforme ilustrado no diagrama abaixo:

<figure><img src="/files/3MZL9gNW6LNdrIfvch3U" alt="Authentication refresh flow.png" width="100%"><figcaption></figcaption></figure>

Geralmente, um usuário só precisará de um novo token de acesso quando o anterior expirar, ou quando obtiver ou perder o acesso a recursos que estão anexados às suas reivindicações. É uma má prática chamar o endpoint para obter um novo token de acesso para cada solicitação à nossa API.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.citrusad.com/retail-media-interface/partner/pt-br/partner-api-authentication/user-key-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
