Quick Start
Get started with Commet SDK in 5 minutes
Quick Start
Get your billing system running in 5 minutes.
Prerequisites: Node.js 18+ and a Commet account.
Install
npm install @commet/nodepnpm add @commet/nodeyarn add @commet/nodebun add @commet/nodeInitialize
import { Commet } from '@commet/node'
const commet = new Commet({
apiKey: process.env.COMMET_API_KEY!,
environment: 'sandbox', // or 'production'
})Subscribe to a Plan
Each customer can have one active subscription at a time.
// Subscribe customer to a plan
const subscription = await commet.subscriptions.create({
externalId: 'user_123', // Your user ID
planId: 'plan_pro',
billingInterval: 'monthly',
initialSeats: { editor: 5 }
})Track Usage
await commet.usage.track({
externalId: 'user_123',
eventType: 'api_call',
idempotencyKey: `evt_${Date.now()}`,
properties: { endpoint: '/users', method: 'GET' }
})Manage Seats
// Add seats
await commet.seats.add({
externalId: 'user_123',
seatType: 'editor',
count: 5
})
// Set exact count
await commet.seats.set({
externalId: 'user_123',
seatType: 'editor',
count: 10
})What's Next?
- Plans - List available plans
- Subscriptions - Manage subscriptions
- Usage Events - Track consumption
- Seat Management - Manage licenses
Need help? support@commet.co
How is this guide?