Provision a key for any tenant
Provision a key for any tenant — superadmin only. Accepts the same name, scope, and expires_days fields as POST /v1/keys.
curl -X POST "https://api.autopil.ai/v1/admin/tenants/example_string/keys" \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{
"name": "John Doe",
"scope": "admin",
"expires_days": 42
}'
import requests
import json
url = "https://api.autopil.ai/v1/admin/tenants/example_string/keys"
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
data = {
"name": "John Doe",
"scope": "admin",
"expires_days": 42
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.autopil.ai/v1/admin/tenants/example_string/keys", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
},
body: JSON.stringify({
"name": "John Doe",
"scope": "admin",
"expires_days": 42
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"name": "John Doe",
"scope": "admin",
"expires_days": 42
}`)
req, err := http.NewRequest("POST", "https://api.autopil.ai/v1/admin/tenants/example_string/keys", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-API-Key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.autopil.ai/v1/admin/tenants/example_string/keys')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['X-API-Key'] = 'YOUR_API_KEY'
request.body = '{
"name": "John Doe",
"scope": "admin",
"expires_days": 42
}'
response = http.request(request)
puts response.body
{
"key_id": "example_string",
"name": "John Doe",
"key": "example_string",
"scope": "admin",
"expires_at": "2024-12-25T10:00:00Z",
"created_at": "2024-12-25T10:00:00Z"
}
{
"error": "Not Found",
"message": "The requested resource was not found",
"code": 404
}
{
"error": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
POST
/v1/admin/tenants/{tenant_id}/keysPOST
Base URLstring
Target server for requests. Edit to use your own host.
API Key (header: X-API-Key)
X-API-Keystring
RequiredAPI key with admin, read, or evaluate scope. Missing key → 401; invalid or revoked key → 403.
API key with
admin, read, or evaluate scope. Missing key → 401; invalid or revoked key → 403.
Content-Typestring
RequiredThe media type of the request body
Options: application/json
Request Preview
Response
Response will appear here after sending the request
Authentication
header
X-API-Keystring
RequiredAPI Key for authentication. API key with admin, read, or evaluate scope. Missing key → 401; invalid or revoked key → 403.
Path Parameters
Body
application/json
scopestring
Allowed values:
adminreadevaluateResponses
Was this page helpful?