#!/usr/bin/env bash
# Remove a do-not-call entry. Only do this when the entry was added by mistake. Needs: curl, jq.
set -euo pipefail
BASE="${RELATIONSAI_API_BASE:-https://voice-api.relationsai.com/v1}"
: "${DNC_ENTRY_ID:?Set DNC_ENTRY_ID to the entry id (dnc_...)}"

deleted=$(curl -sS --fail-with-body -X DELETE "$BASE/dnc-entries/$DNC_ENTRY_ID" \
  -H "Authorization: Bearer $RELATIONSAI_API_KEY") || { echo "$deleted" >&2; exit 1; }
jq -r '"Removed \(.id) deleted=\(.deleted)"' <<<"$deleted"
