Hubspot-admin-skills 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.
install
source · Clone the upstream repo
git clone https://github.com/TomGranot/hubspot-admin-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/TomGranot/hubspot-admin-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/cleanup-lead-owners" ~/.claude/skills/tomgranot-hubspot-admin-skills-cleanup-lead-owners && rm -rf "$T"
manifest:
skills/cleanup-lead-owners/SKILL.mdsource content
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
installed viahubspot-api-clientuv - 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
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
-
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
-
Deactivate users who are no longer employees (requires Super Admin in HubSpot Settings > Users & Teams).
-
Run
after reassignment to catch any records that ended up without an owner./assign-unowned-contacts
Stage 3: After — Verify
- Search for contacts where
matches any deactivated owner ID — count should be zero.hubspot_owner_id - Confirm all reassigned contacts have an active owner.
- 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
back to the original value.hubspot_owner_id - 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
for comprehensive ownership hygiene./assign-unowned-contacts