Skip to content
Google Apps Script · error message

Apps Script: Service invoked too many times in a short time

RetryableDaily and rate quotas

Last verified

The exact message
Exception: Service invoked too many times in a short time: Calendar. Try Utilities.sleep(1000) between calls.

What it means

This is a rate limit, not a daily limit. Google's quotas page says it indicates that the script called the given service too many times in a short period, and the message itself suggests pausing between calls. The service name varies with what you were calling.

Your daily quota may be nowhere near exhausted. Spacing the same calls out over time is usually enough to make them succeed.

It commonly appears in tight loops that create calendar events, send mail, or modify many Drive files back to back, and in custom functions that run in many cells at once.

What it looks like

for (const ev of events) {
  cal.createEvent(ev.title, ev.start, ev.end);
  Utilities.sleep(1000);
}

Why it happens

  • A loop calling the same service hundreds of times with no pause.
  • A custom function used in many cells, all recalculating simultaneously.
  • Several triggers firing at the same moment and hitting the same service.
  • Retry logic that retries immediately rather than backing off.

How to fix it

  1. Add Utilities.sleep between calls in the loop, as the message suggests, starting around 1000 ms.
  2. Wrap calls in retry with exponential backoff: wait 1, 2, 4, 8 seconds between attempts and stop after a few tries.
  3. Use batch-capable methods where available instead of one call per item.
  4. For custom functions, accept a range and return a 2D array so the function runs once instead of once per cell.
  5. Stagger triggers so they do not all fire on the same minute.

How to stop it recurring

Write service calls with rate in mind from the start: batch where possible, pause in loops, and centralize retries in one helper with backoff. For custom functions, design them to take ranges, which Google itself recommends to avoid repeated invocations.

Official documentation: developers.google.com/apps-script/guides/services/quotas. See all Apps Script error messages or the Apps Script limits and quotas.

Related errors

Definitions

Quick answers

What does "Service invoked too many times in a short time" mean in Apps Script?

This is a rate limit, not a daily limit. Google's quotas page says it indicates that the script called the given service too many times in a short period, and the message itself suggests pausing between calls. The service name varies with what you were calling. Your daily quota may be nowhere near exhausted. Spacing the same calls out over time is usually enough to make them succeed.

How do I fix "Service invoked too many times in a short time"?

1. Add Utilities.sleep between calls in the loop, as the message suggests, starting around 1000 ms. 2. Wrap calls in retry with exponential backoff: wait 1, 2, 4, 8 seconds between attempts and stop after a few tries. 3. Use batch-capable methods where available instead of one call per item. 4. For custom functions, accept a range and return a 2D array so the function runs once instead of once per cell. 5. Stagger triggers so they do not all fire on the same minute.

Run the job somewhere with its own limits

If a script keeps hitting its host's quotas, an Autonoly workflow can run the same steps on a schedule in an isolated cloud container, and the AI agent has a terminal with Python for steps that need code. Autonoly has limits of its own, priced in credits.

Also see Agent terminal & SSH.