All connectors

Google Sheets

Official

Google Sheets

Let agents look up figures, keep trackers up to date and build reports in your spreadsheets.

  • Read single cells, ranges or several tabs at once, as displayed, as raw numbers or as formulas.
  • See a spreadsheet's tabs, their sizes and its named ranges.
  • With Write access: write and clear cells, add rows to logs and tables, create spreadsheets, and add or rename tabs, sort data and format cells.

Agents work with a spreadsheet when you share its link. To let them search your Drive for spreadsheets, also connect Google Drive. Read access cannot change your spreadsheets.

Setup instructions

Connect your Google account

  1. Choose the level for Access:
    • Read to let agents read spreadsheets without changing anything.
    • Write to also let agents edit cells, add rows, create spreadsheets and change tabs and formatting.
  2. Select Continue with Google, choose your account, and approve the permissions Google lists. If Google shows a checkbox per permission, tick them all: Houston refuses a partial grant.

The connection can open every spreadsheet your Google account can open, but nothing else in your Drive; connecting Google Sheets does not grant access to your other Google services.

Advanced: changing access and troubleshooting
  • To change the access level, edit the connection and connect with Google again. Google then asks for the new set of permissions.
  • To revoke access, remove the connection in Houston, or remove Houston from your Google Account's third-party connections.
  • Google Workspace administrators can block third-party apps. If Google refuses the connection, ask your administrator to allow Houston.
  • An agent that cannot open a spreadsheet may be using a link from Publish to the web. Share the spreadsheet's normal link instead, from the address bar while it is open.
  • Excel files stored in Drive open in Sheets but cannot be read by agents. Convert one with File > Save as Google Sheets and share the new link.

