curl -X POST http://localhost:6573/auth/api_key \
-H "Content-Type: application/json" \
-H 'Authorization: Bearer <admin-jwt-or-access-token>' \
-d '{
"name": "reader-admin-token",
"description": "Used by the analytics dashboard to run read-only admin checks.",
"will_expire": true,
"expires_in_seconds": 86400,
"permission": "read,admin"
}'import requests
url = "http://localhost:6573/auth/api_key"
payload = {
"name": "<string>",
"permission": "read,admin",
"description": "<string>",
"will_expire": False,
"expires_in_seconds": 123
}
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: '<string>',
permission: 'read,admin',
description: '<string>',
will_expire: false,
expires_in_seconds: 123
})
};
fetch('http://localhost:6573/auth/api_key', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "6573",
CURLOPT_URL => "http://localhost:6573/auth/api_key",
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' => '<string>',
'permission' => 'read,admin',
'description' => '<string>',
'will_expire' => false,
'expires_in_seconds' => 123
]),
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 := "http://localhost:6573/auth/api_key"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"permission\": \"read,admin\",\n \"description\": \"<string>\",\n \"will_expire\": false,\n \"expires_in_seconds\": 123\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("http://localhost:6573/auth/api_key")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"permission\": \"read,admin\",\n \"description\": \"<string>\",\n \"will_expire\": false,\n \"expires_in_seconds\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:6573/auth/api_key")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"permission\": \"read,admin\",\n \"description\": \"<string>\",\n \"will_expire\": false,\n \"expires_in_seconds\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": 12,
"name": "reader-admin-token",
"description": "Used by the analytics dashboard to run read-only admin checks.",
"api_key": "vdai_<newly-generated-token>",
"created_at": "2026-04-02T08:30:00Z",
"expired_at": "2026-04-03T08:30:00Z",
"will_expire": true,
"permission": "read,admin"
}{
"status": "error",
"message": "API key management API requires auth_enabled=true"
}Create access token
Creates a new API key with the specified name, description, expiration, and permissions.
Prerequisite: Authentication must be enabled before calling this endpoint. Call PATCH /auth/enabled with {"enabled": true} using an admin JWT first. If auth_enabled is false, the server rejects this request with 403 Forbidden and the message "API key management API requires auth_enabled=true".
Permission model
Access token permissions use a bitmask model.
| Name | Value | Meaning |
|---|---|---|
read | 1 | Read access |
write | 2 | Write access |
admin | 4 | Admin access |
admin is an independent permission bit. It does not automatically grant read or write.
Common combinations:
| Bitmask | Permission string | Meaning |
|---|---|---|
| 1 | read | Read only |
| 2 | write | Write only |
| 4 | admin | Admin only |
| 5 | read,admin | Read and admin |
| 6 | write,admin | Write and admin |
| 7 | read,write,admin | Read, write, and admin |
The create-token API accepts the canonical comma-separated permission names, and the server stores them as the corresponding bitmask.
When using an admin JWT, the server uses the persisted JWT secret from server_params.btr. If ACTIAN_VECTORAI_JWT_SECRET is set at startup, that value overrides the persisted secret and is saved for subsequent restarts.
curl -X POST http://localhost:6573/auth/api_key \
-H "Content-Type: application/json" \
-H 'Authorization: Bearer <admin-jwt-or-access-token>' \
-d '{
"name": "reader-admin-token",
"description": "Used by the analytics dashboard to run read-only admin checks.",
"will_expire": true,
"expires_in_seconds": 86400,
"permission": "read,admin"
}'import requests
url = "http://localhost:6573/auth/api_key"
payload = {
"name": "<string>",
"permission": "read,admin",
"description": "<string>",
"will_expire": False,
"expires_in_seconds": 123
}
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: '<string>',
permission: 'read,admin',
description: '<string>',
will_expire: false,
expires_in_seconds: 123
})
};
fetch('http://localhost:6573/auth/api_key', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "6573",
CURLOPT_URL => "http://localhost:6573/auth/api_key",
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' => '<string>',
'permission' => 'read,admin',
'description' => '<string>',
'will_expire' => false,
'expires_in_seconds' => 123
]),
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 := "http://localhost:6573/auth/api_key"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"permission\": \"read,admin\",\n \"description\": \"<string>\",\n \"will_expire\": false,\n \"expires_in_seconds\": 123\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("http://localhost:6573/auth/api_key")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"permission\": \"read,admin\",\n \"description\": \"<string>\",\n \"will_expire\": false,\n \"expires_in_seconds\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:6573/auth/api_key")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"permission\": \"read,admin\",\n \"description\": \"<string>\",\n \"will_expire\": false,\n \"expires_in_seconds\": 123\n}"
response = http.request(request)
puts response.read_body{
"id": 12,
"name": "reader-admin-token",
"description": "Used by the analytics dashboard to run read-only admin checks.",
"api_key": "vdai_<newly-generated-token>",
"created_at": "2026-04-02T08:30:00Z",
"expired_at": "2026-04-03T08:30:00Z",
"will_expire": true,
"permission": "read,admin"
}{
"status": "error",
"message": "API key management API requires auth_enabled=true"
}Headers
Body
Response
Token created successfully.