> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowsbuilt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Start tracking churn signals in under 5 minutes.

## 1. Install the SDK

```bash theme={null}
npm install @vgpprasad91/churnkit-sdk
```

## 2. Create a client

```typescript theme={null}
import ChurnKit from '@vgpprasad91/churnkit-sdk'

const churn = new ChurnKit({ apiKey: process.env.CHURNKIT_API_KEY! })
```

## 3. Identify your users

Call `identify()` when a user signs up or logs in. This attaches traits that the scoring model uses.

```typescript theme={null}
await churn.identify('user_123', {
  plan: 'pro',
  mrr: 4900,          // monthly recurring revenue in cents
  email: 'alice@acme.com',
  signedUpAt: '2024-01-15T00:00:00Z',
})
```

## 4. Track product events

Track events that signal engagement (or disengagement):

```typescript theme={null}
// User is active — positive signal
await churn.event('user_123', 'feature_used', { feature: 'data_export' })
await churn.event('user_123', 'dashboard_viewed')

// Potential churn signals
await churn.event('user_123', 'support_ticket_opened', { severity: 'high' })
await churn.event('user_123', 'export_all_data')
```

## 5. Get the risk score

```typescript theme={null}
const risk = await churn.score('user_123')

console.log(risk.score)          // 0.73
console.log(risk.tier)           // 'high'
console.log(risk.signals)        // ['no_login_7d', 'support_spike']
console.log(risk.recommendation) // 'Reach out to this user immediately.'
```

## 6. Set up a webhook alert (optional)

Get notified automatically when a user's risk crosses a threshold:

```typescript theme={null}
await churn.watch('user_123', {
  threshold: 0.7,
  webhook: 'https://yourapp.com/hooks/churn-alert',
  cooldown: '24h',  // don't fire more than once every 24 hours
})
```

## What's next?

<CardGroup cols={2}>
  <Card title="Configuration" icon="sliders" href="/churnkit/configuration">
    Timeouts, retries, observability hooks, and test mode.
  </Card>

  <Card title="Event Batcher" icon="layer-group" href="/churnkit/events/batcher">
    High-throughput event ingestion with automatic batching.
  </Card>

  <Card title="At-Risk Users" icon="users" href="/churnkit/risk/at-risk">
    Query all users above a risk threshold for bulk campaigns.
  </Card>

  <Card title="Webhooks" icon="bell" href="/churnkit/webhooks/overview">
    Verify webhook signatures and handle payload events.
  </Card>
</CardGroup>
