# Quickstart

Get from zero to a shareable video page in under 5 minutes.

## 1. Install

```bash
npm install @capturesweet/sdk
```

## 2. Set Your API Key

```bash
export CAPTURE_SWEET_API_KEY="your-bearer-token"
```

## 3. Create a Capture

```typescript
import CaptureSweet from '@capturesweet/sdk';

const cs = new CaptureSweet(process.env.CAPTURE_SWEET_API_KEY!);

const { id, slug, upload_url } = await cs.captures.create({
  title: "Product Demo",
  privacy: "link_only",
});
```

## 4. Upload Your Video

```typescript
const videoBuffer = await fs.promises.readFile("./demo.mp4");

await fetch(upload_url, {
  method: "PUT",
  body: videoBuffer,
  headers: { "Content-Type": "video/mp4" },
});
```

## 5. Mark Ready and Share

```typescript
const capture = await cs.captures.update(id, {
  status: "ready",
  published: true,
});

console.log(`Share: https://capturesweet.com/v/${slug}`);
```

## 6. Add a CTA Module (Optional)

```typescript
await cs.captures.update(id, {
  page_config: {
    modules: [
      {
        type: "cta",
        enabled: true,
        text: "Book a Demo",
        url: "https://cal.com/you/demo",
        style: "gradient",
        position: "floating",
        show_at_percentage: 50,
      },
    ],
  },
});
```

## 7. Track Views

```typescript
const { summary } = await cs.analytics.get(id, { days: 7 });
console.log(`${summary.total_views} views, ${summary.avg_watch_percentage}% avg watch`);
```

## Error Handling

```typescript
import CaptureSweet, { CaptureSweetError } from '@capturesweet/sdk';

try {
  await cs.captures.get("bad-id");
} catch (err) {
  if (err instanceof CaptureSweetError) {
    console.error(`[${err.code}] ${err.message}`);
  }
}
```

## Next Steps

- [API Reference](api-reference.md) - Full method documentation
- [Core Concepts](core-concepts.md) - Privacy, modules, personalization
- [Agent Integration](agent-integration.md) - Build AI-powered workflows
