Skip to main content
POST
/
keys
Create a new API key
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    name: 'Analytics Service Key',
    workspace_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    scopes: '["chat.completions","responses"]',
    limit: 1,
    limit_reset: 'daily',
    include_byok_in_limit: true,
    expires_at: '2023-11-07T05:31:56Z',
    disabled: false,
    soft_blocked: false
  })
};

fetch('https://api.phaseo.app/v1/keys', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "data": {
    "id": "11111111-1111-4111-8111-111111111111",
    "hash": "a3f5b7c9d8e1f23456789abcdeffedcba9876543210fedcba1234567890abcdef",
    "workspace_id": "22222222-2222-4222-8222-222222222222",
    "name": "Analytics Service Key",
    "label": "Analytics Service Key",
    "prefix": "aistats_v1_sk_abcd1234",
    "status": "active",
    "disabled": false,
    "soft_blocked": false,
    "scopes": "[\"chat.completions\",\"responses\"]",
    "created_by": "user_abc123",
    "created_at": "2026-04-28T12:00:00Z",
    "updated_at": "2026-04-28T12:15:00Z",
    "last_used_at": "2026-04-28T12:30:00Z",
    "expires_at": "2027-12-31T23:59:59Z",
    "key": "aistats_v1_sk_abcd1234_supersecretvalue"
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.ai-stats.phaseo.app/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint requires a management API key. Standard Gateway API keys are not accepted.
The plaintext API key is returned once at creation time. OpenRouter-style limit, limit_reset, and include_byok_in_limit fields are accepted; AI Stats currently treats include_byok_in_limit as compatibility-only and always excludes BYOK from this key limit field.

Authorizations

Authorization
string
header
required

Bearer token authentication

Body

application/json
name
string
required
Minimum string length: 1
Example:

"Analytics Service Key"

workspace_id
string<uuid>

Optional workspace override for internal callers.

scopes
Example:

"[\"chat.completions\",\"responses\"]"

limit
number | null

Optional spend limit in USD for this key.

Required range: x >= 0
limit_reset
enum<string>

Period used for the spend limit window.

Available options:
daily,
weekly,
monthly
include_byok_in_limit
boolean

Accepted for compatibility. Current AI Stats behavior always excludes BYOK from this limit field.

expires_at
string<date-time> | null
disabled
boolean
default:false
soft_blocked
boolean
default:false

Response

API key created

data
object
required
Last modified on April 29, 2026