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

```typescript
campaigns.list(params?: ListCampaignsParams): Promise<ListCampaignsResponse>
```

Newest first. `status: "all"` is dropped by the SDK and not sent.

## Query Parameters

| Name | Type | Description |
| -------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `limit` | number | Page size. |
| `after` | string | Cursor: older campaigns. |
| `before` | string | Cursor: newer campaigns. |
| `status` | `"all"` / `"DRAFT"` / `"ARCHIVED"` / `"SCHEDULED"` / `"SENDING"` / `"SENT"` / `"FAILED"` | Filter by status. `"all"` is omitted from the request. |
| `query` | string | Search by name or subject. |

## Response Fields

| Field | Type | Description |
| ---------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `object` | `"list"` | Discriminator. Always `list`. |
| `has_more` | boolean | `true` when another page exists. |
| `data` | `CampaignListItem[]` | Campaigns. Each row: `id`, `name`, `subject`, `status`, `recipientCount`, `emailsSentCount`, `emailsOpenedCount`, `emailsClickedCount`, `scheduledAt`, `sendAt`. |

`data` is `{ object, data, has_more }`. Failures return `{ data: null, error: { name, message, statusCode } }`.


## API Reference
**Method:** GET
**Endpoint:** /api/v2/campaigns

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

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.campaigns.list({
  limit: 20,
  status: "DRAFT",
});
if (error) {
  throw error;
}
for (const campaign of data.data) {
  console.log(campaign.id, campaign.subject);
}
```

### cURL
```bash
curl "https://lumail.io/api/v2/campaigns?limit=20&status=DRAFT" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
```

### JavaScript
```javascript
const response = await fetch(
  "https://lumail.io/api/v2/campaigns?limit=20&status=DRAFT",
  {
    headers: {
      Authorization: "Bearer YOUR_API_TOKEN",
    },
  },
);
const data = await response.json();
```

### Success Response
```json
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "id": "cmp_abc123",
      "name": "Launch",
      "subject": "Hello",
      "status": "DRAFT",
      "recipientCount": 0,
      "emailsSentCount": 0,
      "emailsOpenedCount": 0,
      "emailsClickedCount": 0,
      "scheduledAt": null,
      "sendAt": null
    }
  ]
}
```

### Error Response
```json
{
  "name": "missing_api_key",
  "message": "Missing API key",
  "statusCode": 401
}
```
