API Reference

Update campaign

PATCH /campaigns/:id — edit a draft campaign.

PATCH/campaigns/:id

Partially updates a campaign. Only a draft can be edited — once it is sending, scheduled, or sent, this returns a validation_error. Send only the fields you want to change.

Path parameters
idstringrequired

The ID of the campaign you want to update.

Body parameters
domainstringoptional

Re-point the campaign at another sending domain’s contacts (draft only). Must be one of your domains. Changing the domain automatically clears segment_id and topic_id unless new values are provided in the same request. Passing audience_id is no longer accepted.

fromstringoptional

Sender address on a verified domain.

subjectstringoptional

Subject line.

reply_tostring | string[]optional

Reply-To address. For multiple addresses, send an array of strings.

htmlstringoptional

HTML body.

textstringoptional

Plain-text body. If omitted, a plain-text version is generated from the HTML; set it to an empty string to opt out.

namestringoptional

The friendly name of the campaign. Only used for internal reference.

preview_textstring | nulloptional

Inbox preview text shown after the subject line (max 150 characters; supports merge tags). Pass null to clear.

segment_idstring | nulloptional

Re-target a segment. Pass null to remove the segment filter. The segment must belong to the same domain.

topic_idstring | nulloptional

Re-target a topic gate. Pass null to remove it.

import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.campaigns.update('8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90', { "subject": "Updated subject" });
console.log({ data, error });

Response

{
  "id": "8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90"
}
Errors: not_found if the campaign is not yours; validation_error if it is not a draft, domain does not reference one of your domains, or audience_id is passed (no longer accepted).