> For a complete page index, fetch https://docs.transak.com/llms.txt

# Refresh User Access Token

GET https://api-gateway-stg.transak.com/api/v2/auth/refresh

The **Refresh Access Token** is an **authenticated** API which should be used when access token is about to expire (not expired).

If Access token is expired, it cannot be refreshed. In that case, Only OTP authentication is the way to generate a new access token

Reference: https://docs.transak.com/api/whitelabel/user/refresh-user-access-token

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: whitelabel-api
  version: 1.0.0
paths:
  /api/v2/auth/refresh:
    get:
      operationId: refresh-user-access-token
      summary: Refresh User Access Token
      description: >-
        The **Refresh Access Token** is an **authenticated** API which should be
        used when access token is about to expire (not expired).


        If Access token is expired, it cannot be refreshed. In that case, Only
        OTP authentication is the way to generate a new access token
      tags:
        - subpackage_user
      parameters:
        - name: authorization
          in: header
          description: >-
            Authorization token is the accessToken received from the API -`
            api/v2/auth/verify`
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 200 - Success
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/User_refresh-user-access-token_Response_200
        '500':
          description: 500 - Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Refresh-user-access-tokenRequestInternalServerError
servers:
  - url: https://api-gateway-stg.transak.com
    description: Staging
components:
  schemas:
    ApiV2AuthRefreshGetResponsesContentApplicationJsonSchemaData:
      type: object
      properties:
        accessToken:
          type: string
      required:
        - accessToken
      title: ApiV2AuthRefreshGetResponsesContentApplicationJsonSchemaData
    User_refresh-user-access-token_Response_200:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/ApiV2AuthRefreshGetResponsesContentApplicationJsonSchemaData
      required:
        - data
      title: User_refresh-user-access-token_Response_200
    ApiV2AuthRefreshGetResponsesContentApplicationJsonSchemaError:
      type: object
      properties:
        statusCode:
          type: integer
        message:
          type: string
      required:
        - statusCode
        - message
      title: ApiV2AuthRefreshGetResponsesContentApplicationJsonSchemaError
    Refresh-user-access-tokenRequestInternalServerError:
      type: object
      properties:
        error:
          $ref: >-
            #/components/schemas/ApiV2AuthRefreshGetResponsesContentApplicationJsonSchemaError
      required:
        - error
      title: Refresh-user-access-tokenRequestInternalServerError

```

## Examples



**Response**

```json
{
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY3RpdmUiOnRydWUsInBlcm1pc3Npb25zIjpbXSwicm9sZXMiOltdLCJ0b2tlbl90eXBlIjoiQmVhcmVyIiwic3ViIjoiYW5zaHVsLmdhcmcrdGVzdGFwaTFAdHJhbnNhay5jb20iLCJhdWQiOiI5OTVhY2RlZjhmYjQwNzRjNTFhYWY1N2ZhNjUwNDVmN21ham91Y2I0IiwiaXNzIjoiaHR0cHM6Ly90cmFuc2FrLmNvbS9hdXRoIiwianRpIjoiMGQyNGJmMTctNjMxNS00NjEzLTg1ZmItOTIxZGFlYjNkNWRlIiwiaWF0IjoxNzUwMzI5NzM1LCJleHAiOjE3NTI5MjE3MzV9.Z4L2myLTfccFLQ_aN6uHLdOSPBjTsm-VjfSHJeeD18A"
  }
}
```

**SDK Code**

```python Success
import requests

url = "https://api-gateway-stg.transak.com/api/v2/auth/refresh"

headers = {"authorization": ""}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript Success
const url = 'https://api-gateway-stg.transak.com/api/v2/auth/refresh';
const options = {method: 'GET', headers: {authorization: ''}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Success
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api-gateway-stg.transak.com/api/v2/auth/refresh"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("authorization", "")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Success
require 'uri'
require 'net/http'

url = URI("https://api-gateway-stg.transak.com/api/v2/auth/refresh")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["authorization"] = ''

response = http.request(request)
puts response.read_body
```

```java Success
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api-gateway-stg.transak.com/api/v2/auth/refresh")
  .header("authorization", "")
  .asString();
```

```php Success
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api-gateway-stg.transak.com/api/v2/auth/refresh', [
  'headers' => [
    'authorization' => '',
  ],
]);

echo $response->getBody();
```

```csharp Success
using RestSharp;

var client = new RestClient("https://api-gateway-stg.transak.com/api/v2/auth/refresh");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "");
IRestResponse response = client.Execute(request);
```

```swift Success
import Foundation

let headers = ["authorization": ""]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway-stg.transak.com/api/v2/auth/refresh")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```