> For a complete page index, fetch https://docs.transak.com/llms.txt # Refresh Access Token POST https://api-stg.transak.com/partners/api/v2/refresh-token Content-Type: application/json The Refresh Access Token API is an authenticated endpoint intended for access token renewal. Invoke this endpoint only when the existing access token has expired (token validity: 7 days). Do not call it repeatedly or on every request, as this can cause unnecessary token regeneration and potential rate-limiting issues. Reference: https://docs.transak.com/api/public/refresh-access-token ## Request ### Headers - `x-api-key` (string, required) — Your Partner API key. You can find this in the [Partner Dashboard](https://docs.transak.com/guides/how-to-create-partner-dashboard-account#open-the-developers-section). - `api-secret` (string, required) — Your api secret, you can get it from Transak Partner Dashboard for respective environment Note: Refer this tutorial on how to fetch the API secret from the partner dashboard. ### Body (application/json) This endpoint expects an object. - `apiKey` (string, required) — Your Api Key which you can get it from Transak Partner Dashboard for respective environment ## Response ### 200 200 - `data` (RefreshTokenPostResponsesContentApplicationJsonSchemaData, optional) ## Errors ### 400 Bad Request Error 400 - `error` (RefreshTokenPostResponsesContentApplicationJsonSchemaError, required) ### 401 Unauthorized Error 401 - `error` (RefreshTokenPostResponsesContentApplicationJsonSchemaError, required) ## Types ### RefreshTokenPostResponsesContentApplicationJsonSchemaData - `accessToken` (string, optional) — accessToken is Authorization token recived by API response - `expiresAt` (integer, optional, default: 0) — accessToken expire Timestamp ### RefreshTokenPostResponsesContentApplicationJsonSchemaError - `statusCode` (integer, required) - `message` (string, required) ## Examples **Request** ```json { "apiKey": "" } ``` **Response** ```json { "data": { "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBUElfS0VZIjoiZDc5NjcxYTQtYjAyMS00YTRmLWE0NDQtNjg2MmE2ODBhOTRiIiwiaWF0IjoxNzI5MTcxMDI1LCJleHAiOjE3Mjk3NzU4MjV9.IhlgDVlYcctmfUfyZv-CMylZpJK5-b3hD40cLLsWwU0", "expiresAt": 1729775825 } } ``` **SDK Code** ```python Success import requests url = "https://api-stg.transak.com/partners/api/v2/refresh-token" payload = { "apiKey": "" } headers = { "api-secret": "", "x-api-key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript Success const url = 'https://api-stg.transak.com/partners/api/v2/refresh-token'; const options = { method: 'POST', headers: {'api-secret': '', 'x-api-key': '', 'Content-Type': 'application/json'}, body: '{"apiKey":""}' }; 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" "strings" "net/http" "io" ) func main() { url := "https://api-stg.transak.com/partners/api/v2/refresh-token" payload := strings.NewReader("{\n \"apiKey\": \"\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("api-secret", "") req.Header.Add("x-api-key", "") req.Header.Add("Content-Type", "application/json") 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-stg.transak.com/partners/api/v2/refresh-token") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["api-secret"] = '' request["x-api-key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"apiKey\": \"\"\n}" response = http.request(request) puts response.read_body ``` ```java Success import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api-stg.transak.com/partners/api/v2/refresh-token") .header("api-secret", "") .header("x-api-key", "") .header("Content-Type", "application/json") .body("{\n \"apiKey\": \"\"\n}") .asString(); ``` ```php Success request('POST', 'https://api-stg.transak.com/partners/api/v2/refresh-token', [ 'body' => '{ "apiKey": "" }', 'headers' => [ 'Content-Type' => 'application/json', 'api-secret' => '', 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp Success using RestSharp; var client = new RestClient("https://api-stg.transak.com/partners/api/v2/refresh-token"); var request = new RestRequest(Method.POST); request.AddHeader("api-secret", ""); request.AddHeader("x-api-key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"apiKey\": \"\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift Success import Foundation let headers = [ "api-secret": "", "x-api-key": "", "Content-Type": "application/json" ] let parameters = ["apiKey": ""] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-stg.transak.com/partners/api/v2/refresh-token")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ```