API
Se connecter
Documentation › Contacts › 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.
Paramètres
apikey obligatoire
La tua API Key (anche header X-API-Key).
id obligatoire
ID du contact (entier, dans le chemin). Utilisez GET /api/contacts pour le trouver.
reason facultatif
Etichetta breve salvata come motivo dell'opt-out (default "api").
Requête
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());
Réponse (200 OK)
{
  "status": "success",
  "changed": true,
  "contact": { "id": 42, "opted_out": true, "opted_out_reason": "crm_sync", "...": "..." }
}
Erreur
{
  "status": "error",
  "message": "Contact not found."
}