Files

  • connector.luau
    -- Google Sheets API v4. Arguments and results keep Google's native field names.
    local API = "https://sheets.googleapis.com/v4"
    
    -- Request layer shared verbatim by the Google connectors (tools/validate checks they match).
    type Options = {[string]: any}
    type Endpoint = {method: string, path: string, access: string?, query: {string}?, body: boolean?, defaults: Options?, list: string?, required: {[string]: string}?, help: string}
    
    local function text(value: any, field: string): string
    	assert(type(value) == "string" and value ~= "", field .. " must be a nonempty string")
    	return value
    end
    
    local function options(value: any): Options
    	if value == nil then return {} end
    	assert(type(value) == "table", "opts must be an object")
    	for key in value do assert(type(key) == "string", "opts must have named fields") end
    	return table.clone(value)
    end
    
    -- Moves the named fields from args into a query string; arrays repeat the key.
    local function query(args: Options, names: {string}): string
    	local parts: {string} = {}
    	for _, name in names do
    		local value = args[name]
    		args[name] = nil
    		for key, item in (if type(value) == "table" then value else {value}) do
    			assert(type(key) == "number" and (type(item) == "string" or type(item) == "number" or type(item) == "boolean"), name .. " must be a string, number, boolean or an array of them")
    			table.insert(parts, url.encode(name) .. "=" .. url.encode(item))
    		end
    	end
    	return if #parts > 0 then "?" .. table.concat(parts, "&") else ""
    end
    
    -- Older APIs name the reason in errors[], newer ones in an ErrorInfo detail.
    local function reasonOf(problem: any): string?
    	for _, list in {problem.errors, problem.details} :: {any} do
    		if type(list) == "table" then
    			for _, item in list do
    				if type(item) == "table" and type(item.reason) == "string" then return item.reason end
    			end
    		end
    	end
    	return nil
    end
    
    local function fail(operation: string, response: HttpResponse): never
    	local ok, decoded = pcall(json.decode, await(response.body:readPrefix(4096)))
    	local problem = if ok and type(decoded) == "table" and type(decoded.error) == "table" then decoded.error else {}
    	local reason = reasonOf(problem)
    	local message = "Google HTTP " .. tostring(response.statusCode)
    	if type(problem.status) == "string" then message ..= " (" .. problem.status .. ")" end
    	if type(problem.message) == "string" then message ..= ": " .. string.sub(problem.message, 1, 600) end
    	if reason then message ..= " [" .. reason .. "]" end
    	local retry = response.headers["retry-after"]
    	if retry and retry[1] then message ..= "; Retry-After: " .. retry[1] end
    	local limited = reason ~= nil and string.find(string.lower(reason), "ratelimitexceeded", 1, true) ~= nil
    	return houston.fail({operation = operation, layer = "upstream", upstream_status = response.statusCode,
    		retryable = response.statusCode == 429 or response.statusCode >= 500 or limited, message = message})
    end
    
    local function decode(operation: string, response: HttpResponse): any
    	if response.statusCode < 200 or response.statusCode >= 300 then fail(operation, response) end
    	local raw = await(response.body:readAll())
    	if raw == "" then return {success = true} end
    	local ok, value = pcall(json.decode, raw)
    	if not ok or type(value) ~= "table" or not string.match(raw, "^%s*{") then
    		houston.fail({operation = operation, layer = "upstream", upstream_status = response.statusCode,
    			retryable = false, message = "Google returned an invalid JSON object"})
    	end
    	return value
    end
    
    local function call(operation: string, method: string, href: string, body: any?): any
    	return decode(operation, await(http.request({method = method, url = href,
    		headers = if body ~= nil then {["Content-Type"] = {"application/json"}} else nil,
    		body = if body ~= nil then json.encode(body) else nil})))
    end
    
    -- Accepts a docs.google.com editor URL in place of its file ID; published and responder links (/d/e/...) carry no ID.
    local function docsId(value: any, product: string, field: string): any
    	if type(value) ~= "string" then return value end
    	local rest = string.match(value, "^https://docs%.google%.com/" .. product .. "/d/(.*)$")
    		or string.match(value, "^https://docs%.google%.com/" .. product .. "/u/%d+/d/(.*)$")
    		or string.match(value, "^https://docs%.google%.com/a/[^/]+/" .. product .. "/d/(.*)$")
    	local id: string = if rest then string.match(rest, "^[^/?#]*") or "" else value
    	assert(string.match(id, "^[%w_%-]+$") and id ~= "e", field .. " must be an ID or its https://docs.google.com/" .. product .. "/d/<id> URL")
    	return id
    end
    
    -- Moves {placeholders} and declared query fields from args into the URL; remaining fields form the JSON body.
    local function target(name: string, endpoint: Endpoint, args: Options): string
    	local defaults: Options = endpoint.defaults or {}
    	for key, value in defaults do
    		if args[key] == nil then args[key] = value end
    	end
    	local required: {[string]: string} = endpoint.required or {}
    	for field, kind in required do
    		local value = args[field]
    		assert(if kind == "array" then type(value) == "table" and value[1] ~= nil elseif kind == "string" then type(value) == "string" and value ~= "" elseif kind == "object" then type(value) == "table" and next(value) ~= nil and value[1] == nil else false,
    			name .. " requires " .. field .. " as a nonempty " .. kind)
    	end
    	local path = string.gsub(endpoint.path, "{(%w+)}", function(field: string)
    		local value = url.segment(text(args[field], field), field)
    		args[field] = nil
    		return value
    	end)
    	path ..= query(args, endpoint.query or {})
    	if not endpoint.body then assert(next(args) == nil, name .. " received an unknown option") end
    	return API .. path
    end
    
    local function invoke(name: string, endpoint: Endpoint, input: any): any
    	local args = options(input)
    	local result = call(name, endpoint.method, target(name, endpoint, args), if endpoint.body then args else nil)
    	if endpoint.list and result[endpoint.list] == nil then result[endpoint.list] = json.decode("[]") end
    	return result
    end
    
    local exports: {[string]: any} = {}
    local help: {[string]: string} = {}
    
    -- Exposes an operation when the connection allows the access it needs, if any.
    local function export(name: string, access: string?, fn: (any) -> any, doc: string)
    	if access == nil or houston.allows(access) then
    		exports[name], help[name] = fn, doc
    	end
    end
    
    local function exportEndpoints(endpoints: {[string]: Endpoint})
    	for name, endpoint in endpoints do
    		export(name, endpoint.access, function(args: Options?): any return invoke(name, endpoint, args) end, endpoint.help)
    	end
    end
    
    -- help() introduces the API, then documents exactly the configured operations.
    local function helpWith(overview: {string}): () -> string
    	return function(): string
    		local names: {string} = {}
    		for name in help do table.insert(names, name) end
    		table.sort(names)
    		local lines = table.clone(overview)
    		for _, name in names do table.insert(lines, help[name]) end
    		return table.concat(lines, "\n")
    	end
    end
    -- End of the shared request layer.
    
    local SPREADSHEET_FIELDS = "spreadsheetId,spreadsheetUrl,properties(title,locale,timeZone),sheets.properties,namedRanges"
    local READ_QUERY = {"majorDimension", "valueRenderOption", "dateTimeRenderOption"}
    local WRITE_QUERY = {"valueInputOption", "includeValuesInResponse", "responseValueRenderOption", "responseDateTimeRenderOption"}
    local RAW = {valueInputOption = "RAW"}
    local APPEND_QUERY = table.clone(WRITE_QUERY)
    table.insert(APPEND_QUERY, "insertDataOption")
    local endpoints: {[string]: Endpoint} = {
    	getSpreadsheet = {method = "GET", path = "/spreadsheets/{spreadsheetId}", defaults = {fields = SPREADSHEET_FIELDS}, list = "namedRanges",
    		query = {"fields", "ranges", "excludeTablesInBandedRanges"},
    		help = "getSpreadsheet({spreadsheetId, fields?, ranges?}) -> {spreadsheetId, spreadsheetUrl, properties, sheets=[{properties={sheetId, title, index, gridProperties={rowCount, columnCount, ...}}}], namedRanges}. Lists the tabs and their sizes; namedRanges is [] when there are none. fields is a Google field mask: e.g. fields='sheets(data(rowData(values(formattedValue,note,hyperlink))))' with ranges={'Sheet1!A1:C3'} reads cell notes and links. Always pass ranges with data fields: responses over 8 MiB fail."},
    	getValues = {method = "GET", path = "/spreadsheets/{spreadsheetId}/values/{range}", list = "values", query = READ_QUERY,
    		help = "getValues({spreadsheetId, range, valueRenderOption?, dateTimeRenderOption?, majorDimension?}) -> {range, majorDimension, values}. One cell: getValues({spreadsheetId=..., range='Sheet1!B2'}).values[1] is {'42'}, or nil when B2 is empty."},
    	batchGetValues = {method = "GET", path = "/spreadsheets/{spreadsheetId}/values:batchGet", list = "valueRanges", required = {ranges = "array"},
    		query = {"ranges", table.unpack(READ_QUERY)},
    		help = "batchGetValues({spreadsheetId, ranges={'Sheet1!A1:B2', 'Totals!C3'}, valueRenderOption?, dateTimeRenderOption?, majorDimension?}) -> {spreadsheetId, valueRanges=[{range, majorDimension, values}]}. Reads several ranges in one request, in the order given; an empty range has values=[]."},
    	updateValues = {method = "PUT", path = "/spreadsheets/{spreadsheetId}/values/{range}", access = "data:write", body = true, defaults = RAW, query = WRITE_QUERY, required = {values = "array"},
    		help = "updateValues({spreadsheetId, range, values, valueInputOption?, majorDimension?, includeValuesInResponse?}) -> {spreadsheetId, updatedRange, updatedRows, updatedColumns, updatedCells}. Writes values from range's top-left cell, e.g. range='Sheet1!B2', values={{42}}."},
    	appendValues = {method = "POST", path = "/spreadsheets/{spreadsheetId}/values/{range}:append", access = "data:write", body = true, defaults = RAW, required = {values = "array"}, query = APPEND_QUERY,
    		help = "appendValues({spreadsheetId, range, values, valueInputOption?, insertDataOption?}) -> {spreadsheetId, tableRange, updates}. Adds rows after the table Google finds in range, e.g. range='Log!A:D', values={{'2026-10-16', 'paid', 120}}, valueInputOption='USER_ENTERED' to store the date as a date. insertDataOption='INSERT_ROWS' inserts rows rather than filling the empty cells below (OVERWRITE, the default). Repeating it adds the rows again."},
    	clearValues = {method = "POST", path = "/spreadsheets/{spreadsheetId}/values/{range}:clear", access = "data:write", body = true,
    		help = "clearValues({spreadsheetId, range}) -> {spreadsheetId, clearedRange}. Clears values and keeps formatting."},
    	batchUpdateValues = {method = "POST", path = "/spreadsheets/{spreadsheetId}/values:batchUpdate", access = "data:write", body = true, defaults = RAW, required = {data = "array"},
    		help = "batchUpdateValues({spreadsheetId, data={{range='Sheet1!A1', values={{1, 2}}}, ...}, valueInputOption?, includeValuesInResponse?}) -> {spreadsheetId, totalUpdatedCells, responses}. Writes several ranges in one request."},
    	batchClearValues = {method = "POST", path = "/spreadsheets/{spreadsheetId}/values:batchClear", access = "data:write", body = true, required = {ranges = "array"},
    		help = "batchClearValues({spreadsheetId, ranges={'Sheet1!A2:D', ...}}) -> {spreadsheetId, clearedRanges}."},
    	createSpreadsheet = {method = "POST", path = "/spreadsheets", access = "data:write", body = true,
    		help = "createSpreadsheet({properties={title='Report'}, sheets?={{properties={title='Data'}}}}) -> the new spreadsheet, with spreadsheetId and spreadsheetUrl. It is created in the root of My Drive."},
    	batchUpdate = {method = "POST", path = "/spreadsheets/{spreadsheetId}:batchUpdate", access = "data:write", body = true, required = {requests = "array"},
    		help = "batchUpdate({spreadsheetId, requests, includeSpreadsheetInResponse?}) -> {spreadsheetId, replies}. Structure and formatting, applied all or nothing, e.g. requests={{addSheet={properties={title='Archive'}}}}. Request kinds include addSheet, deleteSheet, duplicateSheet, updateSheetProperties (rename or freeze, with a fields mask), insertDimension, deleteDimension (rows or columns), findReplace, sortRange, repeatCell (formatting), mergeCells, setDataValidation and addTable. They address cells with GridRange {sheetId, startRowIndex, endRowIndex, startColumnIndex, endColumnIndex}: zero-based, ends exclusive, sheetId from getSpreadsheet. Deleting a tab, rows or columns removes their data; only the spreadsheet's version history restores it."},
    }
    
    local NONE: {string} = table.freeze({})
    -- Ranges are opaque path segments: the proxy allows encoded / and % but refuses dot segments
    -- and control bytes, so any tab name, such as '10/16' or one with emoji, works.
    local function withRange(endpoint: Endpoint, args: Options): Endpoint
    	if not string.find(endpoint.path, "{range}", 1, true) then return endpoint end
    	local range = url.encode(text(args.range, "range"))
    	args.range = nil
    	local resolved = table.clone(endpoint)
    	resolved.path = string.gsub(endpoint.path, "{range}", function(): string return range end)
    	return resolved
    end
    for name, endpoint in endpoints do
    	export(name, endpoint.access, function(input: any): any
    		local args = options(input)
    		if string.find(endpoint.path, "{spreadsheetId}", 1, true) then
    			args.spreadsheetId = docsId(args.spreadsheetId, "spreadsheets", "spreadsheetId")
    		else
    			assert(args.spreadsheetId == nil, name .. " assigns the spreadsheetId")
    		end
    		local result = invoke(name, withRange(endpoint, args), args)
    		for _, range in result.valueRanges or NONE do
    			if range.values == nil then range.values = json.decode("[]") end
    		end
    		return result
    	end, endpoint.help)
    end
    
    local overview = {
    	"Google Sheets API v4. Operations take one named options object with Google's camelCase fields and return Google's JSON unchanged. Calls return completed values: use instance.getValues(...) directly, without await.",
    	"spreadsheetId is the ID or the spreadsheet's https://docs.google.com/spreadsheets/d/<id>/edit URL. This connector cannot search for files: ask for the URL, or find the ID with the Google Drive connector (listFiles with q=\"mimeType = 'application/vnd.google-apps.spreadsheet' and trashed = false\"). Excel files opened in Sheets are refused with HTTP 400 until saved as Google Sheets (File > Save as Google Sheets).",
    	"Ranges use A1 notation: 'Sheet1!B2', 'Sheet1!A1:C10', 'Sheet1!A:A', a whole tab 'Sheet1' or a named range. Quote tab names with spaces or punctuation, and tab names that look like cells, doubling apostrophes: \"'Q1 Sales'!A1\", \"'Q1'!A1\". Without a tab, a range means the first visible tab.",
    	"values are rows of cells (majorDimension='COLUMNS' gives columns). Trailing empty rows and cells are omitted; values is [] for an empty range. valueRenderOption is FORMATTED_VALUE (default, as displayed), UNFORMATTED_VALUE (numbers as numbers; dates as serial numbers unless dateTimeRenderOption='FORMATTED_STRING') or FORMULA.",
    	"Responses over 8 MiB fail: read large tabs in row blocks such as 'Data!A1:Z5000', and keep batchGetValues to a few dozen ranges per call.",
    	"Google allows about 60 reads per minute per user; HTTP 429 errors are retryable after a pause. No hidden paging or retries. Errors report the HTTP status and Google's message.",
    }
    if houston.allows("data:write") then
    	table.insert(overview, "Writes default to valueInputOption='RAW', storing values exactly as given, so '2026-10-16' stays text; pass 'USER_ENTERED' to parse numbers, dates and formulas as if typed. In values, json null leaves a cell unchanged and '' clears it. An empty Luau table encodes as a JSON object, which Google rejects: write an empty row or array as json.decode('[]'). Request bodies over 8 MiB fail: write large tables in row blocks. Google allows about 60 writes per minute per user. A failed or timed-out write may already have succeeded: read the range before repeating it.")
    end
    exports.help = helpWith(overview)
    return exports
    
  • houston.json
    {
      "schema_version": 2,
      "name": "Google Sheets",
      "files": [
        "connector.luau"
      ],
      "icon": "icon.svg",
      "access": [
        {
          "name": "data",
          "label": "Access",
          "levels": [
            {
              "value": "read",
              "label": "Read"
            },
            {
              "value": "write",
              "label": "Write"
            }
          ],
          "default": "read"
        }
      ],
      "auth": {
        "oauth": {
          "type": "oauth2",
          "label": "Connect with Google",
          "brand": "google",
          "authorize_url": "https://accounts.google.com/o/oauth2/v2/auth",
          "token_url": "https://oauth2.googleapis.com/token",
          "client_id": "{{publisher.client_id}}",
          "client_secret": "{{publisher.client_secret}}",
          "client_auth": "body",
          "pkce": "S256",
          "require_refresh": true,
          "authorize_params": {
            "access_type": "offline",
            "include_granted_scopes": "false",
            "prompt": "consent"
          },
          "scopes": [
            {
              "values": [
                "https://www.googleapis.com/auth/userinfo.email"
              ]
            },
            {
              "if": "{{ is access.data \"read\" }}",
              "values": [
                "https://www.googleapis.com/auth/spreadsheets.readonly"
              ]
            },
            {
              "if": "{{ is access.data \"write\" }}",
              "values": [
                "https://www.googleapis.com/auth/spreadsheets"
              ]
            }
          ],
          "account": {
            "method": "GET",
            "url": "https://www.googleapis.com/oauth2/v2/userinfo",
            "headers": {
              "Authorization": {
                "value": "Bearer {{auth.oauth.access_token}}"
              }
            },
            "label": "/email"
          }
        }
      },
      "publisher": {
        "client_id": {
          "type": "string",
          "label": "Google OAuth client ID",
          "required": true,
          "order": 1
        },
        "client_secret": {
          "type": "secret",
          "label": "Google OAuth client secret",
          "required": true,
          "order": 2
        }
      },
      "proxy": [
        {
          "match": {
            "protocol": "http",
            "host": [
              "sheets.googleapis.com"
            ],
            "method": [
              "GET"
            ],
            "path": [
              "/v4/spreadsheets/{spreadsheetId}",
              "/v4/spreadsheets/{spreadsheetId}/values:batchGet"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.oauth.access_token}}"
              }
            }
          }
        },
        {
          "match": {
            "protocol": "http",
            "host": [
              "sheets.googleapis.com"
            ],
            "method": [
              "GET"
            ],
            "path": [
              "/v4/spreadsheets/{spreadsheetId}/values/{range}"
            ],
            "opaque_path_parameters": [
              "range"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.oauth.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "sheets.googleapis.com"
            ],
            "method": [
              "POST"
            ],
            "path": [
              "/v4/spreadsheets",
              "/v4/spreadsheets/{spreadsheetId}:batchUpdate",
              "/v4/spreadsheets/{spreadsheetId}/values:batchUpdate",
              "/v4/spreadsheets/{spreadsheetId}/values:batchClear"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.oauth.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "sheets.googleapis.com"
            ],
            "method": [
              "PUT"
            ],
            "path": [
              "/v4/spreadsheets/{spreadsheetId}/values/{range}"
            ],
            "opaque_path_parameters": [
              "range"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.oauth.access_token}}"
              }
            }
          }
        },
        {
          "if": "{{ allows access.data \"write\" }}",
          "match": {
            "protocol": "http",
            "host": [
              "sheets.googleapis.com"
            ],
            "method": [
              "POST"
            ],
            "path": [
              "/v4/spreadsheets/{spreadsheetId}/values/{range}:append",
              "/v4/spreadsheets/{spreadsheetId}/values/{range}:clear"
            ],
            "opaque_path_parameters": [
              "range"
            ]
          },
          "action": {
            "headers": {
              "set": {
                "Authorization": "Bearer {{auth.oauth.access_token}}"
              }
            }
          }
        }
      ]
    }
    
  • icon.svgicon.svg
  • README.md
    ---
    description: Read and update Google Sheets spreadsheets.
    ---
    # Google Sheets
    
    Let agents look up figures, keep trackers up to date and build reports in your
    spreadsheets.
    
    - Read single cells, ranges or several tabs at once, as displayed, as raw
      numbers or as formulas.
    - See a spreadsheet's tabs, their sizes and its named ranges.
    - With **Write** access: write and clear cells, add rows to logs and
      tables, create spreadsheets, and add or rename tabs, sort data and format cells.
    
    Agents work with a spreadsheet when you share its link. To let them search your
    Drive for spreadsheets, also connect Google Drive. Read access cannot
    change your spreadsheets.
    
  • SETUP.md
    # Connect your Google account
    
    1. Choose the level for **Access**:
       - **Read** to let agents read spreadsheets without changing anything.
       - **Write** to also let agents edit cells, add rows, create
         spreadsheets and change tabs and formatting.
    2. Select **Continue with Google**, choose your account, and approve the
       permissions Google lists. If Google shows a checkbox per permission, tick
       them all: Houston refuses a partial grant.
    
    The connection can open every spreadsheet your Google account can open, but
    nothing else in your Drive; connecting Google Sheets does not grant access to
    your other Google services.
    
    ## Advanced: changing access and troubleshooting
    
    - To change the access level, edit the connection and connect with Google again.
      Google then asks for the new set of permissions.
    - To revoke access, remove the connection in Houston, or remove Houston from
      [your Google Account's third-party connections](https://myaccount.google.com/connections).
    - Google Workspace administrators can block third-party apps. If Google refuses
      the connection, ask your administrator to allow Houston.
    - An agent that cannot open a spreadsheet may be using a link from **Publish to
      the web**. Share the spreadsheet's normal link instead, from the address bar
      while it is open.
    - Excel files stored in Drive open in Sheets but cannot be read by agents.
      Convert one with **File > Save as Google Sheets** and share the new link.
    
  • tests
    • authentication.luau
      return {
      	contract = function(m)
      		m.authentication({
      			{
      				auth = {},
      				config = {},
      				endpoint = { "GET", "https://sheets.googleapis.com/v4/spreadsheets/s1" },
      				expected = "Bearer synthetic-oauth-token",
      				header = "Authorization",
      				method = "oauth",
      				oauth = true,
      				publisher = {
      					client_id = "synthetic-public-client",
      					client_secret = "synthetic-client-secret",
      				},
      				scopes = true,
      			},
      		})
      	end,
      }
      
    • endpoints.luau
      return {
      	contract = function(m)
      		m.endpointRules()
      	end,
      }
      
    • errors.luau
      return {
      	scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}},
      	access = {data = "write"},
      	configure = function()
      		calls, status, payload, responseHeaders = 0, 200, "{}", {}
      		http = {request = function(req)
      			calls += 1
      			return fixture.operation({statusCode = status, headers = responseHeaders, body = fixture.reader(payload)})
      		end}
      	end,
      	run = function(c)
      		local function upstream(code, body, headers, expected)
      			status, payload, responseHeaders = code, body, headers
      			local before = calls
      			local ok, err = pcall(c.appendValues, {spreadsheetId = "s1", range = "Log!A:D", values = {{"x"}}})
      			for _, text in expected do
      				assert(not ok and string.find(tostring(err), text, 1, true), "missing " .. text .. " in " .. tostring(err))
      			end
      			assert(calls == before + 1, "failed write was retried")
      		end
      		upstream(403, '{"error":{"code":403,"message":"The caller does not have permission","status":"PERMISSION_DENIED"}}', {},
      			{"HTTP 403 (PERMISSION_DENIED): The caller does not have permission", '"retryable":false'})
      		upstream(400, '{"error":{"code":400,"message":"Unable to parse range: Nope!A1","status":"INVALID_ARGUMENT"}}', {},
      			{"HTTP 400 (INVALID_ARGUMENT)", "Unable to parse range", '"retryable":false'})
      		upstream(429, '{"error":{"code":429,"message":"Quota exceeded for quota metric \'Write requests\'","status":"RESOURCE_EXHAUSTED"}}', {["retry-after"] = {"30"}},
      			{"HTTP 429 (RESOURCE_EXHAUSTED)", "Retry-After: 30", '"retryable":true'})
      		upstream(400, "<html><title>Error 400 (Bad Request)</title></html>", {}, {"Google HTTP 400", '"retryable":false'})
      		upstream(503, '{"error":{"code":503,"message":"The service is currently unavailable.","status":"UNAVAILABLE"}}', {}, {"HTTP 503", '"retryable":true'})
      		upstream(200, "<html>Maintenance</html>", {}, {"invalid JSON object"})
      		upstream(200, "[]", {}, {"invalid JSON object"})
      		status, payload = 404, '{"error":{"code":404,"message":"Requested entity was not found.","status":"NOT_FOUND"}}'
      		local ok, err = pcall(c.getValues, {spreadsheetId = "missing", range = "A1"})
      		assert(not ok and string.find(tostring(err), "NOT_FOUND", 1, true) and string.find(tostring(err), '"operation":"getValues"', 1, true), tostring(err))
      	end,
      }
      
    • manifest.luau
      return {
      	contract = function(m)
      		local function google(access, scopes)
      			local r, err = m.resolve(
      				{ client_id = "publisher-client", client_secret = "publisher-secret" },
      				{},
      				nil,
      				"oauth",
      				{ data = access }
      			)
      			assert(r and not err, tostring(err))
      			local want = { "https://www.googleapis.com/auth/userinfo.email" }
      			for _, scope in scopes do
      				table.insert(want, "https://www.googleapis.com/auth/" .. scope)
      			end
      			assert(m.equal(r.Scopes, want), "requested OAuth scopes")
      			r.Context.Auth.oauth.access_token = "fixture-token"
      			return r
      		end
      		do
      			local api = "https://sheets.googleapis.com/v4/spreadsheets"
      			for _, access in { "read", "write" } do
      				local scope = "spreadsheets.readonly"
      				if access == "write" then
      					scope = "spreadsheets"
      				end
      				local r = google(access, { scope })
      				m.routes(r, "Bearer fixture-token", true, {
      					"GET " .. api .. "/s1?fields=sheets.properties",
      					"GET " .. api .. "/s1/values/%27Q1%20Sales%27%21B2",
      					"GET " .. api .. "/s1/values:batchGet?ranges=Q2%2FQ3%21A1",
      					"GET " .. api .. "/s1/values/%2710%2F16%27%21A1",
      					"GET " .. api .. "/s1/values/%27100%25%27%21A1",
      				})
      				local writes = {
      					"POST " .. api,
      					"POST " .. api .. "/s1:batchUpdate",
      					"PUT " .. api .. "/s1/values/Sheet1%21B2?valueInputOption=RAW",
      					"POST " .. api .. "/s1/values/Log%21A%3AD:append?valueInputOption=RAW",
      					"POST " .. api .. "/s1/values/A1:clear",
      					"POST " .. api .. "/s1/values:batchUpdate",
      					"POST " .. api .. "/s1/values:batchClear",
      					"PUT " .. api .. "/s1/values/%27Q2%2FQ3%27%21B2",
      					"POST " .. api .. "/s1/values/%27Log%2F2026%27%21A%3AD:append",
      				}
      				m.routes(r, "Bearer fixture-token", (access == "write"), writes)
      				m.routes(r, "Bearer fixture-token", false, {
      					"POST https://oauth2.googleapis.com/token",
      					"GET https://www.googleapis.com/drive/v3/files",
      					"GET https://sheets.googleapis.com/v4/spreadsheets",
      					"GET https://sheets.googleapis.com.evil.test/v4/spreadsheets/s1",
      					"GET https://sheets.googleapis.com/v3/spreadsheets/s1",
      					"DELETE " .. api .. "/s1",
      					"PATCH " .. api .. "/s1/values/A1",
      					"GET " .. api .. "/s1/developerMetadata/1",
      					"POST " .. api .. "/s1/developerMetadata:search",
      					"POST " .. api .. "/s1/sheets/0:copyTo",
      					"POST " .. api .. "/s1/values:batchUpdateByDataFilter",
      					"GET " .. api .. "/s1/values/%2e%2e/x",
      					"GET " .. api .. "/s1/values/%2e%2e%2F%2e%2e%2Fdrive",
      					"GET " .. api .. "/s1/values/%252e%252e%252Fx",
      					"GET " .. api .. "/s1%2F..%2Fx/values/A1",
      				})
      				m.rejectOverrides(r, { "GET " .. api .. "/s1", "GET " .. api .. "/s1/values/A1" })
      				if access == "write" then
      					m.rejectOverrides(r, writes)
      				end
      			end
      		end
      		do
      			local sheets = google("read", { "spreadsheets.readonly" })
      			local spreadsheet = "https://sheets.googleapis.com/v4/spreadsheets/x"
      			m.routes(sheets, "Bearer fixture-token", true, { "GET " .. spreadsheet })
      			m.refused(sheets, "", { "POST " .. spreadsheet .. ":batchUpdate" })
      			m.refused(sheets, "method override", { "GET " .. spreadsheet .. ":batchUpdate?$httpMethod=POST" })
      		end
      	end,
      }
      
    • reads.luau
      return {
      	scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}},
      	access = {data = "read"},
      	configure = function()
      		requests, responses = {}, {}
      		http = {request = function(req)
      			table.insert(requests, req)
      			assert(#responses > 0, "unexpected request: " .. req.url)
      			return fixture.operation({statusCode = 200, headers = {}, body = fixture.reader(table.remove(responses, 1))})
      		end}
      	end,
      	run = function(c)
      		local API = "https://sheets.googleapis.com/v4/spreadsheets/"
      		for _, name in {"updateValues", "appendValues", "clearValues", "batchUpdateValues", "batchClearValues", "createSpreadsheet", "batchUpdate"} do
      			assert(c[name] == nil, "read-only leaked " .. name)
      		end
      		local names = {}
      		for name in c do table.insert(names, name) end
      		table.sort(names)
      		assert(table.concat(names, ",") == "batchGetValues,getSpreadsheet,getValues", table.concat(names, ","))
      
      		responses = {'{"range":"\'Q1 Sales\'!B2","majorDimension":"ROWS","values":[["42"]]}', '{"range":"Sheet1!Z9","majorDimension":"ROWS"}', '{"range":"Sheet1!A1:B2","values":[[1,2],[3]]}'}
      		local cell = c.getValues({spreadsheetId = "https://docs.google.com/spreadsheets/d/1AbC_d-9/edit?gid=0#gid=0", range = "'Q1 Sales'!B2"})
      		assert(cell.values[1][1] == "42")
      		assert(requests[1].method == "GET" and requests[1].url == API .. "1AbC_d-9/values/%27Q1%20Sales%27%21B2", requests[1].url)
      		local empty = c.getValues({spreadsheetId = "https://docs.google.com/spreadsheets/u/1/d/s1/edit", range = "Sheet1!Z9"})
      		assert(json.encode(empty.values) == "[]" and requests[2].url == API .. "s1/values/Sheet1%21Z9", requests[2].url)
      		local raw = c.getValues({spreadsheetId = "s1", range = "Sheet1!A1:B2", valueRenderOption = "UNFORMATTED_VALUE", majorDimension = "ROWS"})
      		assert(raw.values[2][1] == 3 and requests[3].url == API .. "s1/values/Sheet1%21A1%3AB2?majorDimension=ROWS&valueRenderOption=UNFORMATTED_VALUE", requests[3].url)
      
      		responses = {'{"spreadsheetId":"s1","valueRanges":[{"range":"Sheet1!A1:B2","values":[["a"]]},{"range":"Totals!C3"}]}', '{"spreadsheetId":"s1"}'}
      		local batch = c.batchGetValues({spreadsheetId = "s1", ranges = {"Sheet1!A1:B2", "Totals!C3"}, valueRenderOption = "FORMULA"})
      		assert(batch.valueRanges[1].values[1][1] == "a" and json.encode(batch.valueRanges[2].values) == "[]")
      		assert(requests[4].url == API .. "s1/values:batchGet?ranges=Sheet1%21A1%3AB2&ranges=Totals%21C3&valueRenderOption=FORMULA", requests[4].url)
      		local none = c.batchGetValues({spreadsheetId = "s1", ranges = {"Q2/Q3!A1"}})
      		assert(json.encode(none.valueRanges) == "[]" and requests[5].url == API .. "s1/values:batchGet?ranges=Q2%2FQ3%21A1", requests[5].url)
      
      		responses = {'{"range":"\'10/16\'!A1"}', '{"range":"\'100%\'!A1"}', '{"range":"Sheet1!A1"}'}
      		c.getValues({spreadsheetId = "s1", range = "'10/16'!A1"})
      		assert(requests[6].url == API .. "s1/values/%2710%2F16%27%21A1", requests[6].url)
      		c.getValues({spreadsheetId = "s1", range = "'\u{26A0}\u{FE0F} 100%'!A1"})
      		assert(requests[7].url == API .. "s1/values/%27%E2%9A%A0%EF%B8%8F%20100%25%27%21A1", requests[7].url)
      		c.getValues({spreadsheetId = "https://docs.google.com/a/example.com/spreadsheets/d/s1/edit", range = "Sheet1!A1"})
      		assert(requests[8].url == API .. "s1/values/Sheet1%21A1", requests[8].url)
      
      		local fields = "spreadsheetId,spreadsheetUrl,properties(title,locale,timeZone),sheets.properties,namedRanges"
      		responses = {'{"spreadsheetId":"s1","sheets":[{"properties":{"sheetId":0,"title":"Sheet1"}}]}', '{"spreadsheetId":"s1","namedRanges":[{"name":"Totals"}]}'}
      		local info = c.getSpreadsheet({spreadsheetId = "s1"})
      		assert(info.sheets[1].properties.title == "Sheet1" and json.encode(info.namedRanges) == "[]")
      		assert(requests[9].url == API .. "s1?fields=" .. url.encode(fields), requests[9].url)
      		assert(c.getSpreadsheet({spreadsheetId = "s1", fields = "sheets(data(rowData(values(note))))", ranges = {"A1:B2"}}).namedRanges[1].name == "Totals")
      		assert(requests[10].url == API .. "s1?fields=sheets%28data%28rowData%28values%28note%29%29%29%29&ranges=A1%3AB2", requests[10].url)
      		for _, req in requests do
      			assert(req.method == "GET" and req.body == nil, req.method .. " " .. req.url)
      			assert(req.headers == nil or req.headers.Authorization == nil, "connector set credentials")
      		end
      
      		local sent = #requests
      		local invalid = {
      			{spreadsheetId = "s1"},
      			{spreadsheetId = "s1", range = ""},
      			{spreadsheetId = "..", range = "A1"},
      			{spreadsheetId = "s/1", range = "A1"},
      			{spreadsheetId = "https://docs.google.com/spreadsheets/d/e/2PACX-1vT/pubhtml", range = "A1"},
      			{spreadsheetId = "https://docs.google.com.example.com/spreadsheets/d/s1/edit", range = "A1"},
      			{spreadsheetId = "https://example.com/?u=https://docs.google.com/spreadsheets/d/s1", range = "A1"},
      			{spreadsheetId = "https://docs.google.com/spreadsheets/abcd/s1", range = "A1"},
      			{spreadsheetId = "https://docs.google.com/spreadsheets/u/0/?usp=d/s1", range = "A1"},
      			{spreadsheetId = "https://docs.google.com/spreadsheets/#d/s1", range = "A1"},
      			{spreadsheetId = "https://docs.google.com/spreadsheets/d/s1.x/edit", range = "A1"},
      			{spreadsheetId = "s1 x", range = "A1"},
      			{range = "A1"},
      			{spreadsheetId = "s1", range = "A1", key = "api-key"},
      		}
      		for _, args in invalid do
      			assert(not pcall(c.getValues, args), "accepted " .. json.encode(args))
      		end
      		assert(not pcall(c.getValues, "s1"))
      		assert(not pcall(c.batchGetValues, {spreadsheetId = "s1"}), "batchGetValues requires ranges")
      		assert(not pcall(c.batchGetValues, {spreadsheetId = "s1", ranges = {}}))
      		assert(not pcall(c.batchGetValues, {spreadsheetId = "s1", ranges = ""}))
      		assert(not pcall(c.batchGetValues, {spreadsheetId = "s1", ranges = "Sheet1!A1"}))
      		assert(not pcall(c.getSpreadsheet, {spreadsheetId = "s1", includeGridData = true}))
      		assert(#requests == sent, "invalid input reached Google")
      		assert(#responses == 0)
      	end,
      }
      
    • writes.luau
      return {
      	scenario = {publisher = {client_id = "fixture-client", client_secret = "fixture-private-secret"}, config = {}, auth_method = "oauth", auth_config = {}},
      	access = {data = "write"},
      	configure = function()
      		requests, responses = {}, {}
      		http = {request = function(req)
      			table.insert(requests, req)
      			assert(#responses > 0, "unexpected request: " .. req.url)
      			return fixture.operation({statusCode = 200, headers = {}, body = fixture.reader(table.remove(responses, 1))})
      		end}
      	end,
      	run = function(c)
      		local API = "https://sheets.googleapis.com/v4/spreadsheets"
      		local names = {}
      		for name in c do table.insert(names, name) end
      		table.sort(names)
      		assert(table.concat(names, ",") == "appendValues,batchClearValues,batchGetValues,batchUpdate,batchUpdateValues,clearValues,createSpreadsheet,getSpreadsheet,getValues,updateValues", table.concat(names, ","))
      		local function sent(method, href, body)
      			local req = requests[#requests]
      			assert(req.method == method and req.url == href, req.method .. " " .. req.url)
      			assert(req.headers["Content-Type"][1] == "application/json" and req.headers.Authorization == nil)
      			assert(req.body == body, req.body)
      		end
      
      		responses = {'{"spreadsheetId":"s1","updatedRange":"Sheet1!B2","updatedCells":1}'}
      		assert(c.updateValues({spreadsheetId = "https://docs.google.com/spreadsheets/d/s1/edit#gid=0", range = "Sheet1!B2", values = {{42}}}).updatedCells == 1)
      		sent("PUT", API .. "/s1/values/Sheet1%21B2?valueInputOption=RAW", '{"values":[[42]]}')
      		responses = {'{"spreadsheetId":"s1"}'}
      		c.updateValues({spreadsheetId = "s1", range = "B2:C2", values = {{json.decode("null"), ""}}, valueInputOption = "USER_ENTERED", includeValuesInResponse = true})
      		sent("PUT", API .. "/s1/values/B2%3AC2?valueInputOption=USER_ENTERED&includeValuesInResponse=true", '{"values":[[null,""]]}')
      
      		-- Google's system parameters stay out of the URL; Google rejects them as unknown body fields.
      		responses = {'{"spreadsheetId":"s1"}'}
      		c.updateValues({spreadsheetId = "s1", range = "A1", values = {{1}}, key = "k", access_token = "t", alt = "media", fields = "x"})
      		assert(requests[#requests].url == API .. "/s1/values/A1?valueInputOption=RAW", requests[#requests].url)
      		local smuggled = json.decode(requests[#requests].body)
      		assert(smuggled.key == "k" and smuggled.access_token == "t" and smuggled.alt == "media" and smuggled.fields == "x")
      
      		responses = {'{"spreadsheetId":"s1","tableRange":"Log!A1:D3","updates":{"updatedRows":1}}'}
      		assert(c.appendValues({spreadsheetId = "s1", range = "Log!A:D", values = {{"2026-10-16", "paid", 120}}, insertDataOption = "INSERT_ROWS"}).updates.updatedRows == 1)
      		sent("POST", API .. "/s1/values/Log%21A%3AD:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS", '{"values":[["2026-10-16","paid",120]]}')
      
      		responses = {'{"spreadsheetId":"s1"}'}
      		c.appendValues({spreadsheetId = "s1", range = "'Log/2026'!A:D", values = {{1}}})
      		sent("POST", API .. "/s1/values/%27Log%2F2026%27%21A%3AD:append?valueInputOption=RAW", '{"values":[[1]]}')
      
      		responses = {'{"spreadsheetId":"s1","clearedRange":"Sheet1!A2:D1000"}'}
      		assert(c.clearValues({spreadsheetId = "s1", range = "Sheet1!A2:D"}).clearedRange == "Sheet1!A2:D1000")
      		sent("POST", API .. "/s1/values/Sheet1%21A2%3AD:clear", "{}")
      
      		responses = {'{"spreadsheetId":"s1","totalUpdatedCells":2}', '{"spreadsheetId":"s1","clearedRanges":["Q2/Q3!A1"]}'}
      		c.batchUpdateValues({spreadsheetId = "s1", data = {{range = "Q2/Q3!A1", values = {{1, 2}}}}})
      		local body = json.decode(requests[#requests].body)
      		assert(requests[#requests].url == API .. "/s1/values:batchUpdate" and body.valueInputOption == "RAW" and body.data[1].range == "Q2/Q3!A1" and json.encode(body.data[1].values) == "[[1,2]]")
      		body.data, body.valueInputOption = nil, nil
      		assert(next(body) == nil, "unexpected batchUpdateValues fields")
      		c.batchClearValues({spreadsheetId = "s1", ranges = {"Q2/Q3!A1"}})
      		sent("POST", API .. "/s1/values:batchClear", '{"ranges":["Q2/Q3!A1"]}')
      
      		responses = {'{"spreadsheetId":"new","spreadsheetUrl":"https://docs.google.com/spreadsheets/d/new/edit"}', '{"spreadsheetId":"s1","replies":[{"addSheet":{"properties":{"sheetId":7}}}]}'}
      		assert(c.createSpreadsheet({properties = {title = "Report"}}).spreadsheetId == "new")
      		sent("POST", API, '{"properties":{"title":"Report"}}')
      		assert(c.batchUpdate({spreadsheetId = "s1", requests = {{addSheet = {properties = {title = "Archive"}}}}}).replies[1].addSheet.properties.sheetId == 7)
      		sent("POST", API .. "/s1:batchUpdate", '{"requests":[{"addSheet":{"properties":{"title":"Archive"}}}]}')
      
      		local count = #requests
      		assert(not pcall(c.updateValues, {spreadsheetId = "s1", range = "A1"}), "updateValues requires values")
      		assert(not pcall(c.updateValues, {spreadsheetId = "s1", range = "A1", values = json.decode("null")}))
      		assert(not pcall(c.updateValues, {spreadsheetId = "s1", range = "A1", values = {}}))
      		assert(not pcall(c.updateValues, {spreadsheetId = "s1", range = "A1", values = "42"}))
      		assert(not pcall(c.batchUpdate, {spreadsheetId = "s1", requests = {addSheet = {}}}))
      		assert(not pcall(c.createSpreadsheet, {spreadsheetId = "s1", properties = {title = "Copy"}}), "createSpreadsheet assigns the ID")
      		assert(not pcall(c.batchUpdateValues, {spreadsheetId = "s1"}))
      		assert(not pcall(c.batchClearValues, {spreadsheetId = "s1"}))
      		assert(not pcall(c.batchClearValues, {spreadsheetId = "s1", ranges = "Sheet1!A1"}), "batchClearValues ranges must be an array")
      		assert(not pcall(c.batchUpdate, {spreadsheetId = "s1", requests = "x"}))
      		assert(not pcall(c.batchUpdate, {spreadsheetId = "s1"}))
      		assert(not pcall(c.clearValues, {spreadsheetId = "s1"}))
      		assert(not pcall(c.batchUpdate, {spreadsheetId = "https://docs.google.com/spreadsheets/d/e/2PACX-1vT/pubhtml", requests = {}}))
      		assert(#requests == count, "invalid input reached Google")
      		assert(#responses == 0)
      	end,
      }