Mint client token
curl --request POST \
--url https://your-instance.example.com/api/client-tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ephemeralId": "browser-abc123",
"session": "my-session",
"ttlSeconds": 900
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({ephemeralId: 'browser-abc123', session: 'my-session', ttlSeconds: 900})
};
fetch('https://your-instance.example.com/api/client-tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://your-instance.example.com/api/client-tokens"
payload = {
"ephemeralId": "browser-abc123",
"session": "my-session",
"ttlSeconds": 900
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/client-tokens"
payload := strings.NewReader("{\n \"ephemeralId\": \"browser-abc123\",\n \"session\": \"my-session\",\n \"ttlSeconds\": 900\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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/client-tokens",
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([
'ephemeralId' => 'browser-abc123',
'session' => 'my-session',
'ttlSeconds' => 900
]),
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;
}{
"expiresAt": "2025-03-16T15:15:00Z",
"token": "titan_ct_eyJhbGciOi..."
}{
"docs": "https://docs.polymorfa.com/api/messages/send",
"error": "missing required field: chatId"
}{
"error": "missing or invalid API key"
}{
"docs": "<string>",
"error": "<string>"
}client-tokens
Mint client token
Creates a short-lived client token scoped to a specific session. Current session rules determine the actions the token can perform.
POST
/
api
/
client-tokens
Mint client token
curl --request POST \
--url https://your-instance.example.com/api/client-tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ephemeralId": "browser-abc123",
"session": "my-session",
"ttlSeconds": 900
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({ephemeralId: 'browser-abc123', session: 'my-session', ttlSeconds: 900})
};
fetch('https://your-instance.example.com/api/client-tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://your-instance.example.com/api/client-tokens"
payload = {
"ephemeralId": "browser-abc123",
"session": "my-session",
"ttlSeconds": 900
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-instance.example.com/api/client-tokens"
payload := strings.NewReader("{\n \"ephemeralId\": \"browser-abc123\",\n \"session\": \"my-session\",\n \"ttlSeconds\": 900\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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your-instance.example.com/api/client-tokens",
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([
'ephemeralId' => 'browser-abc123',
'session' => 'my-session',
'ttlSeconds' => 900
]),
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;
}{
"expiresAt": "2025-03-16T15:15:00Z",
"token": "titan_ct_eyJhbGciOi..."
}{
"docs": "https://docs.polymorfa.com/api/messages/send",
"error": "missing required field: chatId"
}{
"error": "missing or invalid API key"
}{
"docs": "<string>",
"error": "<string>"
}Authorizations
Scoped API key created via POST /api/account/keys.
Body
application/json
Mint request
EphemeralID is a developer-provided identifier for correlating tokens from the same browser, user, or tab.
Example:
"browser-abc123"
Session is the WhatsApp session name the token is scoped to.
Example:
"my-session"
TTLSeconds is the token lifetime in seconds (default 900, max from config).
Example:
900