Cleanup Lead Owners
Remove non-employee users from HubSpot and reassign their orphaned contacts, companies, and deals. Pairs with the assign-unowned-contacts skill for comprehensive ownership cleanup.
MCP get_skill({ skillId: "cleanup-lead-owners-aad4c215" })Use this skill with your agent
Create a free account and connect via MCP
# Cleanup Lead Owners
Remove departed employees from HubSpot and reassign their CRM records. Orphaned records with no active owner fall through the cracks.
## Prerequisites
- HubSpot API token in `.env`
- Python with `hubspot-api-client` installed via `uv`
- A list of current employees (to compare against HubSpot users)
- A default owner or round-robin assignment rule for orphaned records
## Step-by-Step Instructions
### Stage 1: Before — Identify Non-Employee Owners
```python
from hubspot import HubSpot
api_client = HubSpot(access_token=os.getenv("HUBSPOT_API_TOKEN"))
# Get all owners including deactivated
active_owners = api_client.crm.owners.owners_api.get_page(limit=100)
deactivated_owners = api_client.crm.owners.owners_api.get_page(
limit=100, archived=True
)
```
Cross-reference with your current employee list. Flag:
- Deactivated HubSpot users who still own records
- Active HubSpot users who are no longer employees
- Contractors or vendors who should not own records
For each flagged owner, count how many contacts, companies, and deals they own.
### Stage 2: Execute — Reassign and Deactivate
1. **Reassign records** owned by non-employees:
- Use the batch update API to reassign contacts to the appropriate active owner
- Apply round-robin or territory-based rules if no specific owner is obvious
- Reassign companies and deals associated with the same contacts
2. **Deactivate users** who are no longer employees (requires Super Admin in HubSpot Settings > Users & Teams).
3. **Run `/assign-unowned-contacts`** after reassignment to catch any records that ended up without an owner.
### Stage 3: After — Verify
1. Search for contacts where `hubspot_owner_id` matches any deactivated owner ID — count should be zero.
2. Confirm all reassigned contacts have an active owner.
3. Check that no workflows broke due to owner changes (some workflows may filter by specific owners).
### Stage 4: Rollback
- Owner reassignments can be reversed by batch-updating the `hubspot_owner_id` back to the original value.
- Keep a log of original owner assignments before making changes.
- Deactivated users can be reactivated in HubSpot Settings if needed.
## Tips
- Run this whenever an employee leaves the company — do not wait for quarterly cleanup.
- Set up an offboarding checklist that includes HubSpot record reassignment.
- Pairs with `/assign-unowned-contacts` for comprehensive ownership hygiene.Related Skills
More skills in Business, Marketing & Sales
Ab Testing
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program," or "experiment playbook." Use this whenever someone is comparing two approaches and wants to measure which performs better, or when they want to build a systematic experimentation practice. For tracking implementation, see analytics. For page-level conversion optimization, see cro.
Ab Test Setup
When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.
Ab Test Setup
Ab Test Setup linked from Corey Haines marketing skills, with the upstream skill instructions available on GitHub.
Ab Test Store Listing
When the user wants to A/B test App Store product page elements to improve conversion rate. Also use when the user mentions "A/B test", "product page optimization", "test my screenshots", "test my icon", "conversion rate optimization", "CPP", or "custom product pages". For screenshot design, see screenshot-optimization. For metadata optimization, see metadata-optimization.
Account Research
Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".
Account Research
Research a company using Common Room data. Triggers on 'research [company]', 'tell me about [domain]', 'pull up signals for [account]', 'what's going on with [company]', or any account-level question.
Explore Other Categories
Skills from other categories with shared topics
Agile Product Owner
Agile product ownership for backlog management and sprint execution. Covers user story writing, acceptance criteria, sprint planning, and velocity tracking. Use when writing user stories, creating acceptance criteria, planning sprints, estimating story points, breaking down epics, or prioritizing the backlog.
Deliver User Stories
Generates user stories in the standard persona, action, benefit story format from product requirements or feature descriptions. Use when breaking a feature into stories for sprint planning, writing tickets, or communicating scope to engineering. For testable Given/When/Then acceptance criteria on a story, use deliver-acceptance-criteria; for boundary and failure scenarios, use deliver-edge-cases.
Jira Automation
Automate Jira project management workflows, sprint planning, issue tracking, and reporting