Update campaign
PATCH /campaigns/:id — edit a draft campaign.
/campaigns/:idPartially 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.
idstringrequiredThe ID of the campaign you want to update.
domainstringoptionalRe-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.
fromstringoptionalSender address on a verified domain.
subjectstringoptionalSubject line.
reply_tostring | string[]optionalReply-To address. For multiple addresses, send an array of strings.
htmlstringoptionalHTML body.
textstringoptionalPlain-text body. If omitted, a plain-text version is generated from the HTML; set it to an empty string to opt out.
namestringoptionalThe friendly name of the campaign. Only used for internal reference.
preview_textstring | nulloptionalInbox preview text shown after the subject line (max 150 characters; supports merge tags). Pass null to clear.
segment_idstring | nulloptionalRe-target a segment. Pass null to remove the segment filter. The segment must belong to the same domain.
topic_idstring | nulloptionalRe-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"
}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).