Management SDK
The @optare/management SDK is for server-side administration. Use it to manage users, organizations, and licenses programmatically.
Installation
npm install @optare/managementInitialization
import { ManagementClient } from '@optare/management';
const client = new ManagementClient({
domain: 'https://id.optare.one',
apiKey: process.env.OPTARE_API_KEY!,
});Note: The Management SDK requires an API key with admin privileges. Never use in frontend code.
User Management
List Users
const users = await client.users.list({
organizationId: 'org_abc123',
page: 1,
limit: 20,
});Get User
const user = await client.users.get('user_abc123');Create User
const user = await client.users.create({
email: 'john@example.com',
name: 'John Doe',
organizationId: 'org_abc123',
role: 'member',
emailVerified: true,
});Update User
await client.users.update('user_abc123', {
name: 'John Smith',
avatarUrl: 'https://...',
});Delete User
await client.users.delete('user_abc123');Reset Password
await client.users.sendPasswordReset('user_abc123');Organization Management
List Organizations
const orgs = await client.organizations.list({
page: 1,
limit: 20,
});Get Organization
const org = await client.organizations.get('org_abc123');Create Organization
const org = await client.organizations.create({
name: 'Acme Corporation',
slug: 'acme',
});Update Organization
await client.organizations.update('org_abc123', {
name: 'Acme Corp',
settings: {
requireMfa: true,
allowedDomains: ['acme.com'],
},
});Delete Organization
await client.organizations.delete('org_abc123');Membership Management
Add Member
await client.memberships.add({
organizationId: 'org_abc123',
userId: 'user_xyz789',
role: 'admin',
});Update Member Role
await client.memberships.update({
organizationId: 'org_abc123',
userId: 'user_xyz789',
role: 'member',
});Remove Member
await client.memberships.remove({
organizationId: 'org_abc123',
userId: 'user_xyz789',
});Subscription Management
Create Subscription
const subscription = await client.subscriptions.create({
organizationId: 'org_abc123',
productId: 'prod_pro',
totalSeats: 10,
status: 'active',
});Update Subscription
await client.subscriptions.update('sub_abc123', {
totalSeats: 20,
status: 'active',
});Cancel Subscription
await client.subscriptions.cancel('sub_abc123');Webhooks
List Webhooks
const webhooks = await client.webhooks.list();Create Webhook
const webhook = await client.webhooks.create({
url: 'https://myapp.com/api/webhooks',
events: ['user.created', 'user.login', 'member.invited'],
});Delete Webhook
await client.webhooks.delete('webhook_abc123');Error Handling
import { ManagementError } from '@optare/management';
try {
await client.users.get('nonexistent');
} catch (error) {
if (error instanceof ManagementError) {
console.log('Code:', error.code); // 'NOT_FOUND'
console.log('Status:', error.status); // 404
console.log('Message:', error.message);
}
}Rate Limits
| Endpoint | Limit |
|---|---|
| Read operations | 100/min |
| Write operations | 30/min |
| Bulk operations | 10/min |
Next Steps
- JavaScript Core SDK - Client-side SDK
- Webhooks - React to events
- API Reference - REST API docs