Create API Key
client.apiKeys.create(APIKeyCreateParams { expires_at, name, permissions, 4 more } body, RequestOptionsoptions?): APIKey { id, created_at, expires_at, 10 more }
POST/v1/api_keys
Create API Key
import NirvanaLabs from '@nirvana-labs/nirvana';
const client = new NirvanaLabs({
apiKey: process.env['NIRVANA_LABS_API_KEY'], // This is the default and can be omitted
});
const apiKey = await client.apiKeys.create({
expires_at: '2025-12-31T23:59:59Z',
name: 'My API Key',
permissions: [{ permission: 'edit', resource_type: 'vm' }],
project_ids: ['123e4567-e89b-12d3-a456-426614174000', '123e4567-e89b-12d3-a456-426614174001'],
});
console.log(apiKey.id);{
"id": "123e4567-e89b-12d3-a456-426614174000",
"created_at": "2025-01-01T00:00:00Z",
"expires_at": "2025-01-01T00:00:00Z",
"managed": false,
"name": "My API Key",
"permissions": [
{
"permission": "edit",
"resource_type": "vm"
}
],
"project_ids": [
"string"
],
"source_ip_rule": {
"allowed": [
"192.168.1.0/24",
"10.0.0.0/8"
],
"blocked": [
"192.168.1.100/32"
]
},
"status": "active",
"tags": [
"production",
"ethereum"
],
"updated_at": "2025-01-01T00:00:00Z",
"key": "6r17s0jy_b0_RbSofrrNvawFQcaN-VbGtUM7cKCW7_k",
"starts_at": "2025-01-01T00:00:00Z"
}Returns Examples
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"created_at": "2025-01-01T00:00:00Z",
"expires_at": "2025-01-01T00:00:00Z",
"managed": false,
"name": "My API Key",
"permissions": [
{
"permission": "edit",
"resource_type": "vm"
}
],
"project_ids": [
"string"
],
"source_ip_rule": {
"allowed": [
"192.168.1.0/24",
"10.0.0.0/8"
],
"blocked": [
"192.168.1.100/32"
]
},
"status": "active",
"tags": [
"production",
"ethereum"
],
"updated_at": "2025-01-01T00:00:00Z",
"key": "6r17s0jy_b0_RbSofrrNvawFQcaN-VbGtUM7cKCW7_k",
"starts_at": "2025-01-01T00:00:00Z"
}