sheets_write_values
Google Sheets write medium risk
Part of the Google Sheets Agent.
What it does
Overwrites the values in a specific A1 range of an existing spreadsheet (spreadsheets.values.update). Use this when you want deterministic placement - e.g. write a header block at A1, or replace a previously exported table in-place. Key inputs: `spreadsheet_id`, `range` in A1 notation (e.g. 'Performance!A1:F50'; omit the tab name to target the first sheet), `values` as a 2D array of rows, `value_input_option` ('USER_ENTERED' to let Sheets parse dates/currency/numbers like the UI, or 'RAW' to insert verbatim strings), and optional `major_dimension` ('ROWS' default, or 'COLUMNS'). Returns Google's `updatedRange`, `updatedRows`, `updatedColumns` and `updatedCells`. Only the cells the data covers are replaced. A multi-cell range (A1:F50) must hold all the data - Google refuses a write that runs past it; a single cell (A1) is the top-left corner the data extends from, any number of rows and columns. To add rows below a table, use sheets_append_rows. Response shape: success {success:true,data:{applied,result}} where result is Google's {spreadsheetId,updatedRange,updatedRows,updatedColumns,updatedCells}; error {success:false,error_class,message,action_required,is_retryable}. Two-phase (ADR-028/029, the same gate as Google Ads, LinkedIn and CRM writes): the first call (no preview_id) returns a preview_id and writes nothing. The preview includes the values to be written and the cells they replace (one read of that block; the first 20 rows of each - columns with major_dimension COLUMNS - plus a count of the rest); if the read fails, a warning says so and the preview still comes. Write access is not checked before the commit: the spreadsheets scope Scalix holds cannot read file permissions (that needs a Drive scope), so a file the account can only view fails at commit with Google's permission error. Then re-call with that preview_id and identical arguments to COMMIT (single-use, 30 min; a changed, forged or replayed token fails closed).
When to use it
Use when you need exact, repeatable placement of a block of cells (headers, a fixed-size table, an in-place refresh). For growing logs where rows accumulate, use sheets_append_rows. To write a report's rows into a new or existing file in one call (no formatting), use sheets_export_report.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | yes | Target spreadsheet ID (from sheets_create_spreadsheet or a client-confirmed existing file). |
range | string | yes | A1 notation range to overwrite, e.g. 'Performance!A1:F50'. Without a sheet prefix it targets the first sheet. A multi-cell range must hold all the data; a single cell (e.g. 'Performance!A1') is the top-left corner the data extends from. |
values | array<array<string|number|boolean>> | yes | 2D array of row data. Outer array = rows (or columns if major_dimension=COLUMNS). Cells are text, numbers, true/false or null - never objects. |
value_input_option | string | no | How values are interpreted: 'USER_ENTERED' (parse like the Sheets UI - recommended for client-ready formatting) or 'RAW' (insert as-is). Default 'USER_ENTERED'. |
major_dimension | string | no | 'ROWS' (default - each inner array is a row) or 'COLUMNS' (each inner array is a column). |
include_values_in_response | boolean | no | If true, echoes the written values back in the response for verification. Default false. |
preview_id | string | no | Omit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview. |
Safeguards
A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.
Policy
Write only the authorizing client's own data into the client's own spreadsheet; confirm the destination spreadsheet_id and range before overwriting (overwrite is destructive within the range). White-label content only (no Claude/MCP/Anthropic/Scalix-internal labels). Strict per-account isolation. Data-usage: never write LinkedIn member-derived data; member/lead data may be used ONLY for the authorizing client and ONLY for consented purposes - never to enrich/append/verify profiles, build a cross-account or unaffiliated lead database, do prospecting, or commingle data across clients. Honor deletion on request; member profile data caches <=24h, social activity <=48h. Hash PII where the destination supports it.
Reminder
Overwrite is destructive - show the user the preview's current cells and new values, and confirm spreadsheet_id and range before writing.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
auth_error | Missing or expired Google token, invalid session, or ungranted spreadsheets scope (401). | Reconnect Google in the Scalix dashboard (the connection requests the spreadsheets scope), then retry. | no |
permission_error | Authorizing account lacks edit access to this spreadsheet (403). Write access is not read at preview, so a view-only file shows here, at commit. | Confirm the connected Google account can edit the file (its owner grants edit access); fix access before retrying. | no |
not_found_error | spreadsheet_id does not exist or is not visible to this app/account (404). | Verify the spreadsheet_id and that the connected Google account can open the file; do not retry blindly. | no |
rate_limit_error | Sheets write quota exceeded (429): 60/min/user, 300/min/project. | Retry with truncated exponential backoff min((2^n + random_ms), 64s). | yes |
validation_error | Malformed range or values (400), e.g. unparseable A1 notation, data that runs past a multi-cell range, or a range outside grid bounds (ragged rows are accepted; an unknown value_input_option or major_dimension is refused before any preview_id, invalid_argument). Surface the Google message verbatim. | Fix the range/values per the platform message and retry. | no |
outcome_unknown | Google Sheets answered a 5xx (e.g. 500/503) to this write, or the connection timed out or dropped once it was open, so the write may have landed. | Check first: read the range back with sheets_get_values, and start over with a fresh preview only if the values are not there. | no |
Edge cases
- Data larger than a multi-cell range is refused by Google (the data must be within that range); a single-cell range is where the data starts, and it extends any number of rows or columns (Sheets guide 'Read & write cell values', updated 3 Sep 2026).
- Empty values [] is a no-op write (updatedCells=0) - guard against accidental no-effect calls.
- Ragged rows (uneven inner-array lengths) are accepted but produce uneven columns - normalize before sending.
- USER_ENTERED parses a leading '=' as a formula; use RAW to store literal strings that begin with '=' or '+'.
- Idempotent by nature: re-running the same update over the same range yields the same result (safe to retry on transient errors).
- Pagination/large writes: a single update over a very large range may exceed the ~2MB payload performance guidance - chunk into multiple updates; respect the 10M-cell workbook ceiling.
- Retention/consent: never overwrite client cells with LinkedIn member-derived data; do not persist member/lead data.