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
| Field | Type | Description |
|---|---|---|
| namereq | string | |
| scopesreq | string · "*" | "read:personas" | "write:personas" | "read:chat" | "write:chat" | "read:marketplace" | "write:marketplace" | "read:billing" | "read:audit" | "read:webhooks" | "write:webhooks" | "read:config" | "write:config"[] | |
| environment | string · "live" | "test" | default: "live" |
| workspaceId | string | |
| expiresAt | string |
Responses
201Key issued.
Body
| Field | Type | Description |
|---|---|---|
| idreq | string | |
| prefixreq | string | |
| plaintextKeyreq | string | |
| scopesreq | string · "*" | "read:personas" | "write:personas" | "read:chat" | "write:chat" | "read:marketplace" | "write:marketplace" | "read:billing" | "read:audit" | "read:webhooks" | "write:webhooks" | "read:config" | "write:config"[] | |
| createdAtreq | string | |
| expiresAtreq | string |
400Validation error (invalid scopes, name too long, etc.).
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string | |
| error.details | object |
401Unauthenticated.
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string | |
| error.details | object |
403Forbidden — only org Owner may issue `*` wildcard scope keys.
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string | |
| error.details | object |
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=["*"],
)