> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://partner.tradovate.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://partner.tradovate.com/_mcp/server.

# Renew Access Token

GET https://demo.tradovateapi.com/v1/auth/renewaccesstoken

### Request a renewal for an existing access token.

Extends the current session without creating a new one. Using this function in a long-running application will ensure that you don't start a new session unless it is 100% necessary. This will prevent your application from kicking itself or dropping dependent services that share an Access Token. See the [`/auth/accessTokenRequest`](#operation/accessTokenRequest) operation for more details.

```js

const { accessToken, expirationTime } = await fetch(TRADOVATELIVE+'/auth/accessTokenRequest', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
    },
    body: JSON.stringify(myCredentials) //see auth/accessTokenRequest for more info on the request body
}).then(res => res.json());

sessionStorage.setItem(CURRENT_TOKEN_KEY, accessToken);
sessionStorage.setItem(TOKEN_EXPIRATION_KEY, expirationTime);

//in another file or function, keep the connection alive
//check every 2 mins using useInterval (WARNING on a browser
//this fn will be throttled. Consider using a WebWorker to maintain
//a connection even when tabbed away.)
setInterval(() => {
    const expiration = sessionStorage.getItem(TOKEN_EXPIRATION_KEY);
    const now = new Date().getTime();
    const exp = new Date(expiration).getTime();
    //if expiration is within 15 mins, renew
    if(exp - now < 15 * 60000) {
        const currentToken = sessionStorage.getItem(CURRENT_TOKEN_KEY);
        const renewal = await fetch(TRADOVATELIVE+'/auth/renewAccessToken', {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json',
                'Authorization': `Bearer ${currentToken}` //send existing non-expired token
            }
        });
        //set new token and expiration
        sessionStorage.setItem(CURRENT_TOKEN_KEY, renewal.accessToken);
        sessionStorage.setItem(TOKEN_EXPIRATION_KEY, renewal.expirationTime);
    }
}, 120 * 60000)

```

Reference: https://partner.tradovate.com/api/rest-api-endpoints/authentication/renew-access-token

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Response

### 200

AccessTokenResponse

- `errorText` (string, optional) — Non-empty if the request failed
- `hibpHint` (enum, optional) — EmailAndPasswordCompromised, PasswordCompromised
  - Allowed values: `EmailAndPasswordCompromised`, `PasswordCompromised`
- `accessToken` (string, optional)
- `expirationTime` (datetime, optional)
- `passwordExpirationTime` (datetime, optional)
- `userStatus` (enum, optional) — Active, Closed, Initiated, TemporaryLocked, UnconfirmedEmail
  - Allowed values: `Active`, `Closed`, `Initiated`, `TemporaryLocked`, `UnconfirmedEmail`
- `userId` (long, optional)
- `name` (string, optional)
- `hasLive` (boolean, optional)
- `hasSimPlus` (boolean, optional)
- `showKIDs` (boolean, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "errorText": "",
  "hibpHint": "EmailAndPasswordCompromised",
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEyMzQsImV4cCI6MTY5NjQ4MDAwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "expirationTime": "2024-01-15T09:30:00Z",
  "passwordExpirationTime": "2024-01-15T09:30:00Z",
  "userStatus": "Active",
  "userId": 12345,
  "name": "Jane Doe",
  "hasLive": true,
  "hasSimPlus": true,
  "showKIDs": true
}
```

**SDK Code**

```python
import requests

url = "https://demo.tradovateapi.com/v1/auth/renewaccesstoken"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://demo.tradovateapi.com/v1/auth/renewaccesstoken';
const options = {
  method: 'GET',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

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

```go
package main

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

func main() {

	url := "https://demo.tradovateapi.com/v1/auth/renewaccesstoken"

	payload := strings.NewReader("{}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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
require 'uri'
require 'net/http'

url = URI("https://demo.tradovateapi.com/v1/auth/renewaccesstoken")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

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

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

HttpResponse<String> response = Unirest.get("https://demo.tradovateapi.com/v1/auth/renewaccesstoken")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://demo.tradovateapi.com/v1/auth/renewaccesstoken', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://demo.tradovateapi.com/v1/auth/renewaccesstoken");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://demo.tradovateapi.com/v1/auth/renewaccesstoken")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```