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

```typescript
campaigns.update(campaignId: string, params: UpdateCampaignParams): Promise<LumailResult<UpdateCampaignResponse>>
```

Patch a draft. Locked on `SCHEDULED`, `SENDING`, `SENT`, and workflow campaigns.

## Path Parameters

| Name | Type | Description |
| ------------ | ------ | -------------------------- |
| `campaignId` | string | **Required.** Campaign id. |

## Body Parameters

| Name | Type | Description |
| ------------- | ------------------------------------ | ------------------------- |
| `subject` | string | Subject line. |
| `name` | string | Internal name. |
| `preview` | string or null | Preview / preheader text. |
| `content` | unknown | Campaign body. |
| `contentType` | `"MAILY"` / `"PLATE"` / `"MARKDOWN"` | Editor format. |
| `senderId` | string | Sending identity id. |
| `replyTo` | string or null | Reply-To address. |

## Response Fields

All body fields are optional (`Partial<CreateCampaignParams>`).

| Field | Type | Description |
| --------------- | ---------------- | ------------------------- |
| `id` | string | Campaign id. |
| `name` | string | Internal name. |
| `subject` | string | Subject line. |
| `preview` | string or null | Preview text. |
| `status` | `CampaignStatus` | Current status. |
| `contentType` | `ContentType` | Editor format. |
| `senderId` | string | Sending identity id. |
| `replyTo` | string or null | Reply-To address. |
| `updatedFields` | string[] | Fields that changed. |
| `warnings` | string[] | Optional non-fatal notes. |

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


## API Reference
**Method:** PATCH
**Endpoint:** /api/v2/campaigns/:campaignId

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

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.campaigns.update("cmp_abc123", {
  subject: "Updated subject",
});
if (error) {
  throw error;
}
console.log(data.subject);
```

### cURL
```bash
curl -X PATCH https://lumail.io/api/v2/campaigns/cmp_abc123 \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"subject":"Updated subject"}'
```

### JavaScript
```javascript
const response = await fetch("https://lumail.io/api/v2/campaigns/cmp_abc123", {
  method: "PATCH",
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ subject: "Updated subject" }),
});
const data = await response.json();
```

### Success Response
```json
{
  "id": "cmp_abc123",
  "name": "Launch",
  "subject": "Updated subject",
  "preview": null,
  "status": "DRAFT",
  "contentType": "MAILY",
  "senderId": "snd_abc123",
  "replyTo": null,
  "updatedFields": ["subject"]
}
```

### Error Response
```json
{
  "name": "validation_error",
  "message": "Campaign cannot be patched in this status",
  "statusCode": 422
}
```
