Health Check Payload

When a client asks “is the thing still working?”, you want a URL you can open (or point an uptime monitor at) that answers in one line. healthCheckPayload() builds { ok, version, deployedAt, lastOk }: the version and deploy time you set in code, plus the last time your real job succeeded, read from Script Properties. Return it from doGet as JSON and you have a health check.

When to use

  • Uptime monitors (UptimeRobot, Better Stack, a cron curl) pointed at your web app
  • Answering “which version is live?” without opening the editor
  • Spotting a nightly job that quietly stopped succeeding

How to use this snippet

// Bump these when you ship a new version var APP_VERSION = '1.4.0'; var DEPLOYED_AT = '2026-10-13T18:00:00Z'; /** * Build a small, boring health payload. * lastOk is written by your real job when it succeeds (see example). * * @return {{ok: boolean, version: string, deployedAt: string, lastOk: (string|null)}} */ function healthCheckPayload() { var lastOk = PropertiesService.getScriptProperties().getProperty('LAST_OK') || null; return { ok: true, version: APP_VERSION, deployedAt: DEPLOYED_AT, lastOk: lastOk }; } function doGet() { return ContentService .createTextOutput(JSON.stringify(healthCheckPayload())) .setMimeType(ContentService.MimeType.JSON); }

Example

function nightlySync() { syncRows_(); // your job; throws on failure PropertiesService.getScriptProperties() .setProperty('LAST_OK', new Date().toISOString()); }

Opening the /exec URL now returns something like:

{"ok":true,"version":"1.4.0","deployedAt":"2026-10-13T18:00:00Z","lastOk":"2026-10-13T06:02:11.418Z"}

Tips:

  • Already using jsonOk / jsonErr? Return jsonOk(healthCheckPayload()) instead of building the ContentService output yourself.
  • Never put secrets, row counts from private data, or user emails in a health payload. Anyone with the URL can read it.
  • Only write LAST_OK after the job really finished, so a stale lastOk means something.
  • Apps Script web apps always answer HTTP 200, even for errors, so have your monitor check the body for "ok":true rather than the status code.

Tip: NitroGAS Co-Pilot can add the LAST_OK stamp to your existing job and wire up the doGet. Paste the job function.

Happy Coding!

NitroGAS Chrome Extension

Want this snippet handy inside the Apps Script editor? NitroGAS gives you free themes and snippets — plus optional Co-Pilot when you want a boost (1-week, 1-month, or yearly passes — no subscription). Happy Coding!

Get the Extension