Lists campaigns newest first. Permission: `campaigns`.

## Query Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `limit` | integer | Page size. |
| `after` | string | Campaign id cursor. Next page after this id. |
| `status` | string | Filter: `DRAFT`, `ARCHIVED`, `SCHEDULED`, `SENDING`, `SENT`, `FAILED`, or `all`. |
| `query` | string | Search name or subject. |

`after` is a campaign id from the previous page. `before` is rejected.

## Response Fields

| Field | Type | Description |
| ----- | ---- | ----------- |
| `object` | `"list"` | Discriminator. Always `list`. |
| `has_more` | boolean | `true` when another page exists. |
| `data` | array | Campaign list rows. |

Each row: `id`, `name`, `subject`, `status`, `recipientCount`, `emailsSentCount`, `emailsOpenedCount`, `emailsClickedCount`, `scheduledAt`, `sendAt`.

## Errors

| Status | `name` | When |
| ------ | ------ | ---- |
| 401 | `missing_api_key` | Missing or invalid bearer token |
| 403 | `missing_permission` | Token lacks the `campaigns` permission |
| 422 | `validation_error` | `before` passed, or invalid query |

## Related

- [Create Campaign](/docs/api-reference/v2/campaigns-create)
- [Get Campaign](/docs/api-reference/v2/campaigns-get)
- [SDK: lumail.campaigns.list](/docs/sdk/v2/campaigns-list)


## 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);
}

if (data.has_more) {
  const next = await lumail.campaigns.list({
    limit: 20,
    after: data.data.at(-1)?.id,
  });
  console.log(next.data?.data.length);
}
```

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

curl "https://lumail.io/api/v2/campaigns?limit=20&after=cmp_abc123" \
  -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 page = 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": "validation_error",
  "message": "before is not supported for campaigns; use after",
  "statusCode": 422
}
```
