API Reference

Update contact

PATCH /contacts/:id — partially update a contact.

PATCH/contacts/:id

Partially update a contact, addressed by id or email. Only the fields you send are changed; omitted fields are left untouched. The contact’s email cannot be changed. An id is exact; when addressing by email, include a domain field in the body to say which of your sending domains the contact lives on.

Path parameters
idstringrequired

The contact’s id *or* its email — either value is accepted in this path segment.

Body
domainstringoptional

The sending domain the contact belongs to. Needed only when addressing by email; an id is exact.

first_namestringoptional

New first name. Send null (or an empty string) to clear it.

last_namestringoptional

New last name. Send null (or an empty string) to clear it.

unsubscribedbooleanoptional

New opt-out state. Set true to unsubscribe, false to re-subscribe.

propertiesobjectoptional

A map of custom property keys and values to merge into the contact (e.g. { "department": "Engineering", "score": 10 }). Incoming keys win; unmentioned keys are preserved. Each key must be a registered contact property and the value must match its declared type (string or number).

Request
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.contacts.update({
  id: '479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6',
  "unsubscribed": true
});
console.log({ data, error });
Response (200)
{
  "object": "contact",
  "id": "479e3145-dd0e-4f64-bf48-1d4b6d4cd8f6"
}

Audience-scoped variant

The nested route PATCH /audiences/:audience_id/contacts/:id still works and scopes the update to one audience (no domain field needed):

Request (audience-scoped)
import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.contacts.update({
  audienceId: 'AUDIENCE_ID',
  id: 'steve@example.com',
  "unsubscribed": true
});
console.log({ data, error });

An unknown contact (or audience) returns 404 not_found. See Errors.