SDKs
Node.js SDK
Official Windback SDK for Node.js.
Node.js SDK
Official Node.js SDK for the Windback API.
Installation
npm install @windback/nodepnpm add @windback/nodeyarn add @windback/nodebun add @windback/nodeQuick Start
import { Windback } from "@windback/node";
const client = new Windback({
apiKey: process.env.PAYBACK_SECRET_KEY, // sk_... from dashboard settings
});
// Get stats
const stats = await client.stats.get();
console.log(`Recovery rate: ${stats.recovery_rate}%`);
// List churn events
const events = await client.churnEvents.list({
status: "new",
limit: 10,
});
// Generate recovery emails
const variants = await client.churnEvents.generateVariants("event-id");
// Send a recovery email
await client.churnEvents.sendVariant("event-id", "variant-id");
// Mark as recovered
await client.churnEvents.markRecovered("event-id");The SDK uses your secret API key (sk_...) for authentication, not JWT tokens. Get your API key from Settings in the dashboard.
API Reference
Windback(options)
| Option | Type | Description |
|---|---|---|
apiKey | string | Your secret API key (sk_...) |
baseUrl | string | API base URL (optional) |
client.stats.get()
Returns aggregate statistics.
client.churnEvents.list(params?)
| Param | Type | Description |
|---|---|---|
status | string | Filter by status |
limit | number | Items per page |
offset | number | Items to skip |
client.churnEvents.get(id)
Get a single churn event by ID.
client.churnEvents.generateVariants(id)
Generate 9 AI recovery email variants.
client.churnEvents.sendVariant(eventId, variantId)
Send a specific variant email.
client.churnEvents.markRecovered(id)
Mark an event as recovered.