Skip to content
Docs menu

Guides

Features

API

Integrations

Unsubscribe a contact

Unsubscribes a contact from the lists you name, or from all your marketing email when you name none.

POST /v1/contacts/{id}/unsubscribe

Example

curl -X POST https://api.wakio.net/v1/contacts/con_7Hq2LpXz4VnBw8tRjG6sYe/unsubscribe \
  -H "Authorization: Bearer $WAKIO_API_KEY"

Response 200:

{
  "id": "con_7Hq2LpXz4VnBw8tRjG6sYe",
  "external_id": "user_8812",
  "email": "[email protected]",
  "first_name": "Maya",
  "last_name": "Okafor",
  "source": "signup-form",
  "status": "unsubscribed",
  "fields": {
    "plan": "pro"
  },
  "lists": [
    {
      "id": "lst_5KfN9cDmA3xUvQ2yRhP8Zt",
      "status": "unsubscribed"
    }
  ],
  "suppression": {
    "reason": "unsubscribe",
    "scope": "marketing"
  }
}

Parameters

NameTypeRequiredDescription
idstringYesIn the path: the contact's Wakio id, such as con_…, or your own external_id. Escape any / in an external_id as %2F.
listsarray of stringsNoThe ids of the lists to leave, from API id on Lists, at most 50. Leave it out to unsubscribe from everything, which is what DELETE does. An empty array is refused.

Response

NameTypeRequiredDescription
idstringYesThe contact's id, such as con_….
external_idstringYesYour own id for this person, or null when none is set.
emailstringYesThe contact's address.
first_namestringYesFirst name, or null.
last_namestringYesLast name, or null.
sourcestringYesThe free-text source label, or null.
statusstringYesOne of active, unsubscribed, unreachable, or never_subscribed. Only active contacts receive campaigns and flows.
fieldsobjectYesThe contact's custom field values, keyed by field key, such as { "plan": "pro" }. {} when none is set.
listsarrayYesOne { "id", "status" } for each list the contact is on or has left. Oldest list first.
lists[].idstringYesThe list's id, such as lst_….
lists[].statusstringYessubscribed or unsubscribed.
suppressionobject or nullYesWhy Wakio will not send marketing email to the address, as { "reason", "scope" }, or null when nothing blocks it.

Errors

Every error this endpoint itself returns is {"error": "<code>"}, sometimes with one more field that explains it. The API overview lists the responses that do not follow that shape.

StatusCodeWhat happenedWhat to do
401invalid_api_keyThe Authorization header is missing, malformed, or names no active key.Send Authorization: Bearer <key> with an active key from API keys in the dashboard.
403insufficient_scopeThe key does not carry the scope this endpoint needs. scope names it.Issue a key with Can manage contacts ticked under API keys, and use it for this call.
404contact_not_foundNo contact in your account has this id. A con_… id is only ever looked up as a Wakio id, never as an external_id.Check the id, or use the external_id you stored on the contact.
422invalid_contactlists is not a non-empty array of list ids. Nothing was changed. detail says so.Send lists as an array of ids such as lst_…, or leave it out.
422unknown_listA list in lists is not one of your account's lists. Nothing was changed. list_ids echoes the ones that are unknown.Use the ids under API id on Lists.

Notes

Name the lists the person left in lists. Wakio leaves each one, records the withdrawal with the source api, and cancels any campaign or flow email still queued for a list they left. The request is all or nothing: if any id is not one of your lists, nothing changes.

Leaving a list also records that the person left that list's brand. They cannot be added to any list of that brand again by an import or an API call, and only they can come back, through a confirmation they click. Their other lists, and their status, stay as they were.

Send no lists to unsubscribe from everything. That is the same as Unsubscribe a contact from everything: the contact becomes unsubscribed and no marketing email reaches the address.

A 404 means no such contact exists, so there is nobody to stop mailing. A sync can treat it as done.

This call needs a key with the Can manage contacts scope.