DEV Community

Cover image for Shopify + Zoho CRM Integration Using Python REST API: A Complete Developer Guide
Lucy
Lucy

Posted on

Shopify + Zoho CRM Integration Using Python REST API: A Complete Developer Guide

Businesses running on Shopify often reach a point where they need more robust customer management, sales tracking, and automated workflows beyond what Shopify provides out of the box. Zoho CRM is one of the most widely used CRM platforms because it offers strong lead management, automation rules, pipeline tracking, and multi-channel communication tools. Connecting Shopify with Zoho CRM allows brands to synchronize sales and support teams with a unified view of every interaction.

In this guide, we'll walk through how to integrate Shopify and Zoho CRM using Python REST APIs, and build a webhook listener, authenticate Zoho with APIs with OAuth, and push Shopify customer and order data into Zoho module like Leads, Contacts, and deals.

This tutorial is ideal for developers creating custom integrations or technical merchants working with Shopify Expert Developers who want to build advanced CRM-powered automation.

  1. Why Integrate Shopify with Zoho CRM Syncing Shopify with Zoho CRM unlocks several benefits.
  • Automate the creation of leads/Contacts when a customer signs up
  • Real-time deals when orders are placed
  • Better segmentation for marketing
  • Improved sales follow-ups
  • Centralized customer history
  • Triggered workflows based on order value, purchase frequency, or lifecycle stage.

Instead of manually exporting reports or CSVs, a Python integration ensures your CRM always has the latest customer and order insights synced from Shopify.

Architecture: How the Integration Works

Here's the flow of data between the system
Shopify-Webhooks-PythonAPI-Zoho REST API- CRM Modules

Components

  • Shopify Webhooks: Triggers on events like Order Creation, Checkout, Customer Creation
  • Python API(Flask/FastAPI): Receives and validates webhook events.
  • Zoho CRM API: Stores leads, contacts, deals, and notes
  • OAuth Refresh Token Flow: Keeps Zoho API credentials valid

This modular architecture scales well and works whether you're syncing 100 or 100,000 orders per month.

Step 1: Enable Shopify Webhooks

Go to:
Shopify Admin-Settings-Notifications-Webhooks

Create a Webhook
Event: Orders Create
Format: JSON
URL: https://yourserver.com/webhooks/orders/create

Step 2: Build the Python Webhook Listener

Install dependencies:

https://yourserver.com/webhooks/orders/create
Enter fullscreen mode Exit fullscreen mode

Create a basic Flask server:

from flask import Flask, request
import requests
import json

app = Flask(__name__)

Enter fullscreen mode Exit fullscreen mode

Step 3: Validate Shopify HMAC Signature

Shopify sends an HMAC SHA56 signature with every webhook.

import hmac
import hashlib
import base64
import os

SHOPIFY_SECRET = os.getenv("SHOPIFY_SECRET")

def is_valid_hmac(data, hmac_header):
    digest = hmac.new(
        SHOPIFY_SECRET.encode(),
        data,
        hashlib.sha256
    ).digest()

    computed_hmac = base64.b64encode(digest).decode()
    return hmac.compare_digest(computed_hmac, hmac_header)
Enter fullscreen mode Exit fullscreen mode

Webhook endpoint:

@app.post("/webhooks/orders/create")
def order_created():
    data = request.data
    hmac_header = request.headers.get("X-Shopify-Hmac-Sha256")

    if not is_valid_hmac(data, hmac_header):
        return "HMAC validation failed", 401

    order = json.loads(data)
    send_order_to_zoho(order)
    return "OK", 200
Enter fullscreen mode Exit fullscreen mode

This ensures that incoming requests truly originate from Shopify

Step 4: Authenticate Zoho CRM (OAuth Refresh Flow)

Get the refresh token from;
Zoho API Console- Self Client- Generate OAuth Token

Use Python to refresh access tokens:
def get_zoho_access_token():
    url = "https://accounts.zoho.com/oauth/v2/token"
    payload = {
        "refresh_token": os.getenv("ZOHO_REFRESH_TOKEN"),
        "client_id": os.getenv("ZOHO_CLIENT_ID"),
        "client_secret": os.getenv("ZOHO_CLIENT_SECRET"),
        "grant_type": "refresh_token"
    }

    response = requests.post(url, data=payload).json()
    return response["access_token"]
Enter fullscreen mode Exit fullscreen mode

Step 5: Send Shopify Order Data to Zoho CRM

A single Shopify order can trigger:

  • A contact update
  • A deal creation
  • A note recording the purchsed items

Here is a function for creating a Lead or Contact:

def send_order_to_zoho(order):
    token = get_zoho_access_token()

    url = "https://www.zohoapis.com/crm/v2/Deals"
    headers = {"Authorization": f"Zoho-oauthtoken {token}"}

    zoho_payload = {
        "data": [
            {
                "Deal_Name": f"Order #{order['id']}",
                "Stage": "Closed Won",
                "Amount": order["total_price"],
                "Email": order["email"],
                "Description": json.dumps(order["line_items"])
            }
        ]
    }

    response = requests.post(url, json=zoho_payload, headers=headers)
    print("Zoho Response:", response.json())
Enter fullscreen mode Exit fullscreen mode

Step 6: Mapping Products and Inventory (OPTIONAL)
You can also sync SKUs, inventory, and processes into Zoho's products module.
Example:

def sync_product_to_zoho(product):
    token = get_zoho_access_token()

    url = "https://www.zohoapis.com/crm/v2/Products"
    headers = {"Authorization": f"Zoho-oauthtoken {token}"}

    payload = {
        "data": [
            {
                "Product_Name": product["title"],
                "Unit_Price": product["variants"][0]["price"],
                "SKU": product["variants"][0]["sku"]
            }
        ]
    }

    return requests.post(url, json=payload, headers=headers).json()
Enter fullscreen mode Exit fullscreen mode

Additional Enhancements

Retry Queue for Failed Syncs
Use Redis or RabbitMQ for high-volume stores.

Sync Order Fulfillments
Create Zoho notes or timeline entries.

Triggers Zoho Workflows

  • Tag VIP Customers
  • Assign leads to sales reps
  • Send WhatsApp messages via Zoho Cliq

When merchants require deep automation, they often rely on teams with strong backend and CRM expertise found in professional Shopify Store Development Services providers who specialize in complex API integrations.

Conlusion

Integrating Shopify with Zoho CRM using Python gives businesses full control over real-time data synchronization. Instead of manually exporting CSV files, this automated pipeline captures every customer, order, product, and event and sends it directly into Zoho CRM for sales, support, and lifecycle tracking. With Python handling authentication, transformations, and REST API communication, companies can build scalable workflows that grow with their ecommerce operations.

Top comments (0)