App öffnen
Moonborn — API · api-keys

Issue a new API key (plaintext returned once)

Creates a `pk_*` key. The `plaintextKey` field in the response is returned **once only**. Store it securely; it cannot be retrieved after this call.

POST/v1/api-keysscope · Bearer (API key or session JWT)
Request body
FieldTypeDescription
namereqstring
scopesreqstring · "*" | "read:personas" | "write:personas" | "read:chat" | "write:chat" | "read:marketplace" | "write:marketplace" | "read:billing" | "read:audit" | "read:webhooks" | "write:webhooks" | "read:config" | "write:config"[]
environmentstring · "live" | "test"default: "live"
workspaceIdstring
expiresAtstring

Responses

201Key issued.
Body
FieldTypeDescription
idreqstring
prefixreqstring
plaintextKeyreqstring
scopesreqstring · "*" | "read:personas" | "write:personas" | "read:chat" | "write:chat" | "read:marketplace" | "write:marketplace" | "read:billing" | "read:audit" | "read:webhooks" | "write:webhooks" | "read:config" | "write:config"[]
createdAtreqstring
expiresAtreqstring
400Validation error (invalid scopes, name too long, etc.).
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject
401Unauthenticated.
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject
403Forbidden — only org Owner may issue `*` wildcard scope keys.
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
error.detailsobject

Examples

cURL
curl -X POST https://api.moonborn.co/v1/api-keys \
  -H "Authorization: Bearer $MOONBORN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
      "name": "<string>",
      "scopes": [
        "*"
      ]
    }'
TypeScript
import Moonborn from '@moonborn/sdk';

const client = new Moonborn({ apiKey: process.env.MOONBORN_API_KEY });

const result = await client.api_keys.issueApiKey({
  name: "<string>",
  scopes: ["*"],
});
Python
import os
from moonborn import Moonborn

client = Moonborn(api_key=os.environ["MOONBORN_API_KEY"])

result = client.api_keys.issue_api_key(
    name="<string>",
    scopes=["*"],
)