# Platform SDK Quickstart

Use the type-safe Platform SDK to manage contacts, send batch emails, and interact with the Wraps API programmatically.

## What You'll Build

- A type-safe Platform SDK client connected to your organization
- Contact management with create and list operations
- Batch email sending to segments of contacts

Time: ~3 minutes

## Prerequisites

- Node.js 20 or later
- A Wraps account with an organization ([sign up here](https://app.wraps.dev/auth?mode=signup))
- An API key from your organization settings

## Step 1: Get Your API Key

1. Go to [app.wraps.dev](https://app.wraps.dev) and sign in
2. Navigate to **Settings** → **API Keys**
3. Click **Create API Key** and copy it (you won't see it again)

Store in an environment variable: `WRAPS_API_KEY=wraps_live_xxx...`

## Step 2: Install the SDK

```bash
npm install @wraps.dev/client
# or: pnpm add @wraps.dev/client | yarn add @wraps.dev/client | bun add @wraps.dev/client
```

## Step 3: Initialize the Client

```typescript
import { createPlatformClient } from '@wraps.dev/client';

const client = createPlatformClient({
  apiKey: process.env.WRAPS_API_KEY,
});
```

## Step 4: Create a Contact

```typescript
const { data, error } = await client.POST('/v1/contacts/', {
  body: {
    email: 'user@example.com',
    emailStatus: 'active',
    firstName: 'John',
    lastName: 'Doe',
  },
});

if (data) {
  console.log('Contact created:', data.id);
} else {
  console.error('Error:', error);
}
```

## Step 5: List Contacts

```typescript
const { data, error } = await client.GET('/v1/contacts/', {
  params: {
    query: { page: '1', pageSize: '10' },
  },
});

if (data) {
  console.log('Total contacts:', data.total);
  data.contacts.forEach(contact => {
    console.log(contact.email, contact.emailStatus);
  });
}
```

## Bonus: Send Batch Emails

```typescript
const { data, error } = await client.POST('/v1/batch/', {
  body: {
    templateId: 'your-template-id',
    segmentId: 'your-segment-id',
  },
});

if (data) {
  console.log('Batch created:', data.id, 'Status:', data.status);
}
```

## Next Steps

- [Platform SDK Reference](https://wraps.dev/docs/client-sdk-reference)
- [Email SDK](https://wraps.dev/docs/sdk-reference)
