curl --request POST \
--url https://api.devic.ai/api/v1/tenant-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tenantId": "acme-corp",
"subtenantId": "acme-corp-eu",
"ttlSeconds": 3600
}
'import requests
url = "https://api.devic.ai/api/v1/tenant-sessions"
payload = {
"tenantId": "acme-corp",
"subtenantId": "acme-corp-eu",
"ttlSeconds": 3600
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({tenantId: 'acme-corp', subtenantId: 'acme-corp-eu', ttlSeconds: 3600})
};
fetch('https://api.devic.ai/api/v1/tenant-sessions', 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.devic.ai/api/v1/tenant-sessions",
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([
'tenantId' => 'acme-corp',
'subtenantId' => 'acme-corp-eu',
'ttlSeconds' => 3600
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.devic.ai/api/v1/tenant-sessions"
payload := strings.NewReader("{\n \"tenantId\": \"acme-corp\",\n \"subtenantId\": \"acme-corp-eu\",\n \"ttlSeconds\": 3600\n}")
req, _ := http.NewRequest("POST", 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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.devic.ai/api/v1/tenant-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tenantId\": \"acme-corp\",\n \"subtenantId\": \"acme-corp-eu\",\n \"ttlSeconds\": 3600\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devic.ai/api/v1/tenant-sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tenantId\": \"acme-corp\",\n \"subtenantId\": \"acme-corp-eu\",\n \"ttlSeconds\": 3600\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"tokenType": "Bearer",
"tenantId": "<string>",
"subtenantId": "<string>",
"expiresIn": 123,
"expiresAt": 123
}Issue a tenant session
Mints a short-lived token that proves which end user is calling, instead of trusting what the page claims. Your backend asks for it with a server-side API key and hands it to the browser; from then on the widget calls Devic with the session token and the tenant can no longer be forged.
Two rules keep the guarantee honest, and both are enforced:
- A session cannot issue another session. An expiry that the holder can extend is not an expiry.
- The call must come from a server. A request carrying an
Originheader, or made with a key configured for browser domains, is refused — a session minted with a key that ships in a bundle would prove nothing.
ttlSeconds is clamped into the allowed range rather than rejected: ask for a year and you get twelve hours.
Note the path. This is the one public endpoint served by the gateway itself rather than proxied, so it is reached at /api/v1/tenant-sessions — the /api prefix that the rest of the API accepts optionally is required here.
curl --request POST \
--url https://api.devic.ai/api/v1/tenant-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tenantId": "acme-corp",
"subtenantId": "acme-corp-eu",
"ttlSeconds": 3600
}
'import requests
url = "https://api.devic.ai/api/v1/tenant-sessions"
payload = {
"tenantId": "acme-corp",
"subtenantId": "acme-corp-eu",
"ttlSeconds": 3600
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({tenantId: 'acme-corp', subtenantId: 'acme-corp-eu', ttlSeconds: 3600})
};
fetch('https://api.devic.ai/api/v1/tenant-sessions', 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.devic.ai/api/v1/tenant-sessions",
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([
'tenantId' => 'acme-corp',
'subtenantId' => 'acme-corp-eu',
'ttlSeconds' => 3600
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.devic.ai/api/v1/tenant-sessions"
payload := strings.NewReader("{\n \"tenantId\": \"acme-corp\",\n \"subtenantId\": \"acme-corp-eu\",\n \"ttlSeconds\": 3600\n}")
req, _ := http.NewRequest("POST", 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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.devic.ai/api/v1/tenant-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tenantId\": \"acme-corp\",\n \"subtenantId\": \"acme-corp-eu\",\n \"ttlSeconds\": 3600\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devic.ai/api/v1/tenant-sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tenantId\": \"acme-corp\",\n \"subtenantId\": \"acme-corp-eu\",\n \"ttlSeconds\": 3600\n}"
response = http.request(request)
puts response.read_body{
"token": "<string>",
"tokenType": "Bearer",
"tenantId": "<string>",
"subtenantId": "<string>",
"expiresIn": 123,
"expiresAt": 123
}Authorizations
An API key from your Devic console, sent as Authorization: Bearer <key>. An embedded front end sends a tenant-session token instead, so no API key reaches the browser, and an OAuth integration sends its access token. Missing, invalid or expired credentials get a 401. See Authentication.