To send webhooks from Google Sheets, you write a short Apps Script function that posts a row as JSON with UrlFetchApp, and attach it to an installable edit trigger. In this tutorial you will build one that fires when a lead’s status changes to “Ready”, marks the row as sent so it never fires twice, and adds a secret header your receiver can check.
Quick answer: In Extensions > Apps Script, write a function that reads the edited row and calls UrlFetchApp.fetch(url, {method: "post", payload: JSON.stringify(data)}). Run it on an installable On edit trigger, because a simple onEdit trigger is not allowed to make external requests.
- Set up a sheet with a Status column and a “Webhook Sent” column.
- Paste the sender script, run it once and approve the permissions.
- Add an installable On edit trigger that calls the filtering function.
- Mark each sent row “SENT” so re-edits do not send it again.
- Store a shared secret in Script Properties and send it in a header.
In this guide
- Before You Start
- Step 1: Prepare Your Google Sheet
- Step 2: Write the Webhook Sender
- Step 3: Test the Script Manually
- Step 4: Run It Automatically With an Installable Trigger
- Step 5: Filter Edits and Prevent Duplicate Sends
- Step 6: Add a Shared Secret Header
- If It Still Doesn’t Work
- Frequently Asked Questions
- Next Steps

A typical case: you need to send an HTTP POST to your CRM, a chat tool or your own backend every time a teammate marks a lead as “Ready” in a shared sheet. Apps Script handles this well, but if you ignore its trigger restrictions and permission rules, the script fails in the background without telling you.
Before You Start
- A receiver URL: your backend’s endpoint, or a temporary webhook testing site while you build. The script sends real row data, so do not point it at a URL you do not control.
- A Google Sheet you can edit, and the Apps Script editor under Extensions > Apps Script.
- Time: about 20 minutes.
Step 1: Prepare Your Google Sheet
Apps Script reads rows as arrays, so predictable headers save you parsing work. Set up a new Google Sheet, rename its first tab to Leads (the trigger code further down looks for that name), and add these five columns in row 1:
- ID (Column A)
- Name (Column B)
- Email (Column C)
- Status (Column D)
- Webhook Sent (Column E)
Do not skip the fifth column (“Webhook Sent”). Without a flag that marks which rows have already been sent, your script will eventually send the same row twice. It also shows you at a glance, in the sheet, that the webhook fired.
Add a couple of test rows. Set one status to “Pending” and another to “Ready”, and leave “Webhook Sent” blank for now.
Step 2: Write the Webhook Sender
In your Google Sheet, go to Extensions > Apps Script. The editor opens with a default Code.gs file; delete the placeholder code in it.
HTTP requests go through Google’s UrlFetchApp class, which handles POST, GET, PUT and other methods. The function below reads the row you have selected, packages the cell values as JSON and posts them to your endpoint. Paste it into Code.gs and replace the URL with your receiver’s:
function sendRowWebhook() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const activeRow = sheet.getActiveCell().getRow();
// Prevent running on the header row
if (activeRow === 1) {
Logger.log("Cannot send webhook for header row.");
return;
}
// Fetch columns A through E for the active row
const rowData = sheet.getRange(activeRow, 1, 1, 5).getValues()[0];
const payload = {
id: rowData[0],
name: rowData[1],
email: rowData[2],
status: rowData[3],
timestamp: new Date().toISOString()
};
// Replace with your actual receiver URL
const url = "https://your-api-endpoint.com/webhook";
const options = {
method: "post",
contentType: "application/json",
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
try {
const response = UrlFetchApp.fetch(url, options);
Logger.log("Response Code: " + response.getResponseCode());
Logger.log("Response Body: " + response.getContentText());
} catch (err) {
Logger.log("Error occurred: " + err.toString());
}
}This grabs the active row, pulls columns A through E, and maps them into a JSON payload. Note the muteHttpExceptions: true option. By default, a 400 or 500 response from your server makes Apps Script throw an error and stop. With this option, the script receives the response instead, so it can log the status code and body for debugging.
Step 3: Test the Script Manually
Check that the network call works before you automate it:
- In the sheet, click any cell in one of your test rows (not row 1).
- In the editor, save the project (
Ctrl+SorCmd+S), selectsendRowWebhookfrom the function drop-down at the top, and click Run. - On the first run, Google shows an “Authorization required” dialog, because the script reads your spreadsheet and calls an external URL. Click Review Permissions, select your Google account, click Advanced, then Go to Untitled project (unsafe), and click Allow. Google shows this warning for every unverified script, including your own.
When the run finishes, open the Execution log at the bottom of the editor. If it worked, it shows Response Code: 200 (or another 2xx code) followed by your endpoint’s response body, and the request appears at your receiver.
To inspect payloads without building a backend yet, use a temporary webhook testing site. To send them to a development server on your own machine instead, see how to test webhooks locally with Cloudflare Tunnels.
Step 4: Run It Automatically With an Installable Trigger
Clicking Run by hand is not automation. You want the webhook to fire whenever someone edits the sheet. Apps Script has two kinds of triggers: simple triggers and installable triggers.
A simple trigger, a function named onEdit(e), looks perfect but has a catch: simple triggers cannot use services that require authorization. UrlFetchApp is one of them, so a request from inside a simple onEdit(e) fails with a permission error that you only see on the Executions page.
An installable trigger runs with the permissions of the person who created it, so it can make external HTTP requests. To set one up:
- In the Apps Script editor, click the clock icon (Triggers) on the left sidebar.
- Click the + Add Trigger button in the bottom right.
- Under “Choose which function to run”, select
handleSheetEdit(you add this function in the next step; you can also create the trigger after pasting it). - Under “Select event source”, choose From spreadsheet.
- Under “Select event type”, choose On edit.
- Click Save and authorize the permissions if prompted.
For the full list of trigger types and their limits, see the official Google Apps Script Triggers documentation.
Step 5: Filter Edits and Prevent Duplicate Sends
An On edit trigger fires on every edit, anywhere in the spreadsheet. Left unfiltered, the script would send a webhook for every change and use up your URL Fetch quota. One thing you do not have to worry about is an infinite loop: changes made by a script, such as writing “SENT” back to column E, do not fire edit triggers. Only edits made by a person do.
The function below ignores every edit except a change to “Ready” in the Status column of the Leads tab, and skips rows already marked as sent. Paste it into the same Code.gs file, replace the URL, and save:
function handleSheetEdit(e) {
// Safety check for manual runs without event objects
if (!e) {
Logger.log("No event object detected. Run this by editing the spreadsheet.");
return;
}
const range = e.range;
const sheet = range.getSheet();
// 1. Only run on the "Leads" sheet
if (sheet.getName() !== "Leads") {
return;
}
const row = range.getRow();
const col = range.getColumn();
// 2. Only run if the "Status" column (Column 4 / D) was edited, below the header row
if (col !== 4 || row === 1) {
return;
}
const statusValue = range.getValue();
// 3. Only run if status is set to "Ready"
if (statusValue !== "Ready") {
return;
}
// 4. Check if we already sent a webhook for this row
const statusCell = sheet.getRange(row, 5); // Column E
if (statusCell.getValue() === "SENT") {
Logger.log("Webhook already sent for row " + row + ". Skipping.");
return;
}
// Fetch row details
const rowData = sheet.getRange(row, 1, 1, 4).getValues()[0];
const payload = {
id: rowData[0],
name: rowData[1],
email: rowData[2],
status: rowData[3]
};
const url = "https://your-api-endpoint.com/webhook";
const options = {
method: "post",
contentType: "application/json",
payload: JSON.stringify(payload),
muteHttpExceptions: true
};
try {
const response = UrlFetchApp.fetch(url, options);
const code = response.getResponseCode();
if (code >= 200 && code < 300) {
// Mark as sent so the row is not sent again when someone re-edits it
statusCell.setValue("SENT");
Logger.log("Webhook successfully sent for row " + row);
} else {
Logger.log("Receiver returned status " + code + ": " + response.getContentText());
}
} catch (err) {
Logger.log("HTTP request failed: " + err.toString());
}
}Make sure your installable trigger points at handleSheetEdit, not at the manual sendRowWebhook. The function checks that the edit happened on the “Leads” tab, that column D (Status) changed, that the new value is “Ready”, and that column E is not already “SENT”. Only then does it send the webhook.
To test it, change a row’s status to Ready. If it worked, column E of that row shows SENT within a few seconds, and the Executions page lists a completed handleSheetEdit run. Note that Logger.log messages from triggered runs appear in that run’s entry on the Executions page, not in the editor’s Execution log.
Step 6: Add a Shared Secret Header
Without verification, anyone who finds your receiver’s URL could send it fake data. Include a shared secret token in a request header, and have the receiver reject requests without it.
Do not hardcode the secret in the script. Store it with Google’s Properties Service, which works like an environment variable store and keeps keys out of your source code:
- In the Apps Script editor, click the gear icon (Project Settings) on the left menu.
- Scroll down to the Script Properties section.
- Click Add script property.
- Set the Property name to
WEBHOOK_SECRETand paste your secure token as the Value. - Click Save script properties.
Then change the options object in handleSheetEdit to read the secret and send it in a custom header such as X-Webhook-Secret. Custom headers on a POST request are standard HTTP; see the MDN POST request guidelines. Replace the existing const options = {…} block with this one:
const secretToken = PropertiesService.getScriptProperties().getProperty("WEBHOOK_SECRET");
const options = {
method: "post",
contentType: "application/json",
headers: { "X-Webhook-Secret": secretToken || "" },
payload: JSON.stringify(payload),
muteHttpExceptions: true
};On your receiving server, check this header before processing the payload. If it is missing or does not match your secret, reject the request with a 401 Unauthorized response. For stronger protection, sign the body instead (Apps Script can compute an HMAC with Utilities.computeHmacSha256Signature) and check the signature on the receiver, as shown in verifying webhook signatures with HMAC in Node.js.
If It Still Doesn’t Work
Start with the Executions page (the list icon in the left menu). It shows every run, how long it took, and whether it succeeded. Click a failed run to see its error and log lines. Then check these common causes:
- Nothing happens when you set a row to “Ready”: the trigger is missing, points at the wrong function, or the value is not exactly
Ready(the check is case-sensitive and a trailing space breaks it). A drop-down in column D avoids typos. - The row is not marked “SENT”: the receiver answered with a non-2xx code. The run’s log shows
Receiver returned statuswith the code and body. A400 Bad Requestusually means the receiver’s schema does not match the payload. - Permission error mentioning
UrlFetchApp.fetch: the code is running from a simpleonEditfunction. Rename or delete it and use the installable trigger. - Timeouts: Apps Script limits each run to 6 minutes (simple triggers get only 30 seconds), and slow receivers make each edit slow too. Have the receiver return a 2xx response right away and do its processing in the background.
- Rows added by a form, another script or the Sheets API never send: those changes do not fire edit triggers. Use an On form submit or time-driven trigger for them instead.
- Empty fields in the payload: blank cells arrive as empty strings. Make sure your receiver accepts empty fields without crashing.
Frequently Asked Questions
Why does my script fail with “You do not have permission to call UrlFetchApp.fetch”?
Because the call is running inside a simple trigger such as onEdit(e). Simple triggers run without your authorization, so Google blocks them from services that need it, including external requests. Delete or rename the simple onEdit function and create an installable On edit trigger from the Triggers page instead.
Can I send webhooks in bulk if I update multiple rows at once?
Yes, but you have to loop. If you paste data into several cells at once, the installable edit trigger fires only once, and e.range covers the whole pasted block. The script above only processes the top-left cell, so loop over e.range.getNumRows() rows and send a payload for each.
What are the daily rate limits for sending webhooks from Apps Script?
Google limits UrlFetchApp calls per day. Consumer (Gmail) accounts can make 20,000 requests per day, and Google Workspace accounts up to 100,000. If you expect to exceed that, batch several rows into one request and send them from a scheduled time-driven trigger instead of an edit trigger.
How do I handle JSON responses returned by my webhook receiver?
Parse the response body with JSON.parse() and write the value you need back to the sheet. Inside handleSheetEdit, where sheet and row already exist, it looks like this:
const response = UrlFetchApp.fetch(url, options);
if (response.getResponseCode() === 200) {
const responseData = JSON.parse(response.getContentText());
// Write returned ID from backend to column F
sheet.getRange(row, 6).setValue(responseData.external_id);
}Next Steps
Once your sheet sends webhooks reliably, point it at your real receiver and add the secret check there. To post the same rows to a chat channel, follow the Google Sheets to Discord webhook tutorial. To pull external data back into a sheet instead, learn how to fetch paginated API data in Google Apps Script.

