create()
Creates a new API key for the given user or Organization.
Returns the created APIKey object.
function create(params: CreateAPIKeyParams): Promise<APIKey>const userId = 'user_123'
const apiKey = await clerkClient.apiKeys.create({
name: 'My API Key',
subject: userId,
})const userId = 'user_123'
const apiKey = await clerkClient.apiKeys.create({
name: 'Production API Key',
subject: userId,
description: 'API key for accessing my application',
scopes: ['read:users', 'write:users'],
secondsUntilExpiration: 86400, // expires in 24 hours
})Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint POST/api_keys. See the BAPI reference for more information.
Feedback
Last updated on