DEV Community

Cover image for Zoho Integration Services in Node.js: Fixing Expiring Webhook Channels
Sanya Mittal
Sanya Mittal

Posted on

Zoho Integration Services in Node.js: Fixing Expiring Webhook Channels

Your Deals webhook worked for exactly one hour, then Zoho CRM stopped calling your server. There was no error and no alert, only a growing gap between the CRM and your downstream database. This is a frequent silent failure in Zoho integration services built on push events. Zoho’s notification API defaults a channel to a one-hour lifetime and caps it at one day. Below, we build a Node.js receiver and a renewal job that survive both expiry and duplicate deliveries. For the wider picture, see how Zoho integration services handle real-time sync in enterprise stacks.

Context and Setup

In Zoho Integration Services you need three parts: a channel registrar, a renewal job, and an idempotent receiver. Zoho CRM’s Notifications API sends a POST to your notify_url when a watched event fires. The body carries the module, record IDs, operation, channel ID, and your token. It does not carry the full record.

Zoho’s documentation states that channel expiry can be at most one day after enabling, and defaults to one hour if omitted or set longer. The stack here is Node.js 20, Express, Redis (ioredis), and node-cron. You also need an OAuth client with the ZohoCRM.notifications.ALL scope and a public HTTPS endpoint. That endpoint is exposed to open traffic: Cloudflare’s State of Application Security report (2024) put API traffic at a median 58 percent of dynamic traffic, so verify every call.

Keeping Zoho Integration Services Alive Past Channel Expiry

Register with an explicit expiry, renew on a schedule shorter than that expiry, and backfill after any failure.

Step 1: Register the Channel With a Verification Token

Zoho echoes your token back in every callback, so the receiver can reject spoofed posts. Set the expiry yourself, because the one-hour default is the usual cause of the silence.

js
// register.js: create a channel that Zoho calls on Deals changes
export async function registerChannel(accessToken, channelId) {
// Why: stay under the 24h ceiling so Zoho keeps our expiry instead of the 1h default
const expiry = new Date(Date.now() + 23 * 3600 * 1000).toISOString();
const res = await fetch("https://www.zohoapis.com/crm/v7/actions/watch", {
method: "POST",
headers: { Authorization: Zoho-oauthtoken ${accessToken}, "Content-Type": "application/json" },
body: JSON.stringify({ watch: [{
channel_id: channelId,
events: ["Deals.create", "Deals.edit"],
channel_expiry: expiry,
token: process.env.ZOHO_NOTIFY_TOKEN, // Why: echoed back so we can verify the sender (max 50 chars)
notify_url: "https://api.example.com/zoho/notify",
}] }),
});
return res.json();
}
Step 2: Renew Early and Backfill the Gap

Renewing every six hours leaves several retry chances before the 23-hour expiry lands. If a renewal fails, assume events were missed and replay them.

js
// renew.js: extend the channel every 6 hours, replay missed changes on failure
cron.schedule("0 */6 * * *", async () => {
const token = await getAccessToken(); // assumed helper that refreshes the OAuth token
const expiry = new Date(Date.now() + 23 * 3600 * 1000).toISOString();
const res = await fetch("https://www.zohoapis.com/crm/v7/actions/watch", {
method: "PATCH", // Why: updates the existing channel instead of creating a second one
headers: { Authorization: Zoho-oauthtoken ${token}, "Content-Type": "application/json" },
body: JSON.stringify({ watch: [{ channel_id: CHANNEL_ID, channel_expiry: expiry }] }),
});
// Why: a failed renewal may hide a silent gap since the last event we saw
if (!res.ok) await backfillSince(await redis.get("last_event_at"));
});

Here backfillSince calls the Deals records endpoint with an If-Modified-Since header and queues each returned ID.

Step 3: Acknowledge Fast, Deduplicate, and Weigh the Trade-offs

Answer Zoho first, then do the work. A slow database write inside the handler turns a healthy endpoint into a retry source.

js
// receiver.js: verify, acknowledge, dedupe, enqueue
app.post("/zoho/notify", express.json(), async (req, res) => {
const { token, ids = [], operation, channel_id } = req.body;
if (token !== process.env.ZOHO_NOTIFY_TOKEN) return res.sendStatus(401); // Why: reject spoofed calls
res.sendStatus(200); // Why: ack before any slow work
await redis.set("last_event_at", new Date().toISOString());
for (const id of ids) {
// Why: NX collapses concurrent duplicate deliveries into one job
const fresh = await redis.set(dedupe:${channel_id}:${id}:${operation}, 1, "EX", 30, "NX");
if (fresh) await queue.add("sync-deal", { id });
}
});

The 30-second window has a cost: it can swallow a legitimate second edit. So the worker fetches the record and skips it only if Modified_Time is not newer than the stored value. Polling is the alternative. Zoho CRM charges one credit for most read calls, so polling one module every minute costs 1,440 calls a day before any record changes. Events cost calls only when data moves, and a light If-Modified-Since poll remains a safety net.

Real-World Application

In one of our Zoho integration services projects at [Oodles](oodles.com.

Key Takeaways
Channel expiry is the silent failure: Zoho caps it at one day and defaults to one hour, so always set it explicitly.
Renew on a schedule well under the expiry, and treat a failed renewal as a signal to backfill.
Notifications carry IDs, not records, so the worker must fetch and compare Modified_Time to stay idempotent.
A short Redis SET NX window absorbs duplicates, but only a timestamp check protects legitimate rapid edits.
Event-driven sync saves credits over fixed-interval polling, while a slow If-Modified-Since poll covers gaps.

Questions about your own sync? Share them in the comments, or talk to us about Zoho Integration services.

What are Zoho integration services?
Zoho integration services connect Zoho apps such as CRM, Books, and Desk to each other or to external systems. They use REST APIs, webhooks, and Deluge scripting to sync data, and they include authentication, error handling, and monitoring.

How long do Zoho CRM notification channels last?
Zoho CRM channels expire at most one day after you enable them. If you omit channel_expiry or set it beyond one day, Zoho applies a one-hour default. Renew on a schedule shorter than the expiry.

Do Zoho CRM webhooks include the full record?
No. The notification carries the module, record IDs, operation, channel ID, and your token. Your worker then fetches the record through the Records API. Setting return_affected_field_values to true adds changed field values to the payload.

How do you stop duplicate Zoho notifications from running twice?
Return a 200 immediately, then dedupe with a short-lived Redis key using SET NX. In the worker, compare Modified_Time with the stored value. Together they make processing idempotent even if the same event arrives twice.

Should I use polling or notifications for Zoho CRM sync?
Use notifications for freshness and credit savings, and keep a light If-Modified-Since poll as a safety net. Polling one module every minute costs 1,440 calls daily, while events cost calls only when records change.

Top comments (0)