Dolibarr ERP/CRM is a powerful open-source platform known for its flexibility and wide range of built-in business management tools. While Dolibarr includes basic CRM functionality, businesses may find it useful—or even necessary—to integrate it with external CRM systems like HubSpot, Zoho CRM, or Salesforce to improve marketing automation, customer engagement, or reporting. This guide explains how to synchronize Dolibarr with external CRMs without relying on expensive plugins or proprietary middleware.

Table of Contents

  1. Why Sync Dolibarr with an External CRM?

  2. Overview of Popular External CRMs

  3. Integration Methods: Direct API, Middleware, and Custom Scripts

  4. Requirements and Preparations

  5. Understanding Dolibarr's API Structure

  6. Overview of HubSpot, Zoho, and Salesforce APIs

  7. Choosing What to Sync (Leads, Contacts, Deals, Invoices)

  8. Setting Up API Access on Dolibarr

  9. Setting Up API Access on the External CRM

  10. Mapping Data Fields Between Systems

  11. Creating a Synchronization Script (PHP/Python)

  12. Handling Authentication and Tokens Securely

  13. Automating the Sync with Cron Jobs or Webhooks

  14. Error Handling and Data Conflict Resolution

  15. Final Thoughts and Best Practices


1. Why Sync Dolibarr with an External CRM?

While Dolibarr handles CRM basics like third-party management, tasks, and proposals, external CRMs provide specialized tools such as:

  • Marketing automation (email campaigns, lead nurturing)

  • Sales pipelines and advanced forecasting

  • Built-in telephony or chatbot integrations

  • Enhanced dashboards and analytics

Synchronization ensures that both systems remain in sync and reduce double data entry.


2. Overview of Popular External CRMs

Here’s a quick look at some external CRM options you might integrate with Dolibarr:

  • HubSpot: Inbound marketing, forms, email, and automation

  • Zoho CRM: Strong contact management, lead tracking, and reports

  • Salesforce: Enterprise-grade CRM with deep customization

  • Pipedrive: Focused on simplicity and visual pipelines

  • Freshsales: AI-based scoring and phone integration

All support APIs for integration.


3. Integration Methods: Direct API, Middleware, and Custom Scripts

Three general ways to sync Dolibarr with external CRMs:

  • Direct API integration: Use both APIs to build a bridge

  • Middleware platforms: Use open-source tools like n8n or Integromat (free tier)

  • Custom sync scripts: Ideal for full control and budget-conscious setups

This guide focuses on direct API integration using custom scripts.


4. Requirements and Preparations

Before you begin:

  • Ensure you have Dolibarr with the API module enabled (v9.0+ preferred)

  • Create or access an external CRM account with API privileges

  • Use a server or environment for development (local or remote)

  • Choose a scripting language (PHP, Python, Node.js)

Also:

  • Back up both systems

  • List the data to sync: third parties, contacts, deals, etc.


5. Understanding Dolibarr's API Structure

Dolibarr’s REST API supports most core modules:

  • Thirdparties: /thirdparties

  • Contacts: /contacts

  • Orders: /orders

  • Invoices: /invoices

Access format:

https://yourdolibarr.com/api/index.php/thirdparties?DOLAPIKEY=your_key

Response is JSON. Use GET/POST/PUT depending on operation.


6. Overview of HubSpot, Zoho, and Salesforce APIs

HubSpot

  • Base: https://api.hubapi.com/

  • Authentication: OAuth2 or API Key (deprecated soon)

  • Common endpoints: /contacts/v1, /deals/v1, /companies/v2

Zoho

  • Base: https://www.zohoapis.com/crm/v2/

  • OAuth2 required

  • Supports modules like Leads, Contacts, Deals

Salesforce

  • Uses REST API via OAuth2

  • Requires a registered app with client secret

  • REST base: https://instance.salesforce.com/services/data/vXX.0/


7. Choosing What to Sync (Leads, Contacts, Deals, Invoices)

Define your sync scope:

  • From Dolibarr to CRM: Contacts, companies, invoices

  • From CRM to Dolibarr: Leads, marketing-qualified contacts

  • Decide direction (uni- or bi-directional)

Mapping should be clear and stored in a config file or database.


8. Setting Up API Access on Dolibarr

  1. Enable the API module from Dolibarr admin

  2. Generate the API key for the integration user

  3. Grant permissions to required modules

  4. Test API access with curl or Postman:

curl https://yourdolibarr.com/api/index.php/thirdparties?DOLAPIKEY=your_key

9. Setting Up API Access on the External CRM

Follow the CRM's developer guide to:

  • Create an app/client (for OAuth2)

  • Obtain client ID and secret

  • Set scopes and redirect URIs

  • Test using their API explorer or curl

Store the access and refresh tokens securely.


10. Mapping Data Fields Between Systems

Example:

Dolibarr Field HubSpot Field
name company
email email
phone phone
note_private notes
date_creation createdate

Use arrays or dictionaries in your script to manage this mapping.


11. Creating a Synchronization Script (PHP/Python)

Example in Python (syncing contacts):

import requests

# Get Dolibarr contacts
dol_url = "https://yourdolibarr.com/api/index.php/contacts?DOLAPIKEY=your_key"
dolibarr_contacts = requests.get(dol_url).json()

# Send to HubSpot
hubspot_url = "https://api.hubapi.com/contacts/v1/contact/"
headers = {"Authorization": "Bearer YOUR_ACCESS_TOKEN"}

for contact in dolibarr_contacts:
    data = {
        "properties": [
            {"property": "email", "value": contact['email']},
            {"property": "firstname", "value": contact['firstname']},
        ]
    }
    requests.post(hubspot_url, json=data, headers=headers)

12. Handling Authentication and Tokens Securely

  • Never hardcode credentials

  • Use .env files or environment variables

  • Refresh tokens periodically

  • Set token expiration alerts

Consider using token management libraries or packages.


13. Automating the Sync with Cron Jobs or Webhooks

  • Use cron to schedule periodic syncs (e.g., every 15 mins)

  • Use webhooks to react to changes instantly (if CRM supports it)

Example cron job:

*/15 * * * * /usr/bin/python3 /path/sync_contacts.py

14. Error Handling and Data Conflict Resolution

Handle errors such as:

  • 401 Unauthorized (token expired)

  • 400 Bad Request (missing fields)

  • 429 Too Many Requests (rate limits)

Also handle:

  • Duplicate records

  • Conflicting updates

  • Soft deletes or archiving

Log each sync run with a timestamp and result.


15. Final Thoughts and Best Practices

Connecting Dolibarr with an external CRM gives your business a strategic advantage, combining Dolibarr’s ERP power with advanced marketing and sales tools.

Best practices:

  • Start with one-way sync before moving to bi-directional

  • Test thoroughly before automating

  • Maintain documentation of API usage and field mappings

  • Secure credentials and rotate regularly

  • Use staging environments for new features