Pauses the script for a number of milliseconds.
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
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.
Snippets using this method
Explore
Related methods
-
.jsonParse()
Parses a JSON string into a JavaScript object.
-
.formatDate()
Formats a date using a pattern and time zone.
-
.base64Encode()
Encodes a string or bytes as Base64.
-
.base64Decode()
Decodes a Base64 string back into raw data.
-
.jsonStringify()
Converts a JavaScript object into a JSON string.
More Apps Script
Better Sheets tutorials
How to Format Timestamp to Day and Month
Related blog posts
Written guides about Utilities.sleep().
What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →How to Send Google Forms Entries Automatically with Apps Script
Google Forms provides basic email notifications for form submissions, but enhancing these notifications with detailed summaries can significantly improve productivity and response management.
Read post →Explore Coding in Google Sheets
Did you know you can actually code in Google Sheets?
Read post →