Add to Do-Not-Contact
curl --request POST \
--url https://app.tuco.ai/api/dnc \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "555-010-0778",
"reason": "whatsapp-opt-out"
}
'import requests
url = "https://app.tuco.ai/api/dnc"
payload = {
"phone": "555-010-0778",
"reason": "whatsapp-opt-out"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone: '555-010-0778', reason: 'whatsapp-opt-out'})
};
fetch('https://app.tuco.ai/api/dnc', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.tuco.ai/api/dnc",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '555-010-0778',
'reason' => 'whatsapp-opt-out'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.tuco.ai/api/dnc"
payload := strings.NewReader("{\n \"phone\": \"555-010-0778\",\n \"reason\": \"whatsapp-opt-out\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.tuco.ai/api/dnc")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"555-010-0778\",\n \"reason\": \"whatsapp-opt-out\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.tuco.ai/api/dnc")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"555-010-0778\",\n \"reason\": \"whatsapp-opt-out\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"id": "6ad60002d963dc1e85d12148"
}{
"error": "Either phone or email is required"
}{
"error": "Unauthorized"
}{
"error": "This contact is already on the DNC list"
}{
"error": "Rate limit exceeded"
}Do Not Contact
Add to Do-Not-Contact
Add a phone number or email to your workspace’s Do-Not-Contact list so Tuco never messages it. REST endpoint in the Tuco AI iMessage API — bearer-token auth.
POST
/
api
/
dnc
Add to Do-Not-Contact
curl --request POST \
--url https://app.tuco.ai/api/dnc \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"phone": "555-010-0778",
"reason": "whatsapp-opt-out"
}
'import requests
url = "https://app.tuco.ai/api/dnc"
payload = {
"phone": "555-010-0778",
"reason": "whatsapp-opt-out"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({phone: '555-010-0778', reason: 'whatsapp-opt-out'})
};
fetch('https://app.tuco.ai/api/dnc', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.tuco.ai/api/dnc",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'phone' => '555-010-0778',
'reason' => 'whatsapp-opt-out'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.tuco.ai/api/dnc"
payload := strings.NewReader("{\n \"phone\": \"555-010-0778\",\n \"reason\": \"whatsapp-opt-out\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.tuco.ai/api/dnc")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"phone\": \"555-010-0778\",\n \"reason\": \"whatsapp-opt-out\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.tuco.ai/api/dnc")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"phone\": \"555-010-0778\",\n \"reason\": \"whatsapp-opt-out\"\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"id": "6ad60002d963dc1e85d12148"
}{
"error": "Either phone or email is required"
}{
"error": "Unauthorized"
}{
"error": "This contact is already on the DNC list"
}{
"error": "Rate limit exceeded"
}Use this to push opt-outs from your other channels (WhatsApp, email, forms) into Tuco. Every message is checked against this list before it is sent. A successful add fires the
dnc.added webhook.Authentication
Authorization: Bearer tuco_xxxxxxxxxxxxx
Example
curl -X POST "https://app.tuco.ai/api/dnc" \
-H "Authorization: Bearer tuco_xxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "phone": "555-010-0778", "reason": "whatsapp-opt-out" }'
Success response (200)
{ "ok": true, "id": "6ad60002d963dc1e85d12148" }
Errors
| Status | Body | When |
|---|---|---|
400 | { "error": "Either phone or email is required" } | Neither field sent |
400 | { "error": "Body must be JSON: { phone?, email?, reason? }" } | Body is not JSON |
401 | { "error": "Unauthorized" } | Missing or invalid API key |
409 | { "error": "This contact is already on the DNC list" } | Already listed |
429 | { "error": "Rate limit exceeded" } | Rate limit exceeded |
Authorizations
Workspace API key: Authorization: Bearer tuco_xxxxxxxxxxxxx
Body
application/json