What is UrlFetchApp in Google Sheets?

UrlFetchApp lets Apps Script send HTTP requests to external URLs and read the response. You use it to pull data from APIs, post webhooks, or sync sheet rows with tools like Slack, Stripe, or your own server. It is the bridge between your spreadsheet and the rest of the web.

When to use it

Use UrlFetchApp when sheet data must talk to an outside system: fetch exchange rates, push new leads to a CRM, call a REST API on a schedule, or verify a license key.

When to skip it

Skip UrlFetchApp when a built-in function like IMPORTXML or GOOGLEFINANCE is enough, or when a no-code connector handles the integration with less code to maintain.

How it works

  1. 1

    Build a URL and optional options object with method, headers, payload, or muteHttpExceptions.

  2. 2

    Call UrlFetchApp.fetch(url, options) and read the response with getContentText() or getBlob().

  3. 3

    Parse JSON with JSON.parse when the API returns JSON.

  4. 4

    Run once manually to authorize external request permissions.

  5. 5

    Wrap calls in try/catch and log status codes when muteHttpExceptions is true.

  6. 6

    Respect daily UrlFetch quotas and avoid tight loops that hammer the same endpoint.

Examples in Google Sheets

Daily rate lookup

A time-driven trigger fetches a JSON rate from a public API and writes the value to a Rates tab for formulas to reference.

Webhook on new row

onFormSubmit posts e.values as JSON to your server webhook URL so a database updates when a form arrives.

Slack alert

When a status cell changes to Urgent, UrlFetchApp posts a short message payload to a Slack incoming webhook URL.

Build this without starting from a blank cell

Use a Better Sheets tool for UrlFetchApp, then watch a walkthrough when you want the full pattern.

Better Sheets resources

Common mistakes

  • Storing API keys in client-side HTML where anyone can view source instead of Script Properties.
  • Calling UrlFetchApp inside onEdit on every keystroke, slowing editors and burning quota.
  • Not setting muteHttpExceptions, so a 404 throws and stops the whole script.
  • Forgetting Content-Type application/json when posting JSON bodies.
  • Parsing response text as JSON without checking for empty or HTML error pages first.

Frequently asked questions

Can UrlFetchApp do POST requests?
Yes. Pass method POST and a payload string or object in the options parameter.
Do I need to enable an API in Cloud Console?
Basic UrlFetchApp works without extra setup. Some Google APIs need enabling under Advanced Google services.
What are UrlFetchApp quotas?
Google limits URL fetches per day per account. Check current Apps Script quota documentation for your account type.
Can UrlFetchApp send headers?
Yes. Include an headers object in options, for example Authorization Bearer tokens or API keys.
Why does my fetch return authorization errors?
The remote server may reject your token, block Google IPs, or require OAuth you have not implemented.
Can I download a file with UrlFetchApp?
Yes. Use getBlob() on the response and save with DriveApp or attach via MailApp.
Is UrlFetchApp allowed in simple triggers?
Simple triggers like onEdit cannot call UrlFetchApp. Use an installable trigger after authorization.
How do I debug API responses?
Logger.log the status code and first part of getContentText(), or write failures to a Debug tab with timestamps.

Related Tutorials

Watch how UrlFetchApp works

Browse more tutorials
Spreadsheet Automation 101 Lesson 4: UrlFetchApp

Spreadsheet Automation 101 Lesson 4: UrlFetchApp

Use any URL to scrape the web or access an API and get that info into yo...
Convert Google Sheets into a REST API

Convert Google Sheets into a REST API

How to use Google Sheets as a database by turning it into a REST API wit...
Quickstart Tutorial OpenAI API in Google Sheets

Quickstart Tutorial OpenAI API in Google Sheets

Use the power of OpenAI's GPT-3 inside of Google Sheets. In this quick s...
Automatic Screenshots in Apps Script

Automatic Screenshots in Apps Script

Scrape Google Maps

Scrape Google Maps

Scrape any query in Google Maps into your Google Sheets. Enter your API ...
Curate Google Sheets Easily - Automatic Bookmarklet Maker

Curate Google Sheets Easily - Automatic Bookmarklet Maker

Curated sites, articles, and more web resources super easily into a Goog...

Related blog posts

Guides that explain UrlFetchApp in more depth.

Browse the blog

Related glossary terms

Done reading about UrlFetchApp?

Membership unlocks 636+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.

Need this once

Jump to a free tool or a single tutorial for this topic.

Learning Sheets for real

Unlock the full library, generators, and templates with membership.