The Digital Developer Blog - Blogs by Computan

How to Sync Salesforce and HubSpot Using Custom Middleware

Written by Simranjeet Singh | August 21, 2026 at 8:12 AM

Salesforce and HubSpot both want to be the source of truth for the same customer record, and when the two systems fall out of step, sales and marketing end up working from different versions of reality.

TL;DR

  • HubSpot's native Salesforce integration covers most standard contact, company, and deal syncing needs right out of the box.
  • Custom middleware becomes worth building when you need custom business logic, non-standard objects, conditional sync rules, or Salesforce enforced as a strict source of truth.
  • A Laravel and MySQL middleware layer sits between the Salesforce API and the HubSpot API, giving you full control over transformation, matching, and scheduling.
  • Incremental sync based on Last Modified Date timestamps keeps API usage low and sync windows fast.
  • Duplicate prevention, a documented field mapping, and ongoing monitoring are what separate a reliable sync from a fragile one.

Why Sync Salesforce and HubSpot?

Most businesses that run both platforms did not plan it that way. Sales standardizes on Salesforce for pipeline management, marketing builds campaigns and forms in HubSpot, and within a few months both systems are holding overlapping records of the same contacts and companies. HubSpot's own documentation confirms that its Salesforce integration is built to synchronize contacts, companies, deals, activities, and other supported data between the two platforms, which is exactly the kind of connective tissue that keeps sales and marketing working from the same information.[1]

A working sync between the two systems generally supports:

  • Keeping customer and company data consistent across both platforms
  • Reducing manual data entry and duplicate re-keying
  • Improving marketing and sales alignment on lead status and deal stage
  • Keeping activity and engagement data accessible to whichever team needs it
  • Creating more reliable, closed-loop reporting
  • Maintaining Salesforce as the source of truth for the fields where it should be

Can You Sync Salesforce and HubSpot Without Custom Middleware?

There are three common approaches to connecting the platforms, and it is worth understanding all three before assuming you need the most complex one.

  • Native Salesforce-HubSpot integration. HubSpot's own connector handles standard object sync for contacts, companies, deals, and activities, with configurable sync rules and field mappings managed inside HubSpot's settings.[1]
  • Third-party integration platforms. iPaaS tools sit between the two systems and offer more flexible mapping and transformation than the native connector, without requiring you to host or maintain your own codebase.
  • Custom middleware. A purpose-built application that you own end to end, giving you full control over data transformation, sync direction, scheduling, and business logic that neither of the other two options can accommodate.

These three options trade off against each other on complexity, customization, data volume, sync frequency, the amount of business logic they can express, ongoing maintenance, and cost. Readers evaluating custom middleware should understand this tradeoff clearly, because the native integration is often enough on its own, and a heavier build is only worth it when the standard connector genuinely cannot do what the business needs.

When Do You Need Custom Salesforce to HubSpot Integration?

HubSpot supports configurable field mappings, sync directions, and syncing of custom objects out of the box.[4][5] But mature Salesforce orgs often carry years of process refinement in the form of validation rules, required fields, and deeply embedded custom objects, and an integration that does not respect that structure can generate sync errors or incomplete records.[6] Custom middleware tends to make sense when a business runs into:

  • Complex data transformation requirements between the two platforms
  • Custom objects or non-standard data structures in Salesforce
  • Conditional synchronization, where only certain records or fields should move
  • Specific sync schedules that do not match HubSpot's built-in cadence
  • Salesforce needing to act as the single, undisputed source of truth
  • Custom association logic between records that the native connector cannot express
  • Large or historical datasets that need to be processed outside a live sync
  • Business rules that the native integration simply was not built to accommodate

How Custom Middleware Connects Salesforce and HubSpot

A custom middleware setup follows a straightforward architecture: Salesforce feeds records into the middleware, the middleware stores and processes them, and then it pushes the finished records into HubSpot.

  • Salesforce API layer. Handles authentication and retrieves records, typically filtered by Last Modified Date so the middleware only pulls what has actually changed.
  • Laravel middleware layer. The application logic that owns authentication, transformation, matching, and scheduling for the whole sync.
  • MySQL database. Stores records locally so the middleware can track what has already synced, normalize data, and recover cleanly if a run fails partway through.
  • HubSpot API layer. Receives the transformed records and creates or updates the matching HubSpot objects.
  • Scheduled synchronization process. A job runner that triggers each of these steps on a defined interval, whether that is every ten minutes or once an hour.

