Quick Start
Get started with Commet SDK in under 5 minutes
Quick Start
Get your billing system running in under 5 minutes.
Prerequisites: Node.js 18+ and a Commet account. Sign up here if needed.
Install the SDK
npm install @commet/node
pnpm add @commet/node
yarn add @commet/node
Link your project
Use the CLI to connect your project and sync types:
npx commet link
Select your organization and project. The CLI generates TypeScript types for your event types and seat types automatically.
Type Safety: The CLI creates typed wrappers for your billing events, preventing runtime errors.
Initialize the client
Create your Commet client with environment variables:
import { Commet } from '@commet/node'
const commet = new Commet({
apiKey: process.env.COMMET_API_KEY!
})
Security: Store your API key in .env
and never commit it. The CLI adds .commet/
to .gitignore
automatically.
Track usage events
Send usage data with type-safe methods:
// Track API calls (type-safe after CLI link)
await commet.usage.create({
eventType: 'api_call',
customerId: 'cus_xyz', // Or use externalId
properties: [
{ property: 'endpoint', value: '/users' },
{ property: 'method', value: 'GET' }
]
})
Manage seats
Add, remove, or set seat counts:
// Add seats
await commet.seats.add({
externalId: 'stripe_cus_abc', // Use your own IDs
seatType: 'admin',
count: 5
})
// Set exact count
await commet.seats.set({
customerId: 'cus_xyz',
seatType: 'admin',
count: 10
})
Need help? support@commet.co
How is this guide?