Generate an API Token
curl --request POST \
--url https://api.flare.io/tokens/generate \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"tenant_id": 123
}
'import requests
url = "https://api.flare.io/tokens/generate"
payload = { "tenant_id": 123 }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({tenant_id: 123})
};
fetch('https://api.flare.io/tokens/generate', 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://api.flare.io/tokens/generate",
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([
'tenant_id' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$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://api.flare.io/tokens/generate"
payload := strings.NewReader("{\n \"tenant_id\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flare.io/tokens/generate")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"tenant_id\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flare.io/tokens/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tenant_id\": 123\n}"
response = http.request(request)
puts response.read_body{
"refresh_token_exp": 1723673997,
"token": "i-am-an-example-api-token"
}
{
"refresh_token_exp": <number (unix timestamp)>,
"token": "<string>"
}
Tokens
Generate an API Token
POST
/
tokens
/
generate
Generate an API Token
curl --request POST \
--url https://api.flare.io/tokens/generate \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"tenant_id": 123
}
'import requests
url = "https://api.flare.io/tokens/generate"
payload = { "tenant_id": 123 }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({tenant_id: 123})
};
fetch('https://api.flare.io/tokens/generate', 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://api.flare.io/tokens/generate",
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([
'tenant_id' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$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://api.flare.io/tokens/generate"
payload := strings.NewReader("{\n \"tenant_id\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.flare.io/tokens/generate")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"tenant_id\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.flare.io/tokens/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tenant_id\": 123\n}"
response = http.request(request)
puts response.read_body{
"refresh_token_exp": 1723673997,
"token": "i-am-an-example-api-token"
}
{
"refresh_token_exp": <number (unix timestamp)>,
"token": "<string>"
}
Tokens are used to interact with the Flare API.
They can be generated using an API key provided via the Authorization header.
API tokens expire after 1 hour.
The endpoint returns an API token via the response body, but also via cookies which can then be used in future HTTP requests.
For more information about authentication, see the
API Authentication Guide .
{
"refresh_token_exp": 1723673997,
"token": "i-am-an-example-api-token"
}
{
"refresh_token_exp": <number (unix timestamp)>,
"token": "<string>"
}
Auth Headers
Your Flare API key.
Body Parameters
The tenant you want to authenticate to.
When unspecified, the API token will be generated for your default tenant.
Response Fields
The generated API token.
Unix timestamp of the expiration of the refresh token.(The refresh token is returned in cookies).
Was this page helpful?
⌘I