FruxonDocs
UsersAPI Access

Generate a new API key

Creates a new API key with the specified permissions. The full key secret is only returned once in this response - store it securely. Personal access tokens always expire: `expirationDays` is required, from 1 to 365.

POST
/v1/tenants/{tenant}/tokens:generate
AuthorizationBearer <token>

JWT Authorization header using the Bearer scheme. Enter 'Bearer' [space] and then your token.

In: header

Path Parameters

tenant*string

The tenant identifier

The API key configuration

name?string

Gets or sets the name of the API key. This helps in identifying the purpose of the key.

expirationDays?integer|null

Number of days until the token expires. Required: from 1 to 365 (PersonalTokenLifetime.MaxDays). Personal access tokens cannot be minted without an expiry; omitting it, or asking for more than 365 days, is a 400.

Formatint32
scopes?array<string>

Explicit scope list. Each entry must be a known scope from TokenScopes.AllScopes; unknown values cause the request to 400 with the offending strings listed. Combined (unioned) with the expansion of GenerateTokenRequest.Preset when both are supplied — that lets callers say "the runner preset plus one extra scope I need" without having to enumerate the whole preset by hand.

preset?string|null

Named preset (sugar for a scope list). One of runner, builder, read-only, admin. Expanded at mint time; the preset name itself is never stored — only the expanded scope array — so a preset definition change tomorrow doesn't retroactively widen permissions on keys minted today.

deviceId?string|null

Stable per-install device id to stamp on the minted token, for CLI-auth keys (see Token.DeviceId). Lets a later re-login from the same machine rotate this credential in place. Null for everything else.

[key: string]?never

Response Body

curl -X POST "https://api.fruxon.com/v1/tenants/string/tokens:generate" \  -H "Content-Type: application/json" \  -d '{}'
{
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "string",
  "token": "string",
  "keyPrefix": "string",
  "scopes": [
    "string"
  ],
  "droppedScopes": [
    "string"
  ],
  "createdAt": 0,
  "expiresAt": 0,
  "createdBy": "string"
}
{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string",
  "property1": null,
  "property2": null
}
Empty
{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string",
  "property1": null,
  "property2": null
}