Google Sheets Connector

The Google Sheets connector sends the SubmissionEnvelope to a Google Apps Script web app, which writes the data into a Google Sheet. This gives you a live spreadsheet of all form submissions without any server infrastructure.

Config

Field Type Required Default Description
url string Yes Published Apps Script web app URL
method string No "POST" POST or PUT
authHeader string No Value for the Authorization header (optional security layer)

How It Works

  1. A form submission arrives at the ingestion endpoint
  2. formdata.dev enqueues a delivery message for the Google Sheets destination
  3. The queue consumer sends the full SubmissionEnvelope as JSON to the Apps Script URL
  4. Your Apps Script parses the envelope and appends a row to the spreadsheet

Apps Script Setup

Follow these steps to create a Google Apps Script that receives submissions and writes them to a Google Sheet.

Step 1 — Create a Google Sheet

  1. Go to Google Sheets and create a new spreadsheet
  2. Name the first sheet (tab) Submissions
  3. Add header row in row 1:
A B C D E F
Submission ID Submitted At IP Origin Name Email

Adjust the last columns to match the fields in your form's payload.

Step 2 — Open Apps Script

  1. In your Google Sheet, go to Extensions > Apps Script
  2. Delete any existing code in Code.gs
  3. Paste the following script:
function doPost(e) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Submissions");
  var envelope = JSON.parse(e.postData.contents);

  var payload = envelope.payload || {};
  var metadata = envelope.metadata || {};

  sheet.appendRow([
    envelope.submissionId,
    metadata.submittedAt,
    metadata.ip,
    metadata.origin,
    payload.name || "",
    payload.email || "",
    payload.message || "",
  ]);

  return ContentService
    .createTextOutput(JSON.stringify({ ok: true }))
    .setMimeType(ContentService.MimeType.JSON);
}
Customize Columns

Edit the sheet.appendRow([...]) array to match the fields your form collects. The envelope.payload object contains whatever JSON the submitter sent.

Step 3 — Deploy as Web App

  1. Click Deploy > New deployment
  2. Click the gear icon next to "Select type" and choose Web app
  3. Set the following:
    • Description: formdata.dev receiver
    • Execute as: Me
    • Who has access: Anyone
  4. Click Deploy
  5. Copy the web app URL — it looks like https://script.google.com/macros/s/AKfycb.../exec
Anyone Access

Setting "Who has access" to "Anyone" means any HTTP request can trigger the script. This is required because formdata.dev's queue consumer sends the request from Cloudflare's infrastructure, not from your Google account. You can add an authHeader for extra security (see below).

Step 4 — Add the Destination

curl -X POST https://api.formdata.dev/v1/admin/forms/FORM_ID/destinations \
  -H "Content-Type: application/json" \
  -H "x-tenant-key: sk_live_abc123..." \
  -d '{
    "type": "google_sheets_webhook",
    "config": {
      "url": "https://script.google.com/macros/s/AKfycb.../exec",
      "method": "POST"
    }
  }'

Step 5 — Test

Submit a test form entry:

curl -X POST https://api.formdata.dev/v1/f/pk_YOUR_PUBLIC_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Test User",
    "email": "[email protected]",
    "message": "Hello from formdata.dev!"
  }'

Open your Google Sheet — a new row should appear within a few seconds.

Adding Authentication

For an extra layer of security, you can set an authHeader in your destination config. formdata.dev will send it as the Authorization header with every request to your Apps Script.

curl -X POST https://api.formdata.dev/v1/admin/forms/FORM_ID/destinations \
  -H "Content-Type: application/json" \
  -H "x-tenant-key: sk_live_abc123..." \
  -d '{
    "type": "google_sheets_webhook",
    "config": {
      "url": "https://script.google.com/macros/s/AKfycb.../exec",
      "method": "POST",
      "authHeader": "Bearer my-secret-token-123"
    }
  }'
Header Limitations

Google Apps Script has limited access to request headers. The Apps Script URL itself is already an unguessable shared secret, so authHeader is an optional additional layer.

Updating the Script

When you modify your Apps Script code:

  1. Go to Deploy > Manage deployments
  2. Click the pencil icon on your deployment
  3. Change Version to "New version"
  4. Click Deploy

The URL stays the same — no need to update the destination config in formdata.dev.