Skip to main content

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​

PropertyTypeDescription
delegateAllTokens?booleanIf 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?stringUser's description/label for this API key. Max 255 characters.
expiresAt?stringOptional expiration date in ISO 8601 format. If not provided, key never expires. Example "2025-12-31T23:59:59Z"
roleApiKeyRoleRole 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