The reason middleware is worth the extra build effort is that it acts as a control layer, not just a pipe. Data does not move directly from one CRM to the other; it passes through a system you own, where it can be validated, transformed, filtered, and logged before it ever reaches HubSpot.

How to Build a Salesforce to HubSpot Data Sync Using APIs

1. Connect to the Salesforce API

Authentication for server-to-server integrations typically uses the OAuth 2.0 JWT bearer flow rather than username-password authentication, which Salesforce has deprecated for production use.[10] Once connected, records are retrieved with SOQL queries filtered on Last Modified Date rather than pulling the entire object every run, which is the single biggest lever for staying inside Salesforce's API limits.[8] Governor limits apply per transaction rather than per API call, so a single request that triggers heavy Apex logic can consume far more of your budget than the raw call count suggests, which is worth accounting for when you size your polling interval.[9]

2. Store and Process Salesforce Data in Middleware

Incoming records land in a local MySQL table before anything is sent to HubSpot. This gives the middleware a place to normalize inconsistent formatting, track which records have already been synced so they are not reprocessed unnecessarily, and log errors in a way that survives a failed run instead of silently dropping records.

3. Map Salesforce Fields to HubSpot Properties

Field mapping needs to account for standard fields, custom fields, differences in data types between the two platforms, and which HubSpot properties are required before a record can be created. HubSpot's own field mapping tools let you pair a HubSpot property with a specific Salesforce field for contacts, companies, and deals, which is a useful reference point even when you are building the mapping logic yourself.[4]

4. Send Records to HubSpot Through Its API

The final step covers creating new records, updating existing ones, matching against records that already exist in HubSpot, and handling whatever comes back in the API response. HubSpot's batch endpoints let you create, update, or read multiple records in a single call, which is the standard way to keep call volume down during a sync run rather than sending one request per record.[12] When a request does get rate-limited, the standard pattern is to read the Retry-After header and back off with exponential delay rather than retrying immediately.[13]

How to Sync Salesforce Accounts to HubSpot Companies

Salesforce Accounts map to HubSpot Companies in HubSpot's own native integration, so it is a well-established pairing to model middleware logic on.[3] A reliable sync in this direction needs to:

  • Identify existing companies in HubSpot before creating a new one
  • Create new company records when no match exists
  • Update companies whose Salesforce Account has changed
  • Maintain associations between companies and their related contacts and deals
  • Handle missing or incomplete account information gracefully rather than failing the whole batch

How to Sync Salesforce Contacts to HubSpot

Contact syncing is usually the highest-volume part of the integration. Salesforce leads and contacts both resolve down to HubSpot contacts, with accounts syncing to companies based on matching rules such as company domain.[15] Email address remains the primary matching mechanism HubSpot uses to reconcile Salesforce leads and contacts against existing HubSpot records, and contacts generally will not sync at all without one.[2] Custom middleware needs to replicate this same discipline: match on email first, create a new contact only when no match exists, update existing contacts rather than duplicating them, and keep the contact-to-company relationship intact on every write.

How to Sync Salesforce Events and Activities to HubSpot

Activity and event data is where a lot of native integrations fall short, because Salesforce Events do not map cleanly onto a single HubSpot object the way Accounts and Contacts do. A custom sync for this data typically needs to retrieve Salesforce Events filtered by modification date, transform the event data into whatever structure the destination content type expects in HubSpot, send the transformed record through the API, and account for recurring or subsequently updated events so activity history stays accurate for reporting.

How Incremental Salesforce to HubSpot Sync Works

Instead of retrieving every Salesforce record on every run, middleware should check which records changed since the last successful sync. Delta queries filtered on Last Modified Date can reduce API consumption by more than 90 percent in mature orgs, where most records simply have not changed since the previous run.[7] This pattern, often called a scheduled read, polls Salesforce on a configurable interval such as every 5, 10, or 30 minutes and pulls only the records that changed in that window, using LastModifiedDate together with paginated SOQL queries to make sure nothing with an identical timestamp gets skipped.[11][9] The tradeoff is that scheduled reads are predictable, easy to throttle, and easy to debug, but they do consume API quota on every poll whether or not anything actually changed.[11]

A well-built incremental sync should also be able to recover cleanly from a failed run, picking back up from the last confirmed checkpoint instead of re-pulling everything or silently missing records.

How to Prevent Duplicate Data During Salesforce and HubSpot Sync

