Zum Hauptinhalt springen

Übersicht

Dieser Endpunkt erstellt einen neuen API-Key vom Typ type=user in der Organisation, die mit dem aktuellen Management-Token verknüpft ist.

Request-Body

FeldTypStandard / GrenzenBeschreibung
namestringerforderlich, Standard Default Key, Länge 1-50Anzeigename; führende und nachgestellte Leerzeichen werden serverseitig entfernt
limitAmountnumber | nullmin. 0, Eingabe max. 1000000null oder weggelassen = unbegrenzt, 0 = Nullkontingent. Positive Werte werden auf ein gespeichertes Limit normalisiert, das 100000 USD Gegenwert nicht überschreiten kann.
limitCurrencyenumStandardwert USDNur USD. Das Senden von CNY gibt 400 currency_retired zurück.
modelsstring[]Standard []Optionale Allowlist für logische Modelle
expiresAtstring | nullRFC3339-Datetimenull bedeutet ohne Ablaufzeit

Hinweise

  • Der vollständige API-Key-Wert wird nur einmal in der Antwort angezeigt.
  • models: [] bedeutet, dass keine zusätzliche Modellbeschränkung über die Organisationsrichtlinie hinaus gilt.
  • limitAmount: 0 erstellt einen gültigen Key, der zunächst kein Kontingent verbrauchen kann.

Beispiel

curl -X POST "https://api.tokenlab.sh/v1/management/api-keys" \
  -H "Authorization: Bearer mt-your-management-token" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Backend Worker",
    "limitAmount": 500,
    "models": ["veo3.1", "kling-3.0-video"],
    "expiresAt": "2026-12-31T23:59:59Z"
  }'

Anfrage / Antwort

Verwenden Sie das interaktive OpenAPI-Panel oben für das genaue Schema und die Response-Felder.

Response example

{
  "id": "key_abc123def456",
  "name": "Backend Worker",
  "key": "sk-live-redacted",
  "key_prefix": "sk-live...",
  "status": "active",
  "limit_amount": 500,
  "limit_amount_decimal": "500",
  "used_amount": 0,
  "used_amount_decimal": "0",
  "models": [
    "veo3.1",
    "kling-3.0-video"
  ],
  "expires_at": "2026-12-31T23:59:59.000Z",
  "last_used_at": null,
  "created_at": "2026-07-08T03:00:00.000Z"
}

Important fields

key
string
Full secret API key value. It is returned only once on creation.
id
string
API key identifier used in follow-up Management API calls.
name
string
Display name for the API key.
key_prefix
string
Non-secret key prefix for display and support.
status
string
One of active, inactive, or revoked.
limit_amount
number | null
Spending cap in USD as a JSON number for display. null means unlimited.
limit_amount_decimal
string | null
Exact spending cap in USD as a decimal string. null means unlimited.
used_amount
number
Accumulated usage in USD as a JSON number for display.
used_amount_decimal
string
Exact accumulated usage in USD as a decimal string.
models
string[]
Per-key model allowlist. Empty array means no additional key-level model restriction.
expires_at
string | null
ISO timestamp when the key expires, or null for no expiry.
last_used_at
string | null
ISO timestamp for the most recent use, or null when unused.
created_at
string
ISO creation timestamp.