Cleanup Workflows
Audit HubSpot workflows to remove dead weight. Unused workflows clutter the automation dashboard and make it harder to understand what is actually running.
Prerequisites
- - HubSpot API token in INLINECODE0
- Python with
hubspot-api-client installed via INLINECODE2 - Note: The Workflows API may return 403 on some plan tiers. If so, audit manually in HubSpot UI under Automation > Workflows.
Step-by-Step Instructions
Stage 1: Before — Inventory All Workflows
Pull all workflows. The Automation API endpoint for workflows:
CODEBLOCK0
For each workflow, record: ID, name, enabled status, type, enrollment count, created date, last updated date.
Stage 2: Execute — Identify Candidates for Deletion
Flag workflows matching any of these criteria:
- 1. Turned off for 90+ days with no plans to reactivate
- Zero enrollments ever (likely test or abandoned drafts)
- Test workflows (names containing "test", "temp", "copy of", "draft")
- Superseded workflows replaced by newer versions
- Error state workflows that have been failing consistently
Before deleting, check:
- - Does the workflow feed into another workflow (via enrollment trigger)?
- Does the workflow set properties that other workflows depend on?
- Is there any documentation referencing this workflow?
Stage 3: After — Delete and Document
- 1. Turn off workflows first, wait one week, then delete if no issues arise.
- Document deleted workflows in a cleanup log (name, purpose, reason for deletion).
- Notify workflow owners before deletion.
Stage 4: Rollback
- - Deleted workflows cannot be restored.
- Before deleting, screenshot or document the workflow logic (triggers, actions, branches) so it can be recreated if needed.
- HubSpot retains workflow activity history on contact records even after the workflow is deleted.
Tips
- - Use folders in the workflows dashboard to organize by team, purpose, or status.
- Prefix draft/test workflows with "[TEST]" so they are easy to identify later.
- Review workflows quarterly as part of the database cleanup routine.
清理工作流
审计HubSpot工作流,清除冗余内容。未使用的工作流会杂乱地堆在自动化仪表盘中,让人难以了解实际运行的内容。
前提条件
- - 在.env文件中配置HubSpot API令牌
- 通过uv安装带有hubspot-api-client的Python环境
- 注意:某些套餐层级的工作流API可能返回403错误。若出现此情况,请在HubSpot界面中手动审计:自动化 > 工作流。
分步操作指南
第一阶段:前期准备——盘点所有工作流
拉取所有工作流。工作流的自动化API端点如下:
python
import requests
headers = {Authorization: fBearer {os.getenv(HUBSPOTAPITOKEN)}}
response = requests.get(
https://api.hubapi.com/automation/v4/flows,
headers=headers,
params={limit: 100}
)
workflows = response.json()
针对每个工作流,记录以下信息:ID、名称、启用状态、类型、注册数量、创建日期、最后更新日期。
第二阶段:执行操作——识别待删除候选
标记符合以下任一条件的工作流:
- 1. 已关闭超过90天且无重新激活计划
- 零注册记录(很可能是测试或废弃草稿)
- 测试工作流(名称包含test、temp、copy of、draft等字样)
- 被替代的工作流已被新版本取代
- 处于错误状态的工作流持续运行失败
删除前需检查:
- - 该工作流是否通过注册触发器关联到其他工作流?
- 该工作流是否设置了其他工作流依赖的属性?
- 是否有任何文档引用了该工作流?
第三阶段:后续处理——删除与记录
- 1. 先关闭工作流,等待一周,若无问题出现再执行删除。
- 在清理日志中记录已删除的工作流(名称、用途、删除原因)。
- 删除前通知工作流所有者。
第四阶段:回滚操作
- - 已删除的工作流无法恢复。
- 删除前,截图或记录工作流逻辑(触发器、操作、分支),以便需要时重新创建。
- 即使工作流被删除,HubSpot仍会在联系人记录中保留工作流活动历史。
实用建议
- - 在工作流仪表盘中使用文件夹,按团队、用途或状态进行组织。
- 为草稿/测试工作流添加[TEST]前缀,便于日后识别。
- 每季度审查工作流,作为数据库清理常规流程的一部分。