Author: By Raj

Part of our Apps Script Web Apps guides. Need this built for your team? Hire a Google Apps Script developer.

Estimated reading time: 10 minutes

doGet vs doPost in Google Apps Script: Complete Reference

doGet handles HTTP GET, browser navigation, query parameters, and JSON APIs returning ContentService.createTextOutput. doPost handles POST bodies from forms and webhooks.

The event object e carries parameter (query or form fields) and postData (raw body, type, headers) for POST. Always return a TextOutput or HtmlOutput, never bare strings.

Deployment execute-as settings change whose Drive and Gmail access apply, document for security reviews alongside /blog/apps-script-user-authentication.

doGet parameters and JSON APIs

e.parameter.id reads ?id=123. Return JSON with MimeType.JSON for mobile apps consuming your web app as API.

Set Cache-Control via headers only if you control clients, Apps Script caching is limited.

doPost bodies

JSON: JSON.parse(e.postData.contents). Form: e.parameter.field. Multipart rare, prefer JSON for webhooks.

Return 200 quickly for Stripe/Shopify webhook acks, see /blog/apps-script-webhook-receiver.

CORS and external sites

Browser fetch from other domains to web app may fail without CORS headers, Apps Script has limited CORS support; prefer server-to-server calls.

Intranet pages on same domain subpaths still iframe better than cross-origin fetch.

Error responses

Return createTextOutput(JSON.stringify({error:'...'})).setMimeType(JSON) with appropriate HTTP status by documenting codes in client, even though setResponseCode is not available like Node.

Log server-side in Executions; clients only see returned body.

Example code

function doGet(e) {
  const action = (e && e.parameter && e.parameter.action) || 'health';
  if (action === 'health') {
    return ContentService.createTextOutput(JSON.stringify({ ok: true }))
      .setMimeType(ContentService.MimeType.JSON);
  }
  return ContentService.createTextOutput('Not found');
}
ApproachBest forTradeoff
Apps Script nativeGoogle Workspace-centric workflows6-min limit, quotas
Zapier / MakeNo-code, many connectorsPer-task cost, vendor lock-in
Python + CloudHeavy data / MLHosting cost, separate auth
Apps Script web app developmentProduction custom logicBuild cost, you own code

FAQ

Can one project have both doGet and doPost?

Yes in the same script file. Deployment URL serves both methods on one endpoint.

Why is e undefined in manual run?

Running doGet from editor without mock event, pass test object {parameter:{id:'1'}} when debugging.

Maximum POST size?

Large payloads can fail, accept webhook, store ID only, fetch details via API afterward.

GET vs POST for CRUD?

Use POST for mutations even if GET is easier, caches and prefetch break GET side effects.

Web app vs API executable?

Web app for HTTP; API executable for google.script.run only, not interchangeable URLs.

Need this done for you? I handle this as part of my consulting work, fixed-price quote within 24 hours.

Book a call with Raj →

Get the full doGet vs doPost in Google Apps Script script template

I'll email you a production-ready, commented version you can deploy in 10 minutes.

Need help with this? I handle this as part of my Apps Script Web Apps service.

Internal tools, CRUD apps, HtmlService UIs, and Google SSO.

See how it works →