Skip to main content

Keys

API key management with granular permissions. Manage authentication credentials with fine-grained access controls, allowing you to issue keys with specific scopes and resource restrictions.

Methods​

Method (TypeScript)Method (Python)DescriptionHTTP
create(options)create(options)Create new API keyPOST /keys
list(options?)list(options=None)List API keysGET /keys
revoke(keyId)revoke(key_id)Revoke API keyPOST /keys/{id}/revoke

Example​

import { OptropicClient } from 'optropic';

const client = new OptropicClient({ apiKey: 'optr_live_...' });

// Create an API key with scoped permissions
const key = await client.keys.create({
name: 'CI/CD Pipeline',
scopes: ['assets:read', 'assets:create', 'documents:read'],
expiresIn: '90d'
});

console.log(`API Key: ${key.secret}`);
console.log(`Keep this safe - it cannot be retrieved again!`);