`lumail@2.1.0` · [`lumail.subscribers`](/docs/sdk/v2/subscribers)

```typescript
subscribers.create(params: CreateSubscriberParams): Promise<LumailResult<CreateSubscriberResponse>>
```

`email` required. Upserts by email.

`skipDoubleOptIn` defaults to `false`. Pass `true` from a trusted backend (checkout, server-side import) to create the contact as `SUBSCRIBED` even when the organization has double opt-in enabled. This does not record a native confirmation click (`confirmedAt` stays empty). Do not use it on public forms.

## Body Parameters

| Name | Type | Description |
| ------------------ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `email` | string | **Required.** Contact email. |
| `name` | string or null | Display name. |
| `phone` | string or null | Phone number. |
| `tags` | string[] | Tag names to attach. Created if missing. |
| `fields` | `Record` | Custom fields. `null` clears a field. |
| `replaceTags` | boolean | When `true`, replace the existing tag set with `tags`. |
| `resubscribe` | boolean | When `true`, re-subscribe an `UNSUBSCRIBED` contact. |
| `triggerWorkflows` | boolean | When `true`, run subscribe workflows. |
| `skipDoubleOptIn` | boolean | When `true`, create as `SUBSCRIBED` even if org double opt-in is on. Does not resubscribe `UNSUBSCRIBED` unless `resubscribe` is also `true`. |
| `ipAddress` | string | Optional signup IP. |
| `country` | string | Optional country code. |

## Response Fields

| Field | Type | Description |
| ----------- | ------------------ | ---------------------------- |
| `id` | string | Subscriber id. |
| `email` | string | Email. |
| `name` | string or null | Display name. |
| `phone` | string or null | Phone. |
| `status` | `SubscriberStatus` | Current status. |
| `tags` | `{ id, name }[]` | Attached tags. |
| `fields` | `Record` | Custom fields. |
| `createdAt` | string | Optional ISO 8601 timestamp. |
| `updatedAt` | string | Optional ISO 8601 timestamp. |
| `warnings` | string[] | Optional non-fatal notes. |

`data` is the subscriber. Failures return `{ data: null, error: { name, message, statusCode } }`.


## API Reference
**Method:** POST
**Endpoint:** /api/v2/subscribers

### SDK
```ts
import { Lumail } from "lumail";

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.subscribers.create({
  email: "user@example.com",
  name: "Ada",
  tags: ["newsletter"],
});
if (error) {
  throw error;
}
console.log(data.id);
```

### cURL
```bash
curl -X POST https://lumail.io/api/v2/subscribers \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","name":"Ada","tags":["newsletter"]}'
```

### JavaScript
```javascript
const response = await fetch("https://lumail.io/api/v2/subscribers", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    email: "user@example.com",
    name: "Ada",
    tags: ["newsletter"],
  }),
});
const data = await response.json();
```

### Success Response
```json
{
  "id": "sub_abc123",
  "email": "user@example.com",
  "name": "Ada",
  "phone": null,
  "status": "SUBSCRIBED",
  "tags": [{ "id": "tag_abc", "name": "newsletter" }],
  "fields": {}
}
```

### Error Response
```json
{
  "name": "validation_error",
  "message": "email is required",
  "statusCode": 422
}
```
