> ## 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.</Note>

<ParamField body="refresh_token" type="string" required>
  The refresh token received from the [exchange token](/connect/exchange_token) API flow or previously received from refreshing an access token from this API
</ParamField>

<ParamField body="access_token" type="string" required>
  The current access token you are refreshing
</ParamField>

### Return values

<ResponseField name="user_id" type="integer" required>
  The Benji Platform ID associated with the user.
</ResponseField>

<ResponseField name="merchant_id" type="integer" required>
  Your system ID as specified on the Benji Platform.
</ResponseField>

<ResponseField name="token_data" type="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.

  <Expandable title="properties" defaultOpen="true">
    <ResponseField name="access_token" type="string" required>A new access token to use when making user-oriented requests to the Benji Platform APIs </ResponseField>
    <ResponseField name="refresh_token" type="string" required>Refresh Token to use in order to silently obtain a new access token when it expires </ResponseField>
    <ResponseField name="access_token_expires_at" type="string" required>A string representing a datetime of when this access token will expire </ResponseField>
  </Expandable>
</ResponseField>

<ResponseExample>
  ```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"
  }
  ```
</ResponseExample>

<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.</Tip>
