How to Call a REST API in Deluge: A Practical Guide (with invokeUrl Examples)
- 2 days ago
- 3 min read
Updated: 3 hours ago

Calling a REST API in Deluge means sending an HTTP request from a Deluge script to an external service and working with the response inside Zoho, and the task that does it is invokeUrl. Whether you are wiring Zoho CRM to a shipping provider or pulling data into Creator, this is the pattern we reach for on almost every custom software development integration, and it replaces the older getUrl and postUrl functions with one unified task.
Zoho now serves more than one million paying customers and over 150 million users worldwide (Zoho, February 2026), so odds are the external system you need to reach already has a REST API waiting. Here is how to talk to it.

How to call a REST API in Deluge: the invokeUrl task
Every call has the same shape. You assign the result of invokeUrl to a variable, then pass a set of named keys inside square brackets:
response = invokeUrl
[
url: "https://api.example.com/v1/status"
type: GET
headers: {"Authorization": "Bearer YOUR_TOKEN"}
];
info response;The keys that matter most:
url — the endpoint you are calling.
type — the HTTP method: GET, POST, PUT, PATCH, or DELETE. It defaults to GET.
headers — a Map of header keys and values, including auth and content-type.
body or parameters — the payload. You cannot use both in the same call.
connection — an optional named connection that handles OAuth for you.
When detailed is left at its default of false, the response comes back as just the content (a Map or List if the body is JSON). Set detailed:true and you instead get a Map with responseCode, responseHeader, and responseText — which is what you want for real error handling.
Sending a POST with a JSON body
For a POST, build a Map, convert it to a JSON string with toString(), and set the content type header. The response parses straight into a Map, so you read a field with a simple get().
payload = Map();
payload.put("name", "Ada Lovelace");
payload.put("email", "ada@example.com");
response = invokeUrl
[
url: "https://api.example.com/v1/contacts"
type: POST
headers: {"Authorization": "Bearer YOUR_TOKEN", "content-type": "application/json"}
body: payload.toString()
];
new_id = response.get("id");
info new_id;A few things worth internalizing. The body key sends a raw payload, while parameters sends form or query values — mixing them up is the most common reason a call quietly fails. And because the auth header is spelled out here, this is a good moment to point developers toward Zoho's business systems integration practices before secrets end up hardcoded across a dozen functions.
Handling errors instead of hoping
A 200 is never guaranteed. Use detailed:true so you can check the status code and read the raw body before trusting the data. We have seen more than one production automation break silently because it assumed the API always returned a clean Map — until the day the endpoint returned a 429 and the script tried to get() a key that was not there.
response = invokeUrl
[
url: "https://api.example.com/v1/contacts"
type: GET
headers: {"Authorization": "Bearer YOUR_TOKEN"}
detailed: true
];
status = response.get("responseCode");
if(status == 200)
{
data = response.get("responseText");
info data.get("email");
}
else
{
info "API error: " + status + " - " + response.get("responseText");
}Wrap that check around every call and your integrations degrade gracefully instead of throwing cryptic runtime errors. For the auth side of the equation, our Zoho engineering team leans on named connections rather than raw bearer tokens, so credentials rotate in one place instead of a hundred.
A short checklist before you ship
Run through this every time you write a new call:
Set type explicitly — do not rely on the GET default when you mean POST.
Match your content-type header to the body (JSON needs application/json).
Choose body or parameters, never both.
Use detailed:true and check responseCode for anything that touches customer data.
Prefer a connection over pasted tokens so auth is centralized and rotatable.
Log the response with info during development, then trim it out.
If you want a deeper walkthrough of the language itself, our Zoho Deluge scripting examples and the seven Deluge lessons we learned the hard way cover the patterns that keep these scripts maintainable.
The takeaway
Calling a REST API in Deluge comes down to one task, invokeUrl, plus disciplined error handling. Set the method and headers deliberately, send JSON as a stringified Map through body, read the result as a Map, and always verify responseCode before you use the data. Get those habits right and you can connect Zoho to almost anything. If you would rather have experienced engineers build and harden the integration for you, book a free Zoho consultation and we will map it out with you.
By the CodeStringers Team — Zoho Experts & Custom Software. CodeStringers is a custom software engineering firm writing from work we've actually shipped for clients.



































Comments