create widget session token
curl --request POST \
--url https://api.anam.ai/v1/auth/widget \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "071b0286-4cce-4808-bee2-e642f1062de3"
}
'import requests
url = "https://api.anam.ai/v1/auth/widget"
payload = { "agentId": "071b0286-4cce-4808-bee2-e642f1062de3" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({agentId: '071b0286-4cce-4808-bee2-e642f1062de3'})
};
fetch('https://api.anam.ai/v1/auth/widget', 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.anam.ai/v1/auth/widget",
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([
'agentId' => '071b0286-4cce-4808-bee2-e642f1062de3'
]),
CURLOPT_HTTPHEADER => [
"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.anam.ai/v1/auth/widget"
payload := strings.NewReader("{\n \"agentId\": \"071b0286-4cce-4808-bee2-e642f1062de3\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.anam.ai/v1/auth/widget")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"071b0286-4cce-4808-bee2-e642f1062de3\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.anam.ai/v1/auth/widget")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"071b0286-4cce-4808-bee2-e642f1062de3\"\n}"
response = http.request(request)
puts response.read_body{
"sessionToken": "<string>"
}{
"error": "Missing or invalid agentId",
"details": {}
}{
"error": "Origin not allowed",
"origin": "https://customer.example",
"hint": "Add \"https://customer.example\" to allowed origins in widget settings"
}{
"error": "Agent not found"
}{
"error": "Failed to create session"
}create widget session token
Create a session token for a configured widget. The request origin must be allowed by the persona’s widget configuration unless the widget is configured to allow every origin. When watermark removal is configured, the token also requests removal of the AI avatar disclosure; the engine re-checks the organization’s current entitlement when the session starts.
POST
/
v1
/
auth
/
widget
create widget session token
curl --request POST \
--url https://api.anam.ai/v1/auth/widget \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "071b0286-4cce-4808-bee2-e642f1062de3"
}
'import requests
url = "https://api.anam.ai/v1/auth/widget"
payload = { "agentId": "071b0286-4cce-4808-bee2-e642f1062de3" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({agentId: '071b0286-4cce-4808-bee2-e642f1062de3'})
};
fetch('https://api.anam.ai/v1/auth/widget', 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.anam.ai/v1/auth/widget",
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([
'agentId' => '071b0286-4cce-4808-bee2-e642f1062de3'
]),
CURLOPT_HTTPHEADER => [
"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.anam.ai/v1/auth/widget"
payload := strings.NewReader("{\n \"agentId\": \"071b0286-4cce-4808-bee2-e642f1062de3\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.anam.ai/v1/auth/widget")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"071b0286-4cce-4808-bee2-e642f1062de3\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.anam.ai/v1/auth/widget")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"071b0286-4cce-4808-bee2-e642f1062de3\"\n}"
response = http.request(request)
puts response.read_body{
"sessionToken": "<string>"
}{
"error": "Missing or invalid agentId",
"details": {}
}{
"error": "Origin not allowed",
"origin": "https://customer.example",
"hint": "Add \"https://customer.example\" to allowed origins in widget settings"
}{
"error": "Agent not found"
}{
"error": "Failed to create session"
}Headers
Body
application/json

