suppress-hard-bounced
정보
이 스킬은 발신자 평판을 보호하고 감사 추적을 제공하기 위해 HubSpot API를 통해 하드 바운스된 이메일 연락처를 식별합니다. 발견(discovery) 작업은 API를 통해 자동화되지만, 관련 필드가 API를 통해 읽기 전용이므로 억제(suppression)는 HubSpot UI에서 수동으로 수행해야 하는 하이브리드 방식을 사용합니다. 지속적인 데이터베이스 관리에 활용하여 전송 불가능한 연락처를 모니터링하고 관리하세요.
빠른 설치
Claude Code
추천npx skills add TomGranot/hubspot-admin-skills -a claude-code/plugin add https://github.com/TomGranot/hubspot-admin-skillsgit clone https://github.com/TomGranot/hubspot-admin-skills.git ~/.claude/skills/suppress-hard-bouncedClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Suppress Hard-Bounced Contacts
Purpose
Hard-bounced contacts have permanently undeliverable email addresses. Every email sent to them fails, wastes send volume, and actively damages sender reputation with ISPs like Gmail, Microsoft, and Yahoo. This skill identifies all hard-bounced contacts, exports an audit trail, creates a HubSpot active list for ongoing monitoring, and guides the user through manual suppression in the UI.
Prerequisites
- A HubSpot private app access token with
crm.objects.contacts.readandcrm.lists.read/crm.lists.writescopes - Python 3.10+ with
uvfor package management - A
.envfile containingHUBSPOT_ACCESS_TOKEN - Super Admin or Marketing Hub Admin permissions for the manual UI suppression step
Key Constraint
hs_marketable_status is read-only via the API. You cannot set a contact to non-marketing programmatically. The API is used for discovery, analysis, and audit trail generation. The actual suppression must happen in the HubSpot UI.
Execution Pattern
This skill follows a 4-stage execution pattern: Plan -> Before State -> Execute -> After State.
Stage 1: Plan
Before writing any code, confirm with the user:
- Understand the impact: Suppressed contacts remain in the CRM but stop counting toward the marketing contact billing tier. They cannot receive marketing emails.
- Non-marketing processing timing: HubSpot processes non-marketing status changes at the start of the next billing cycle. Billing savings are not immediate.
- High-bounce contacts: Contacts with 3+ bounces are the most severe reputation risk. Ask whether the user wants a separate review list for potential deletion.
Stage 2: Before State
Discover all hard-bounced contacts, break down by bounce reason, and generate an audit CSV.
"""
Before State: Count and audit hard-bounced contacts.
Creates:
1. A HubSpot active list for ongoing monitoring
2. A local CSV audit log of all affected contacts
"""
import os
import csv
import time
import requests
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.environ["HUBSPOT_ACCESS_TOKEN"]
BASE = "https://api.hubapi.com"
headers = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json",
}
url = f"{BASE}/crm/v3/objects/contacts/search"
# --- Step 1: Paginated search for all hard-bounced contacts ---
search_payload = {
"filterGroups": [
{
"filters": [
{
"propertyName": "hs_email_hard_bounce_reason_enum",
"operator": "HAS_PROPERTY",
}
]
}
],
"properties": [
"email", "firstname", "lastname",
"hs_email_hard_bounce_reason_enum",
"hs_email_bounce", "lifecyclestage",
"hs_marketable_status", "createdate",
],
"limit": 100,
}
all_contacts = []
after = None
while True:
payload = search_payload.copy()
if after:
payload["after"] = after
resp = requests.post(url, headers=headers, json=payload)
resp.raise_for_status()
data = resp.json()
for contact in data.get("results", []):
props = contact.get("properties", {})
all_contacts.append({
"id": contact["id"],
"email": props.get("email", ""),
"firstname": props.get("firstname", ""),
"lastname": props.get("lastname", ""),
"hard_bounce_reason": props.get("hs_email_hard_bounce_reason_enum", ""),
"bounce_count": props.get("hs_email_bounce", ""),
"lifecycle_stage": props.get("lifecyclestage", ""),
"marketable_status": props.get("hs_marketable_status", ""),
"createdate": props.get("createdate", ""),
})
paging = data.get("paging", {})
after = paging.get("next", {}).get("after")
if not after:
break
time.sleep(0.2)
print(f"Total hard-bounced contacts: {len(all_contacts)}")
# --- Step 2: Bounce reason breakdown ---
reasons = {}
for c in all_contacts:
r = c["hard_bounce_reason"] or "(empty)"
reasons[r] = reasons.get(r, 0) + 1
print("\nBounce reason breakdown:")
for reason, count in sorted(reasons.items(), key=lambda x: -x[1]):
pct = (count / len(all_contacts) * 100) if all_contacts else 0
print(f" {reason}: {count} ({pct:.1f}%)")
# --- Step 3: Marketing status breakdown ---
already_non_marketing = sum(
1 for c in all_contacts if c["marketable_status"] == "false"
)
still_marketing = len(all_contacts) - already_non_marketing
print(f"\nAlready non-marketing: {already_non_marketing}")
print(f"Still marketing (need suppression): {still_marketing}")
# --- Step 4: High-bounce contacts (3+) ---
high_bounce = [
c for c in all_contacts
if c["bounce_count"] and int(float(c["bounce_count"])) >= 3
]
print(f"Contacts with 3+ bounces (review for deletion): {len(high_bounce)}")
# --- Step 5: Save CSV audit log ---
os.makedirs("data/audit-logs", exist_ok=True)
csv_path = "data/audit-logs/hard-bounced-contacts.csv"
with open(csv_path, "w", newline="") as f:
writer = csv.DictWriter(f, fieldnames=[
"id", "email", "firstname", "lastname", "hard_bounce_reason",
"bounce_count", "lifecycle_stage", "marketable_status", "createdate",
])
writer.writeheader()
writer.writerows(all_contacts)
print(f"\nAudit log saved: {csv_path} ({len(all_contacts)} records)")
Expected output: Total count, bounce reason breakdown, marketing status split, and CSV export.
Bounce reason categories to explain to the user:
- OTHER: Generic bounce, often a server configuration issue
- UNKNOWN_USER: The mailbox does not exist (most common hard bounce)
- SPAM: The receiving server flagged the message as spam -- investigate what content was sent
- POLICY: Receiving server policy rejected delivery
- MAILBOX_FULL: Technically a soft bounce that HubSpot escalated to hard after repeated failures
Stage 3: Execute
This is a hybrid step -- the API creates a HubSpot list, but suppression must happen in the UI.
Step 3a: Create a HubSpot active list via API
"""
Execute (API part): Create a HubSpot active list for hard-bounced contacts.
"""
list_payload = {
"name": "CLEANUP: Hard Bounced Contacts",
"objectTypeId": "0-1", # contacts
"processingType": "DYNAMIC", # active list
"filterBranch": {
"filterBranchType": "OR",
"filterBranches": [
{
"filterBranchType": "AND",
"filterBranches": [],
"filters": [
{
"filterType": "PROPERTY",
"property": "hs_email_hard_bounce_reason_enum",
"operation": {
"operationType": "ALL_PROPERTY",
"operator": "IS_KNOWN",
},
}
],
}
],
"filters": [],
},
}
resp = requests.post(
f"{BASE}/crm/v3/lists", headers=headers, json=list_payload,
)
if resp.status_code in (200, 201):
list_data = resp.json()
list_id = list_data.get("listId") or list_data.get("list", {}).get("listId")
print(f"List created! ID: {list_id}")
elif resp.status_code == 409:
print("List already exists (409 conflict). Use the existing list.")
else:
print(f"Failed to create list: {resp.status_code} — {resp.text[:300]}")
Step 3b: Suppress contacts in HubSpot UI
Instruct the user to perform these steps manually:
- Open the list "CLEANUP: Hard Bounced Contacts" in HubSpot
- Click the checkbox in the table header row to select all contacts on the page
- Click the "Select all N contacts in this list" link in the blue banner
- Click More > Set marketing contact status
- Select Set as non-marketing contact
- Click Confirm
Step 3c (optional): Create a high-bounce review list
If the user wants to review contacts with 3+ bounces for potential deletion, create a second list:
# Optional: List for contacts with 3+ bounces
review_list_payload = {
"name": "REVIEW: 3+ Bounces - Possible Delete",
"objectTypeId": "0-1",
"processingType": "DYNAMIC",
"filterBranch": {
"filterBranchType": "OR",
"filterBranches": [
{
"filterBranchType": "AND",
"filterBranches": [],
"filters": [
{
"filterType": "PROPERTY",
"property": "hs_email_bounce",
"operation": {
"operationType": "NUMBER",
"operator": "IS_GREATER_THAN",
"value": 2,
},
}
],
}
],
"filters": [],
},
}
Stage 4: After State
Re-run the Before State query. Compare the still_marketing count -- it should be zero (or near zero if new bounces occurred between Before and After).
"""
After State: Verify hard-bounced contacts have been suppressed.
"""
# Re-run the same search and check marketable_status
still_marketing_after = sum(
1 for c in all_contacts_after if c["marketable_status"] != "false"
)
if still_marketing_after == 0:
print("SUCCESS: All hard-bounced contacts are now non-marketing.")
else:
print(f"WARNING: {still_marketing_after} hard-bounced contacts "
f"are still marketing. Re-check the list in the UI.")
Important: Always re-measure before executing. Counts drift over time as new emails bounce.
Safety Mechanisms
| Mechanism | Detail |
|---|---|
| CSV audit trail | Every hard-bounced contact is exported with full details before any action. |
| Active list for monitoring | The HubSpot list is DYNAMIC, so new hard bounces are automatically captured. Keep it active permanently. |
| Non-destructive suppression | Contacts are moved to non-marketing status, not deleted. They remain in the CRM with full history. |
| Separate review list | Contacts with 3+ bounces are flagged in a dedicated list for deletion review, not auto-deleted. |
| Confirmation prompt | Present Before State findings to the user and wait for explicit confirmation before creating lists or instructing UI actions. |
Technical Gotchas
-
Property name is
hs_email_hard_bounce_reason_enum, noths_email_hard_bounce_reason. The_enumsuffix is required in API calls. -
hs_marketable_statusis read-only via API. This is the single biggest constraint. There is no API endpoint to change a contact's marketing status. The only way is through the HubSpot UI or via a HubSpot workflow triggered by a custom property flag. -
Workaround for full automation: Create a custom contact property (e.g.,
suppress_marketing_flag), set it via API, then build a HubSpot workflow that triggers on that flag to set the contact as non-marketing. This adds complexity but enables end-to-end automation. -
Billing cycle timing: Non-marketing status changes take effect at the start of the next billing cycle. Do not expect immediate billing savings.
-
Bounce count property:
hs_email_bouncestores the count as a string that may contain decimal values (e.g.,"3.0"). Always cast withint(float(value)). -
Keep the list active permanently. New hard bounces will occur over time. The active list captures them automatically. Run this suppression process monthly or set up a workflow.
Package Setup
uv init hubspot-cleanup
cd hubspot-cleanup
uv add requests python-dotenv
Create a .env file:
HUBSPOT_ACCESS_TOKEN=pat-na1-xxxxxxxx
GitHub 저장소
연관 스킬
executing-plans
디자인executing-plans 스킬은 검토 체크포인트가 포함된 통제된 배치로 실행할 완전한 구현 계획이 있을 때 사용합니다. 이 스킬은 계획을 불러와 비판적으로 검토한 후, 소규모 배치(기본값 3개 작업)로 작업을 실행하면서 각 배치 사이에 진행 상황을 아키텍트 검토를 위해 보고합니다. 이를 통해 내재된 품질 관리 체크포인트를 갖춘 체계적인 구현이 보장됩니다.
requesting-code-review
디자인이 스킬은 코드 변경 사항을 요구 사항에 따라 분석하기 위해 코드 리뷰어 하위 에이전트를 호출합니다. 작업 완료 후, 주요 기능 구현 후, 또는 메인 브랜치에 병합하기 전에 사용해야 합니다. 이 리뷰는 현재 구현체와 원래 계획을 비교하여 문제를 조기에 발견하는 데 도움이 됩니다.
connect-mcp-server
디자인이 스킬은 개발자들이 HTTP, stdio 또는 SSE 전송 방식을 통해 MCP 서버를 Claude Code에 연결하는 포괄적인 가이드를 제공합니다. GitHub, Notion 및 사용자 정의 API와 같은 외부 서비스를 통합하기 위한 설치, 구성, 인증 및 보안을 다룹니다. MCP 통합 설정, 외부 도구 구성 또는 Claude의 모델 컨텍스트 프로토콜 작업 시 활용하세요.
web-cli-teleport
디자인이 스킬은 작업 분석을 기반으로 개발자가 Claude Code 웹 인터페이스와 CLI 인터페이스 중 선택할 수 있도록 돕고, 두 환경 간 원활한 세션 텔레포트를 가능하게 합니다. 웹, CLI 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.
