API
Iniciar sesión
Documentación › Contactos › Opt-out contatto
POST

Opt-out contatto

POSThttps://app.sendapp.ai/api/contacts/{id}/opt-out
Esclude il contatto dalle campagne e dagli invii marketing (stesso effetto di una risposta STOP). Idempotente: l'opt-out di un contatto già escluso restituisce changed = false.
Parámetros
apikey obligatorio
La tua API Key (anche header X-API-Key).
id obligatorio
ID del contacto (entero, en la ruta). Usa GET /api/contacts para encontrarlo.
reason opcional
Etichetta breve salvata come motivo dell'opt-out (default "api").
Solicitud
curl -X POST 'https://app.sendapp.ai/api/contacts/42/opt-out' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{ "reason": "crm_sync" }'
<?php
$ch = curl_init('https://app.sendapp.ai/api/contacts/42/opt-out');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY', 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode(['reason' => 'crm_sync']),
]);
echo curl_exec($ch);
curl_close($ch);
const res = await fetch('https://app.sendapp.ai/api/contacts/42/opt-out', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Content-Type': 'application/json' },
  body: JSON.stringify({ reason: 'crm_sync' })
});
console.log(await res.json());
Respuesta (200 OK)
{
  "status": "success",
  "changed": true,
  "contact": { "id": 42, "opted_out": true, "opted_out_reason": "crm_sync", "...": "..." }
}
Error
{
  "status": "error",
  "message": "Contact not found."
}