Duplicate records are one of the most common complaints businesses raise about CRM integrations, and preventing them has to be designed into the middleware rather than cleaned up after the fact. That means:

  • Matching records on unique identifiers before writing anything
  • Using email as the primary match for contacts
  • Storing the Salesforce ID alongside the HubSpot record ID so future syncs can match reliably
  • Matching accounts to companies on a consistent rule, such as domain
  • Checking for an existing match before creating any new record
  • Handling associations carefully so a duplicate company does not fragment a contact's related records

This is one of the strongest commercial-intent reasons businesses look at custom middleware in the first place, because data quality problems compound quietly until reporting stops being trustworthy.

Salesforce and HubSpot Field Mapping Best Practices

Every reliable sync starts with a documented field mapping, not a mapping that only exists in code. An integration mapping document should cover which HubSpot properties map to which Salesforce fields for contacts, companies, deals, and activities, whether each field syncs one way or two ways, and which system wins when both sides have a value.[14] Also plan for:

  • Standard versus custom property differences between the two platforms
  • Data type compatibility, since Salesforce and HubSpot do not always store the same kind of field the same way
  • Which fields are required before HubSpot will accept a record
  • Clear source-of-truth rules for fields that could be edited on either side
  • How to handle fields on one platform that have no direct equivalent on the other

How Often Should Salesforce and HubSpot Data Sync?

There is no single correct sync frequency. Scheduled sync intervals commonly run every 5, 10, or 30 minutes depending on how time-sensitive the data is and how much API quota is available to spend on polling.[11] The right frequency for a given business depends on:

  • Overall data volume and how much of it changes daily
  • How quickly sales and marketing teams actually need updated data to act on it
  • Available API quota on both the Salesforce and HubSpot sides
  • Reporting requirements and how current the numbers need to be

Tighter intervals mean fresher data but higher API usage, and looser intervals conserve quota at the cost of lag. Most businesses land somewhere between 15 minutes and hourly for standard objects, with real-time or near-real-time reserved for the specific fields that actually justify it.

How to Sync Historical Salesforce Data to HubSpot

Ongoing sync and historical data migration are two different problems, and they should be treated that way. Historical migration typically covers existing Accounts moving into Companies, existing Contacts moving into Contacts, and existing Events moving into the appropriate HubSpot records, all processed in batch rather than through the same incremental job that handles day-to-day sync. For large historical loads, the Bulk API is built for exactly this kind of volume and can move millions of records far more efficiently than looping through single-record calls.[10] A historical migration should also include its own data validation, duplicate prevention pass, and post-migration QA before the ongoing incremental sync takes over.

How to Test and Monitor a Salesforce HubSpot Integration

A sync that works once is not the same as a sync that works reliably. Before it goes live, and on an ongoing basis afterward, testing and monitoring should cover:

  • API authentication on both the Salesforce and HubSpot sides
  • Field mapping validation against real records, not just sample data
  • Record creation and record update paths tested independently
  • Duplicate detection under realistic conditions
  • Association testing between contacts, companies, and deals
  • Logging and alerting for failed API requests
  • Retry mechanisms with backoff, since a rate-limited request should not be treated as a permanent failure[13]
  • Periodic data reconciliation between the two platforms to catch silent drift

Custom Middleware vs Native Salesforce HubSpot Integration

It is worth being direct about this: custom middleware is not automatically the better option. It is the right option when the native integration cannot express what the business actually needs.

Requirement Native Integration Custom Middleware
Standard contact sync Yes Yes
Standard company sync Yes Yes
Custom business logic Limited Yes
Custom data transformation Limited Yes
Custom sync schedules Limited Yes
Historical data processing Depends Yes
Complex associations Depends Yes
Custom workflows Limited Yes
Full control over API logic No Yes

Best Practices for Building a Reliable Salesforce and HubSpot Sync

  • Define the system of record for every object before writing any sync logic
  • Document every field mapping in a shared reference, not just in code
  • Establish clear, written sync rules for direction and conflict handling
  • Use incremental synchronization based on Last Modified Date rather than full pulls
  • Build duplicate prevention into the architecture from the start, not as a cleanup step
  • Log every API error with enough context to debug it later
  • Implement retry mechanisms with exponential backoff
  • Test associations explicitly, not just individual record syncs
  • Validate historical data separately from the ongoing sync
  • Monitor synchronization performance and API usage on an ongoing basis

When Should You Choose a Custom Salesforce HubSpot Integration?

