Patches a draft campaign. Permission: `campaigns`.

## Path Parameters

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

## Body Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `subject` | string | Email subject line. |
| `name` | string | Campaign name. Max 100. |
| `preview` | string or null | Preview / preheader text. |
| `content` | unknown | TipTap JSON (object or string). |
| `contentType` | `"MAILY"` \| `"PLATE"` \| `"MARKDOWN"` | Content format. |
| `senderId` | string | Email sender id. |
| `replyTo` | string or null | Reply-To address. |

All fields optional. Omit a field to leave it unchanged.

## Response Fields

| Field | Type | Description |
| ----- | ---- | ----------- |
| `id` | string | Campaign id. |
| `name` | string | Campaign name. |
| `subject` | string | Subject line. |
| `preview` | string or null | Preview text. |
| `status` | string | Campaign status. |
| `contentType` | string | Content format. |
| `senderId` | string | Sender id. |
| `replyTo` | string or null | Reply-To address. |
| `updatedFields` | string[] | Fields that changed. |
| `warnings` | string[] | Present when a field was ignored or remapped. |

## Errors

| Status | `name` | When |
| ------ | ------ | ---- |
| 401 | `missing_api_key` | Missing or invalid bearer token |
| 403 | `missing_permission` | Token lacks the `campaigns` permission |
| 404 | `not_found` | Unknown campaign id |
| 422 | `validation_error` | Invalid payload or campaign is not a draft |

## Related

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


## 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
}
```

### Error Response
```json
{
  "name": "not_found",
  "message": "Campaign not found",
  "statusCode": 404
}
```
