> ## Documentation Index
> Fetch the complete documentation index at: https://docs.minimo.it/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle Unsubscribe Requests

> When a customer asks your bot to stop messaging them, record it in Minimo so marketing stops everywhere

When your bot answers the customer, **your bot** is the one that hears "stop sending me offers". Minimo
doesn't read that conversation for you, so you have to tell it. One API call records the opt-out, and
from then on Minimo stops sending marketing to that customer on every channel your company's opt-out
scope covers.

> [!NOTE]
>
> Opting out is a legal obligation (GDPR, WhatsApp Business Policy). If your bot detects the intent, record it before
> you reply.

## The flow

**1. Detect the intent**

Your bot classifies the inbound message (`message.text` in the [webhook
envelope](https://docs.minimo.it/api-reference/whatsapp-transport/webhooks.md)) as a request to stop marketing: "unsubscribe", "stop", "non
voglio più ricevere messaggi", "cancellami".

**2. Record the opt-out in Minimo**

Call [`POST /public/v1/contacts/opt-out`](https://docs.minimo.it/api-reference/core-data/contacts/opt-out) with the sender's
`contact.phone`. The same WhatsApp-only API key you use to send works.

**3. Confirm to the customer**

Reply with what actually changed. The response's `revokedChannels` tells you whether it was only WhatsApp or every
marketing channel.

## Example

```javascript theme={null}
// Inside your webhook handler, after verifying X-Minimo-Signature
const { contact, message } = envelope;

if (isUnsubscribeRequest(message.text)) {
  const res = await fetch('https://api.minimo.it/public/v1/contacts/opt-out', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.MINIMO_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      phone: contact.phone,
      reason: `Customer wrote: "${message.text}"`,
    }),
  });
  const { data } = await res.json();

  const everything = data.revokedChannels.length > 1;
  await sendWhatsappText(
    contact.phone,
    everything
      ? "Done, you won't receive any more promotional messages from us (WhatsApp, email or SMS)."
      : "Done, you won't receive any more promotional messages from us on WhatsApp.",
  );
}
```

`sendWhatsappText` is your call to [Send](https://docs.minimo.it/api-reference/whatsapp-transport/send.md). The reply is a session
message inside the 24-hour window the customer just opened, so it is not marketing.

## What changes

* Marketing campaigns and marketing WhatsApp templates **skip** this contact.
* Transactional email and utility templates keep working: order updates, reminders, account emails.
* The opt-out appears on the contact's timeline in Minimo, with source `api` and your `reason`.
* Calling it again for the same contact is harmless (idempotent).

## Doing it without code

* **Minimo's AI assistant** does this natively when it answers the conversation itself (WhatsApp or email).
  Use this API only when your own bot answers.
* **AI agents over MCP** can call the `minimo_contact_opt-out` tool. See [Connect your
  agent](https://docs.minimo.it/guides/connect-your-agent.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.