Custom middleware tends to make the most sense when a business needs some combination of:

  • Custom synchronization logic that the native connector cannot express
  • Salesforce-to-HubSpot-only synchronization, without a two-way sync
  • Complex field transformations between the two platforms
  • Specific data filters controlling what does and does not sync
  • Scheduled synchronization on a cadence the native integration does not support
  • Historical data migration alongside ongoing sync
  • Custom objects or association logic outside HubSpot's standard model
  • Greater control over exactly how the API behaves under load

Need to connect Salesforce and HubSpot around your specific business processes? Computan can help design and implement custom CRM integrations that connect your systems, automate data synchronization, and accommodate your unique business logic.

Final Thoughts: Building a Scalable Salesforce and HubSpot Data Sync

Native integrations are suitable for a large share of standard use cases, and there is no reason to build custom middleware just because it is possible. Custom middleware earns its place when business requirements go beyond standard synchronization: non-standard objects, strict source-of-truth rules, conditional logic, or historical data that needs its own migration path. A well-designed middleware layer gives you real control over mapping, scheduling, transformation, validation, and error handling. The goal was never simply to move data between two CRMs. It is to build a reliable flow of usable business data that both teams can trust.

Computan is a Canadian digital technology company serving businesses across Canada, the United States, the United Kingdom, Australia, and other markets worldwide. Our team helps businesses connect and optimize their technology ecosystems, including CRM integrations, HubSpot development, Salesforce integrations, custom middleware, and marketing technology solutions. 

Sources:

  1. HubSpot: Connect HubSpot and Salesforce
  2. HubSpot: Understand sync triggers between HubSpot and Salesforce
  3. HubSpot: Sync companies between HubSpot and Salesforce
  4. HubSpot: Map HubSpot properties to Salesforce fields
  5. HubSpot: Sync Salesforce opportunities to HubSpot
  6. Getint: Salesforce HubSpot Integration Guide 2026
  7. Forcenaut: Salesforce API Limits, What Every Developer Should Know
  8. Reintech: Salesforce API Rate Limits, Strategies for Optimization
  9. Sequin: Pulling past the limits of Salesforce's /updated endpoint
  10. Developing Programmers: Salesforce API Integration, A Developer's Practical Guide
  11. Ampersand: Optimizing Salesforce API Quotas for Customer-Facing Integrations at Enterprise Scale
  12. Scopious Digital: HubSpot API Rate Limits, The Limits Table and Production Retry Patterns
  13. HubSpot Developers: API usage guidelines and limits
  14. SmartBug Media: The Definite Guide to HubSpot and Salesforce Integration
  15. Consultevo: Sync Salesforce Leads with HubSpot

Frequently Asked Questions

Do I need custom middleware to connect Salesforce and HubSpot?
Not always. HubSpot's native Salesforce integration handles standard contact, company, deal, and activity syncing for most businesses. Custom middleware is worth building when you need custom business logic, non-standard objects, conditional sync rules, or Salesforce enforced as a strict source of truth.

What does a custom Salesforce to HubSpot middleware actually look like?
Typically a Laravel application backed by a MySQL database, sitting between the Salesforce API and the HubSpot API. It pulls changed Salesforce records, stores and transforms them locally, then pushes the finished records to HubSpot on a defined schedule.

How does incremental sync work between Salesforce and HubSpot?
Instead of pulling every record on every run, the middleware queries Salesforce for records modified since the last successful sync using the Last Modified Date field. This keeps API usage low and sync windows short, even on large datasets.

How do you prevent duplicate records when syncing Salesforce and HubSpot?
By matching on unique identifiers before writing any record, typically email for contacts and domain for companies, and by storing the Salesforce ID alongside the HubSpot record ID so future syncs can match reliably instead of creating a second record.

Can Salesforce Events sync to HubSpot?
Yes, though Events do not map to a single HubSpot object as cleanly as Accounts or Contacts do. A custom sync typically retrieves events by modification date, transforms them into the structure the destination HubSpot content type expects, and accounts for recurring or updated events.

How often should Salesforce and HubSpot data sync?
Most scheduled syncs run somewhere between every 10 minutes and every hour, depending on data volume, available API quota, and how quickly sales and marketing actually need updated information to act on it.

Is historical data migration different from ongoing sync?
Yes. Historical migration moves existing Accounts, Contacts, and Events into HubSpot in batch, usually through the Bulk API, and includes its own validation and QA pass. Ongoing sync then takes over with incremental, Last Modified Date-based updates.