Skip to content
Get Started

Opt out a contact

contacts.opt_out(ContactOptOutParams**kwargs) -> ContactOptOutResponse
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
number: str

Phone number in E.164 format

opted_out: Optional[bool]

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

ReturnsExpand Collapse
class ContactOptOutResponse:
number: Optional[str]

The normalized phone number

opted_out: Optional[bool]

The current opt-out status

status: Optional[str]

Opt out a contact

import os
from sendblue_api import SendblueAPI

client = SendblueAPI(
    api_key=os.environ.get("SENDBLUE_API_API_KEY"),  # This is the default and can be omitted
    api_secret=os.environ.get("SENDBLUE_API_API_SECRET"),  # This is the default and can be omitted
)
response = client.contacts.opt_out(
    number="+14155551234",
)
print(response.number)
{
  "number": "+14155551234",
  "opted_out": true,
  "status": "OK"
}
Returns Examples
{
  "number": "+14155551234",
  "opted_out": true,
  "status": "OK"
}