Quick Start
Drew Billing provides a complete billing infrastructure for your applications. Choose between our SDK for programmatic access or the CLI for command-line workflows.
SDK
Integrate billing directly into your application code.
npm install @drewsepsi/billing-sdkCLI
Manage billing from the command line.
npx @drewsepsi/billing-cli initInstallation
SDK Installation
# npm
npm install @drewsepsi/billing-sdk
# yarn
yarn add @drewsepsi/billing-sdk
# pnpm
pnpm add @drewsepsi/billing-sdk
# bun
bun add @drewsepsi/billing-sdkCLI Installation
# Run without installing
npx @drewsepsi/billing-cli init
# Or install globally
npm install -g @drewsepsi/billing-cli
drew-billing initSDK Usage
The SDK provides methods to verify licenses, track usage, and check entitlements.
Initialize the SDK
import { DrewBillingSDK } from '@drewsepsi/billing-sdk';
const sdk = new DrewBillingSDK({
licenseKey: process.env.DREW_BILLING_LICENSE_KEY,
baseUrl: 'https://monetize-two.vercel.app',
});Verify License
// Verify your license key
const result = await sdk.verifyLicense({
machineId: 'unique-machine-id', // Optional: track unique installations
});
if (result.valid) {
console.log('License tier:', result.license.tier);
console.log('Features:', result.license.features);
} else {
console.error('License invalid:', result.error);
}SDK API Reference
verifyLicense(options)
Verifies a license key and returns license details.
| Parameter | Type | Required |
|---|---|---|
| machineId | string | No |
trackUsage(eventType, metadata)
Track API usage. Automatically enforces tier limits.
| Parameter | Type | Required |
|---|---|---|
| eventType | string | Yes |
| metadata | object | No |
CLI Commands
# Initialize Drew Billing in your project
drew-billing init
# Check your license status
drew-billing status
# Validate a license key
drew-billing validate --key DREW-XXXX-XXXX-XXXX
# Get help
drew-billing --helpEnvironment Variables
The CLI reads configuration from environment variables:
# Required
export DREW_BILLING_LICENSE_KEY="DREW-XXXX-XXXX-XXXX"
# Optional
export DREW_BILLING_API_URL="https://monetize-two.vercel.app"License Verification API
Direct HTTP API for license verification (used by SDK/CLI internally).
/api/license/verifyRequest Body
{
"licenseKey": "DREW-XXXX-XXXX-XXXX",
"machineId": "optional-machine-id",
"eventType": "verify"
}Response
{
"valid": true,
"license": {
"id": "uuid",
"tier": "pro",
"status": "active",
"features": ["usage_based_billing", "advanced_analytics"],
"usageLimits": { "apiCalls": 10000 }
}
}Usage Tracking API
/api/license/trackTracks usage and enforces tier limits. Returns 429 when limit exceeded.
Request Body
{
"licenseKey": "DREW-XXXX-XXXX-XXXX",
"eventType": "api_call",
"machineId": "optional-machine-id"
}Response Headers
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9999
X-RateLimit-Reset: 2026-05-01T00:00:00.000Z/api/license/track?licenseKey=xxxCheck current usage without incrementing the counter.
License Key Management
Manage your license keys through the dashboard at /dashboard/licenses
Dashboard Features
- ✓View all your license keys
- ✓Copy keys to clipboard (masked by default)
- ✓Track usage statistics with visual progress bars
- ✓Regenerate keys (invalidates old key)
- ✓Receive email notifications for new/regenerated keys
Regenerating Keys
Warning: Regenerating a key immediately invalidates the old key. A new key will be emailed to you. Make sure to update your applications with the new key.
License Key Format
Drew Billing license keys follow a consistent format:
DREW-XXXX-XXXX-XXXXKey Components
- Prefix:
DREW-- Identifies the key type - Segments: Three 4-character hexadecimal segments
- Format: Uppercase letters and numbers
- Total Length: 19 characters
Example Key
DREW-A1B2-C3D4-E5F6Security
- ✓Cryptographically random generation
- ✓Unique per license
- ✓Immediately invalidated on regeneration