curl -X POST https://your-ocient-instance/v1/token_refresh \
-H "Authorization: Bearer YOUR_CURRENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"database": "retail_analytics"
}'import requests
url = "https://{sql_node}/v1/token_refresh"
payload = { "database": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
body: JSON.stringify({database: '<string>'})
};
fetch('https://{sql_node}/v1/token_refresh', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{sql_node}/v1/token_refresh",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'database' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{sql_node}/v1/token_refresh"
payload := strings.NewReader("{\n \"database\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{sql_node}/v1/token_refresh")
.header("Authorization", "<authorization>")
.header("Content-Type", "<content-type>")
.body("{\n \"database\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{sql_node}/v1/token_refresh")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"database\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhb...",
"username": "jdoe",
"database": "retail_analytics",
"expires_in": 3600,
"status": {
"reason": "Token refreshed successfully",
"sql_state": "00000",
"vendor_code": 0
}
}token_refresh
Refreshes an existing access token, extending its validity period. Call this endpoint before the current token expires to maintain uninterrupted access. Use the expires_in value from the login or previous refresh response to determine when to refresh the token. A common practice is to refresh when the token has half of its time remaining. On success, the endpoint returns the 200 response and a JSON object containing a new access token and metadata about the refreshed session. Replace the access token in your client with the new token returned by the endpoint, and use the expires_in value to decide when to refresh again.
curl -X POST https://your-ocient-instance/v1/token_refresh \
-H "Authorization: Bearer YOUR_CURRENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"database": "retail_analytics"
}'import requests
url = "https://{sql_node}/v1/token_refresh"
payload = { "database": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': '<content-type>'},
body: JSON.stringify({database: '<string>'})
};
fetch('https://{sql_node}/v1/token_refresh', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{sql_node}/v1/token_refresh",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'database' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{sql_node}/v1/token_refresh"
payload := strings.NewReader("{\n \"database\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{sql_node}/v1/token_refresh")
.header("Authorization", "<authorization>")
.header("Content-Type", "<content-type>")
.body("{\n \"database\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{sql_node}/v1/token_refresh")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"database\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhb...",
"username": "jdoe",
"database": "retail_analytics",
"expires_in": 3600,
"status": {
"reason": "Token refreshed successfully",
"sql_state": "00000",
"vendor_code": 0
}
}Headers
The bearer token, which must be a valid access token still within its refresh lifetime configured on the server. To obtain a token, call either the /v1/login or /v1/token_refresh endpoints.
Specifies the request body format. Use the value: application/json.
Body
Target database name. If you do not specify this parameter, the request defaults this value to system.
Was this page helpful?

