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

# Opt Out Lead

> Opt a lead's email or phone number out of outreach, or remove that opt-out

This endpoint opts a lead's email or phone number out of outreach. Agents and team members cannot contact the opted-out email or phone number, and any pending messages to it are cancelled. The other address is not affected.

Opt-outs are applied at the workspace level. If multiple leads share the same email or phone number, the opt-out applies to all of them. Removing the opt-out restores outreach to that email or phone number across all associated leads.

When all addresses for a lead are opted out, the lead's status changes to `OPTED_OUT` and `didOptOut` is `true`.

To opt a lead out of both email and phone outreach, make two requests: one with `scope` set to `EMAIL` and one with `scope` set to `PHONE`.

## Authentication

Requires the `x-api-key` header with a valid workspace API key.

## Path Parameters

**leadId** `string` *required*

The unique identifier of the lead.

## Request Body

**optOut** `boolean` *required*

When true, opts the address out. When false, removes the opt-out.

**scope** `enum` *required*

`EMAIL` or `PHONE`. The address to change. `EMAIL` covers email. `PHONE`
covers texts, calls, and WhatsApp.

## Response

**success** `boolean`

Whether the request succeeded

```javascript Node.js theme={null}
const options = {
  method: "POST",
  headers: {
    "x-api-key": "<your-api-key>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    optOut: true,
    scope: "PHONE",
  }),
};

fetch(
  "https://api-v2.getomni.ai/api/v1/leads/b3f1c2d4-5e6a-7b8c-9d0e-1f2a3b4c5d6e/opt-out",
  options,
)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));
```

```python Python theme={null}
import requests

lead_id = "b3f1c2d4-5e6a-7b8c-9d0e-1f2a3b4c5d6e"
url = f"https://api-v2.getomni.ai/api/v1/leads/{lead_id}/opt-out"
headers = {
    "x-api-key": "<your-api-key>",
    "Content-Type": "application/json",
}
payload = {
    "optOut": True,
    "scope": "PHONE",
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

```bash cURL theme={null}
curl --request POST \
  --url 'https://api-v2.getomni.ai/api/v1/leads/b3f1c2d4-5e6a-7b8c-9d0e-1f2a3b4c5d6e/opt-out' \
  --header 'x-api-key: <your-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
    "optOut": true,
    "scope": "PHONE"
  }'
```

```json 200 theme={null}
{
  "success": true
}
```

```json 400 theme={null}
{
  "error": "scope must be EMAIL or PHONE",
  "success": false
}
```

```json 404 theme={null}
{
  "error": "Lead not found",
  "success": false
}
```


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