Skip to content
Get Started

Opt out a contact

client.contacts.optOut(ContactOptOutParams { number, opted_out } body, RequestOptionsoptions?): ContactOptOutResponse { number, opted_out, status }
POST/api/v2/contacts/opt-out

Opt a contact out (or back in) from receiving messages. When a recipient is opted out, outbound messages to that number will be blocked.

Pass opted_out: false to opt a contact back in.

ParametersExpand Collapse
body: ContactOptOutParams { number, opted_out }
number: string

Phone number in E.164 format

opted_out?: boolean

Set to false to opt the contact back in (defaults to true)

ReturnsExpand Collapse
ContactOptOutResponse { number, opted_out, status }
number?: string

The normalized phone number

opted_out?: boolean

The current opt-out status

status?: string

Opt out a contact

import SendblueAPI from 'sendblue';

const client = new SendblueAPI({
  apiKey: process.env['SENDBLUE_API_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SENDBLUE_API_API_SECRET'], // This is the default and can be omitted
});

const response = await client.contacts.optOut({ number: '+14155551234' });

console.log(response.number);
{
  "number": "+14155551234",
  "opted_out": true,
  "status": "OK"
}
Returns Examples
{
  "number": "+14155551234",
  "opted_out": true,
  "status": "OK"
}