API reference
Opt a lead out - stop calling, add to Do Not Call
POST /leads/{id}/opt_out
The number goes on the organization’s Do Not Call list (source “API”), so no campaign of the organization dials it again; the lead leaves the queue with the DNC outcome and its open callbacks are closed. A call in progress is NOT cut: the reply says call_in_progress true, and nothing dials the number again. Idempotent: a second opt_out answers the same, with no second Do Not Call entry. Answers the updated lead plus call_in_progress.
Parameters
Section titled “Parameters”| Name | In | Type | Required | Notes |
|---|---|---|---|---|
id |
path | string (uuid) | yes | |
Idempotency-Key |
header | string | Any string you choose (1 to 255 visible characters), new for each new action. Send the same key again within 24 hours and you get the first answer back instead of a second lead or call. At most 255 characters. |
| Field | Type | Required | Notes |
|---|---|---|---|
reason |
string | Why (kept in the audit log and on closed callbacks) At most 500 characters. |
Example request
Section titled “Example request”curl -X POST 'https://v2-api.callview.ai/api/v1/external/leads/2b8e4c1d-9f3a-4b7e-8c21-6a5d4e3f2b10/opt_out' \ -u "$CALLVIEW_KEY_ID:$CALLVIEW_SECRET" \ -H 'Idempotency-Key: postLeadsIdOptOut-0001' \ -H 'Content-Type: application/json' \ -d '{ "reason": "Asked to stop on our web chat"}'import { randomUUID } from 'node:crypto';
const auth = Buffer.from(`${process.env.CALLVIEW_KEY_ID}:${process.env.CALLVIEW_SECRET}`).toString('base64');
const res = await fetch('https://v2-api.callview.ai/api/v1/external/leads/2b8e4c1d-9f3a-4b7e-8c21-6a5d4e3f2b10/opt_out', { method: 'POST', headers: { Authorization: `Basic ${auth}`, 'Content-Type': 'application/json', 'Idempotency-Key': randomUUID() }, body: JSON.stringify({ "reason": "Asked to stop on our web chat" }),});console.log(res.status, res.headers.get('request-id'));console.log(await res.text());import os, uuid
import requests
res = requests.request( "POST", "https://v2-api.callview.ai/api/v1/external/leads/2b8e4c1d-9f3a-4b7e-8c21-6a5d4e3f2b10/opt_out", auth=(os.environ["CALLVIEW_KEY_ID"], os.environ["CALLVIEW_SECRET"]), headers={"Idempotency-Key": str(uuid.uuid4())}, json={ "reason": "Asked to stop on our web chat", }, timeout=30,)print(res.status_code, res.headers.get("Request-Id"))print(res.text)<?php$ch = curl_init('https://v2-api.callview.ai/api/v1/external/leads/2b8e4c1d-9f3a-4b7e-8c21-6a5d4e3f2b10/opt_out');curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_USERPWD => getenv('CALLVIEW_KEY_ID') . ':' . getenv('CALLVIEW_SECRET'), CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'Idempotency-Key: ' . bin2hex(random_bytes(16))], CURLOPT_POSTFIELDS => <<<'JSON'{ "reason": "Asked to stop on our web chat"}JSON, CURLOPT_HEADER => false,]);$body = curl_exec($ch);echo curl_getinfo($ch, CURLINFO_HTTP_CODE), "\n", $body, "\n";Response
Section titled “Response”200 The lead, plus call_in_progress
{ "data": { "id": "2b8e4c1d-9f3a-4b7e-8c21-6a5d4e3f2b10", "external_id": "crm-10442", "campaign_id": "7c1f2b9e-4a3d-4e8f-9b21-5d6a7e8f9a01", "name": "LEAD_NAME", "phone": "+15555550142", "address": "1 Example Street, Springfield", "fields": { "roof_age": "12" }, "consent": { "source": "web_form", "agreed_at": "2026-10-06T16:58:02Z", "url": "https://example.com/quote" }, "lead_source": "Example CRM", "owner": null, "created": "2026-10-06T16:58:04.000Z", "updated": "2026-10-06T16:58:04.000Z", "status": "queued", "call_now": true, "place_in_line": 3, "estimated_wait_seconds": 90, "scheduled_for": null, "scheduled_reason": null, "held_reason": null, "callback_at": null, "late": false, "attempts": 0, "last_outcome": null, "last_outcome_label": null, "next_dial_at": null, "calls": [], "livemode": true, "call_in_progress": true }}Errors
Section titled “Errors”| Status | Codes |
|---|---|
| 400 | invalid_request |
| 401 | authentication_failed |
| 403 | permission_denied |
| 404 | not_found |
| 409 | idempotency_mismatch, idempotency_in_progress |
| 429 | rate_limited, too_many_concurrent_requests |
| 500 | internal_error |
| 503 | service_unavailable |
Part of Leads. Every example sends your key ID and secret as CALLVIEW_KEY_ID and CALLVIEW_SECRET (see Keys and authentication).