Leads

Potential customers and incoming inquiries tracked via HubSpot Integration. Leads represent the earliest stage of the sales funnel before conversion to Contacts and Companies.

HubSpot mirror: hubspot_leads mirrors the HubSpot Lead object (objectTypeId 0-136, leadConfig in services/hubspot/sync-engine/entity-configs.ts). hubspotId is for sync round-tripping only — internal references join on the UUID PK.

Source Files

LayerPath
Schemabackend/src/db/schema.ts (hubspotLeads)
Backendbackend/src/routes/admin/hubspot-sync.ts (leads endpoints at /leads, /leads/:id)
Pagesfrontend/src/pages/LeadsPage.tsx, frontend/src/pages/LeadDetailPage.tsx

Database Table

TablePurpose
hubspot_leadsHubSpot-synced leads with pipeline, status, and association references

Key Fields

FieldTypeNotes
hubspotIdvarchar(100)HubSpot Lead object ID (unique, required)
hubspotContactIdvarcharAssociated HubSpot contact ID
contactIduuid FKLocal contact reference (nullable)
hubspotCompanyIdvarcharAssociated HubSpot company ID
companyIduuid FKLocal company reference (nullable)
leadNamevarchar(255)Display name of the lead
leadStatusvarchar(100)Current status in the pipeline
leadLabelvarchar(100)Classification label
hubspotPipelinevarcharHubSpot pipeline identifier
hubspotPipelineStagevarcharCurrent stage within the pipeline
recordOwnerContactIduuid FKRead-only sync mirror of the HubSpot record owner, resolved to a contact via hubspot_owners (replaced the old hubspotOwnerId varchar — PR#1767); sync layer is the sole writer
hubspotPropertiesjsonbFull HubSpot property bag
hubspotSchemaVersionvarchar(20)Schema version for sync compatibility
lastSyncedAttimestampLast sync timestamp
archived, archivedAt, deletedAtbool/timestampSoft archive + privacy deletion
archiveReasontextWhy the lead was archived
mergedIntoHubspotIdvarcharIf lead was merged into another

Relationships

Lead *──0..1 Contact (local contact reference)
Lead *──0..1 Company (local company reference)

Leads may reference both a HubSpot contact/company ID and a local contact/company record once the association is established.

API Endpoints

Leads are served through the HubSpot admin sync routes:

MethodPathPurpose
GET/api/admin/hubspot/sync/leadsPaginated lead list
GET/api/admin/hubspot/sync/leads/:idSingle lead detail

Leads are synced as part of the full HubSpot sync process (with syncLeads flag).

Conversion Flow

HubSpot Lead -> Sync -> hubspot_leads table
                     -> Associate with local Contact/Company
                     -> Convert to Building/Project (manual)

When a lead converts, the associated contact and company records serve as the basis for creating Buildings and Projects.

Features

  • HubSpot-native — leads originate and are primarily managed in HubSpot CRM
  • Pipeline tracking with stage progression synced from HubSpot
  • Soft archive with reason tracking and merge detection
  • Association linking to local Contacts and Companies records

Contacts | Companies | Buildings | Projects | HubSpot Integration | Admin Dashboard