class Utilities method .sleep()

Utilities is the Apps Script service.

.sleep() is the method name you will see after a dot in your code.

What it does

Pauses the script for a number of milliseconds.

Why it's used

  • Pause between API calls to respect rate limits.
  • Wait a second before retrying a flaky request.

Common errors

  • Forgetting parentheses on sleep. Write Utilities.sleep(), not Utilities.sleep or sleep by itself.
  • Skipping dots between chained calls. Each step needs a dot, like Utilities.sleep().
  • Adding spaces where they do not belong. Write Utilities.sleep(), not Utilities .sleep(), Utilities.sleep (), or Utilities . sleep().
  • Wrong capitalization. Use Utilities and sleep, not utilities or sleep.

Explore

Related methods

Better Sheets tutorials

How to Format Timestamp to Day and Month

How to Format Timestamp to Day and Month

Create a formatted timestamp to the full name of the day and month. Form...
How to Power Testimonials with Google Forms and Sheets

How to Power Testimonials with Google Forms and Sheets

I show you how I use a Google Form and a Google Sheet to power the testi...

Related blog posts

Written guides about Utilities.sleep().

Browse the blog