Get started now

Making API Calls from Zoho Deluge: Connecting Your CRM to External Systems

One of Deluge’s most powerful capabilities is the ability to call external REST APIs from within a CRM function or Creator workflow. This means a Deluge function can: query an external data enrichment service and write the results to a CRM record, send data to an external system when a deal closes, check inventory levels in an external system before generating a quote, or trigger an action in a third-party tool without any middleware. This guide covers the invokeurl syntax that makes API calls in Deluge, how to handle authentication and how to parse and use the response data. For the API integrations hub covering the full integration architecture, see the Zoho API integrations hub. For the Deluge fundamentals, see the Deluge introduction guide.

The invokeurl Block

API calls in Deluge use the invokeurl statement. The basic syntax:

// Basic GET request response = invokeurl [ url: “https://api.example.com/endpoint” type: GET connection: “connection_name” ]; // Basic POST request with parameters params = Map(); params.put(“field1”, “value1”); params.put(“field2”, “value2”); response = invokeurl [ url: “https://api.example.com/create” type: POST parameters: params.toString() connection: “connection_name” ]; // POST with JSON body and custom headers headers = Map(); headers.put(“Content-Type”, “application/json”); headers.put(“Authorization”, “Bearer ” + apiToken); response = invokeurl [ url: “https://api.example.com/json-endpoint” type: POST parameters: params.toString() headers: headers ];

Managing Authentication with Connections

For APIs that require authentication — API keys, OAuth tokens, basic auth — Zoho’s Connections feature stores credentials securely and passes them to your API calls without exposing them in your Deluge code. Connections are configured in Setup → Developer Space → Connections.

Create a Connection for the external API you are calling. The Connection stores the authentication credentials. Reference the Connection by name in your invokeurl block using the “connection” parameter. Zoho handles token refreshing for OAuth connections automatically — your Deluge code never needs to manage token lifecycle.

Parsing JSON Responses

Most modern APIs return JSON responses. Deluge’s invokeurl automatically parses JSON responses into Map objects, so you can read fields directly using .get():

// Example: call a company data enrichment API // and write results to a Zoho CRM Account record // 1. Build the request accountDomain = “example.com”; // from CRM account record response = invokeurl [ url: “https://api.clearbit.com/v2/companies/find?domain=” + accountDomain type: GET connection: “clearbit_connection” ]; // 2. Parse the response // response is already a Map if the API returns JSON companyName = response.get(“name”); employeeCount = response.get(“metrics”).get(“employees”); industry = response.get(“category”).get(“industry”); linkedInUrl = response.get(“linkedin”).get(“handle”); // 3. Write results to the CRM account record updateMap = Map(); updateMap.put(“Enriched_Employee_Count__c”, employeeCount); updateMap.put(“Enriched_Industry__c”, industry); updateMap.put(“LinkedIn_URL__c”, “https://linkedin.com/company/” + linkedInUrl); zoho.crm.updateRecord(“Accounts”, accountId, updateMap);

Handling API Errors

API calls fail — the external service is down, the request is malformed, the rate limit is exceeded. Every production Deluge API call should include error handling:

// Robust API call with error handling try { response = invokeurl [ url: “https://api.example.com/data” type: GET connection: “my_connection” ]; // Check for an error field in the response if(response.containsKey(“error”)) { info “API error: ” + response.get(“error”).get(“message”); return; // exit the function gracefully } // Process successful response data = response.get(“data”); info “API call successful. Records returned: ” + data.size(); } catch (e) { info “invokeurl failed: ” + e.get(“message”); // Optionally: create an error log record, send an alert email }

Rate Limiting Considerations

External APIs have rate limits — a maximum number of requests per second or per minute. A Deluge scheduled function that calls an external API for every record in a large dataset can exceed the API’s rate limit, causing requests to fail. For batch operations, add a delay between API calls or process records in smaller batches:

For the full API integration architecture — including bi-directional syncs, webhook patterns and the decision between Deluge API calls and the Zoho REST API — see the Zoho API integrations hub and the integration methods comparison guide.

// Process records with rate limit awareness for each record in records { // Call the external API for this record response = invokeurl [url: apiUrl type: GET connection: “my_conn”]; // Process response… // Add a brief delay between calls if needed // Note: Deluge does not have a sleep() function. // For strict rate limiting, use a smaller batch size // and schedule multiple function runs throughout the day. }

Frequently Asked Questions

Yes — Deluge’s invokeurl task can call any REST API endpoint that accepts HTTP requests. The API must be accessible from Zoho’s servers (public internet-facing) and must accept standard authentication methods (API key, OAuth, Basic auth).
OAuth connections are the recommended approach — configure the connection once in Zoho CRM’s Connections settings, then reference the connection name in your invokeurl task. API keys can be passed as headers or query parameters within the invokeurl task parameters.
Without error handling, a failed API call will cause the function to throw an error and stop execution. ABR builds production Deluge scripts with try/catch logic and fallback behaviour to handle API failures gracefully without corrupting CRM data.
Yes — Zoho imposes limits on the number of API calls a Deluge function can make per execution and per day. Scripts that need to call external APIs for large batches of records must be designed to handle pagination and respect these limits.
Yes — API-connected Deluge development is a core ABR service. Book a free consultation →