Update contact
PATCH /contacts/:id — partially update a contact.
/contacts/:idPartially 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.
idstringrequiredThe contact’s id *or* its email — either value is accepted in this path segment.
domainstringoptionalThe sending domain the contact belongs to. Needed only when addressing by email; an id is exact.
first_namestringoptionalNew first name. Send null (or an empty string) to clear it.
last_namestringoptionalNew last name. Send null (or an empty string) to clear it.
unsubscribedbooleanoptionalNew opt-out state. Set true to unsubscribe, false to re-subscribe.
propertiesobjectoptionalA 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).
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 });{
"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):
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.