> ## Documentation Index
> Fetch the complete documentation index at: https://docs.withbenji.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Refresh a user access token

> Silently refresh the user access token for a specific user without requiring them to reconnect their account

> [!NOTE]
>
> The `x-api-key` header value to be used on this API is your **partner API key**, which can be generated through the dashboard.

**refresh\_token** `string` *required*

The refresh token received from the [exchange token](https://docs.withbenji.com/connect/exchange_token.md) API flow or previously received from refreshing an access token from this API

**access\_token** `string` *required*

The current access token you are refreshing

### Return values

**user\_id** `integer` *required*

The Benji Platform ID associated with the user.

**merchant\_id** `integer` *required*

Your system ID as specified on the Benji Platform.

**token\_data** `object` *required*

An object representing the access\_token, refresh\_token to use when using the Benji Platform APIs as well as the access token expiry date. Once an access token expires, you can use the refresh token to obtain a new access token silently without requiring the user to authenticate again.

**properties**

**access\_token** `string` *required*

A new access token to use when making user-oriented requests to the Benji Platform APIs

**refresh\_token** `string` *required*

Refresh Token to use in order to silently obtain a new access token when it expires

**access\_token\_expires\_at** `string` *required*

A string representing a datetime of when this access token will expire

```json 200 theme={null}
{
    "code": "ok",
    "data": {
        "user_id": 1,
        "merchant_id": 1,
        "token_data": {
            "access_token": "0c371a1c-aa81-11ef-b28c-0a58a9feac02",
            "refresh_token": "05tghegts-aa81-sgte-hgte-u8nhgbvgtio",
            "access_token_expires_at": "Tue, 22 Oct 2024 21:57:02 GMT"
        }
    }
}
```

```json 400 theme={null}
{
  "error": "invalid_token",
  "message": "Invalid refresh or access token"
}
```

```json 401 theme={null}
{
  "error": "unauthorized_request",
  "message": "Token is not authorized to make this request"
}
```

> [!TIP]
>
> Access tokens are typically valid for 90 days. You can refresh an access token either before it expires proactively, or after calling an API and getting an expired\_token 401 status code.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.