import { Limitly } from '@limitly/limitly-nextjs';const limitly = new Limitly({ apiKey: process.env.LIMITLY_API_KEY!});// Create a new API keyconst newApiKey = await limitly.apiKeys.create({ name: 'User API Key', user_id: 123, plan_id: 'plan_456', status: 'active'});console.log('New API key:', newApiKey.data?.api_key);
// Update an API keyconst updatedApiKey = await limitly.apiKeys.update('key_123', { name: 'Updated API Key Name', status: 'inactive'});console.log('Updated API key:', updatedApiKey.data);
Regenerate an existing API key to get a new key value:
Copy
Ask AI
// Regenerate an API keyconst regeneratedApiKey = await limitly.apiKeys.regenerate('key_123');console.log('New API key value:', regeneratedApiKey.data?.api_key);