Mint Phantom Token
Mint a short-lived capability token for an agent. The plaintext is returned exactly once.
curl --request POST \
--url https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "ci-runner",
"kind": "agent",
"expires_in_seconds": 86400
}
'import requests
url = "https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens"
payload = {
"name": "ci-runner",
"kind": "agent",
"expires_in_seconds": 86400
}
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({name: 'ci-runner', kind: 'agent', expires_in_seconds: 86400})
};
fetch('https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens', 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.knoxcall.com/v1/ai-gateway/agents/{agentId}/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([
'name' => 'ci-runner',
'kind' => 'agent',
'expires_in_seconds' => 86400
]),
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.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens"
payload := strings.NewReader("{\n \"name\": \"ci-runner\",\n \"kind\": \"agent\",\n \"expires_in_seconds\": 86400\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.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"ci-runner\",\n \"kind\": \"agent\",\n \"expires_in_seconds\": 86400\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens")
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 \"name\": \"ci-runner\",\n \"kind\": \"agent\",\n \"expires_in_seconds\": 86400\n}"
response = http.request(request)
puts response.read_bodykp_-prefixed since 2026-09-01 (kp_<env>_<kind>_…) — see the
changelog;
a token minted before that date no longer parses.
Two behaviours worth knowing:
- Omitting
expires_in_secondsgives 30 days, not “never”. Any requested TTL is clamped to between 60 seconds and 90 days. Before 2026-08-30 an omitted expiry meant the token never expired. - The capability scope is empty, deliberately. This endpoint offers no parameter to set one, and an earlier revision guessed a provider restriction from the model name — which mislabelled every Gemini, Mistral and Cohere agent and would have refused the token’s own traffic. An empty scope means “no token-level restriction”, which is the truth. See Scoping for what a scope enforces when one is present, and how to get one today.
dpop_required: true requires dpop_jkt in the same request — a DPoP-bound
token with no key thumbprint is unusable, so it is refused with
400 validation rather than minted.
POST /admin/ai-gateway/{gatewayId}/agents/{agentId}/keys, session-authenticated with an X-Tenant-ID header and an
owner/admin role. That is what the dashboard itself calls. Prefer the /v1
operation above for anything you write: it is the surface the five SDKs, the
Postman collection and this spec cover.Authorizations
OAuth 2.1 authentication — recommended for new integrations. Access tokens
(kc_ prefix) are minted at the root-host token endpoint
https://api.knoxcall.com/oauth/token and passed as Authorization: Bearer <access_token>.
Public clients must use PKCE with the authorization_code grant; confidential
clients may use client_credentials. The first-party SDKs and the
knoxcall login CLI handle token minting, caching, refresh, and DPoP for you.
Path Parameters
The AI agent UUID.
Body
A human-readable label for the token.
agent, read, tool, oneshot Bind the token to a DPoP key. Requires dpop_jkt.
base64url SHA-256 thumbprint of your DPoP public key. Required when dpop_required is true.
Token lifetime, clamped to [60s, 90d]. Omit for the 30 days default; a non-expiring token cannot be minted.
60 <= x <= 7776000Was this page helpful?
curl --request POST \
--url https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "ci-runner",
"kind": "agent",
"expires_in_seconds": 86400
}
'import requests
url = "https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens"
payload = {
"name": "ci-runner",
"kind": "agent",
"expires_in_seconds": 86400
}
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({name: 'ci-runner', kind: 'agent', expires_in_seconds: 86400})
};
fetch('https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens', 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.knoxcall.com/v1/ai-gateway/agents/{agentId}/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([
'name' => 'ci-runner',
'kind' => 'agent',
'expires_in_seconds' => 86400
]),
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.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens"
payload := strings.NewReader("{\n \"name\": \"ci-runner\",\n \"kind\": \"agent\",\n \"expires_in_seconds\": 86400\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.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"ci-runner\",\n \"kind\": \"agent\",\n \"expires_in_seconds\": 86400\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.knoxcall.com/v1/ai-gateway/agents/{agentId}/tokens")
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 \"name\": \"ci-runner\",\n \"kind\": \"agent\",\n \"expires_in_seconds\": 86400\n}"
response = http.request(request)
puts response.read_body