API Reference

Update campaign

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

PATCH/campaigns/:id

Partially updates a campaign. Only a draft can be edited — any other status (scheduled, queued, paused, recurring, canceled, sent or failed) 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.

schedule_timezonestring | nulloptional

IANA timezone name (e.g. America/New_York) the campaign’s scheduled_at wall-clock time is interpreted in — also the zone daily batches roll over in. A scheduled_at that already carries a UTC offset (e.g. a trailing Z) is used as-is. Pass null to clear (batch rollover then falls back to your account timezone; an offset-less scheduled_at is read as UTC).

daily_batch_sizenumber | nulloptional

Send to at most this many recipients per day — an integer between 1 and 100000. Delivery continues the next day at the same local time until every contact is reached. Pass null to send to everyone at once.

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).