index/interfaces/CreateApiKeyOptions.md
Options for creating a new API key.
Example
const options: CreateApiKeyOptions = {
role: 'MODERATOR',
description: 'Chat moderation bot',
delegateAllTokens: false,
tokenNames: ['mytoken', 'othertoken'],
expiresAt: '2025-12-31T23:59:59Z'
};
Properties
| Property | Type | Description |
|---|---|---|
delegateAllTokens? | boolean | If true, key has access to ALL tokens owned by the user (current and future). If false, only tokens in tokenNames are accessible. Default false |
description? | string | User's description/label for this API key. Max 255 characters. |
expiresAt? | string | Optional expiration date in ISO 8601 format. If not provided, key never expires. Example "2025-12-31T23:59:59Z" |
role | ApiKeyRole | Role determining permissions for this API key. Required. |
tokenNames? | string[] | Specific tokens to delegate access to. Ignored if delegateAllTokens is true. Token names are case-insensitive. |
tokenPermissions? | Record<string, Permission[]> | Per-token permission overrides. Maps tokenName to Permission[]. Only applies to tokens in tokenNames. Tokens not in this map use the API key's role-based default permissions. Example { "mytoken": ["MANAGE_COMMUNITY"] } Since 5.8.0 |
delegate all tokens token names expires at api key role permissions manage community