sheets_export_report
Google Sheets write high risk
Part of the Google Sheets Agent.
What it does
Writes a reporting payload's rows into a client-owned Google Sheet in one call, creating a new spreadsheet (`new_spreadsheet_title`) or reusing an existing one (`spreadsheet_id`). `report` is {rows: array<array<cell>>} (or {values:[...]}, or a bare 2D array), a cell being text, a number, true/false or null - put the header row in rows[0]; title/columns/totals_row are not read. Rows are written verbatim from A1 of the `sheet_title` tab (default 'Sheet1') with `mode` 'write' (default; values.update - alias 'overwrite') or 'append' (values.append below the existing table). No formatting, title block, totals row or branding is applied. A new file is created with that tab; in an existing file the tab must already exist. No rows, an object row or cell, an unknown mode, or both spreadsheet_id and new_spreadsheet_title -> invalid_argument; a new file's title or tab name with Claude, MCP or Anthropic as a whole word -> white_label_required (Scalix policy). Each is refused before any preview_id is issued. If a new file is created but writing the rows then fails, the error is partially_applied and names the new spreadsheet_id - re-preview with spreadsheet_id set to it, never with a new title (that makes a second file). Response shape: success {success:true,data:{applied,result}} where result is {spreadsheet_id, created, write} and write is Google's update/append response; 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) builds the request locally and returns a preview_id - nothing is created or written; 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 as the default, one-click path to write a reporting payload's rows into a client-owned Google Sheet - when the user asks to 'export this report to Sheets' or 'send the client a spreadsheet'. Use the granular sheets_write_values/sheets_append_rows tools only for surgical edits where you don't want destination management. For audit deliverables, first call build_audit_report for the report structure, reconciliation rules, and severity ordering, then export the assembled report here.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
report | object | yes | {rows: array<array<cell>>} (or {values:[...]}, or a bare 2D array); a cell is text, a number, true/false or null - send records like {campaign, cost} as a header row plus value rows. title/columns/totals_row are not read - put the header row in rows[0]. |
spreadsheet_id | string | no | Reuse an existing client spreadsheet. If omitted, a new one is created using new_spreadsheet_title. Give spreadsheet_id or new_spreadsheet_title, not both (both -> invalid_argument). |
new_spreadsheet_title | string | no | Title for a new spreadsheet when spreadsheet_id is omitted (default 'Report'). White-label (Scalix policy): 'Claude', 'MCP', 'Anthropic' or 'Scalix' as a whole word, in any case, is refused before any preview_id (white_label_required); inside a longer word (McPherson) it is not. |
sheet_title | string | no | Target tab, default 'Sheet1'. A new file is created with this tab, so it is checked like new_spreadsheet_title; in an existing file it must already exist and is not checked. |
mode | string | no | 'write' (default; alias 'overwrite' - values.update at A1, replacing that range) or 'append' (values.append below the existing table). Any other value -> invalid_argument. |
value_input_option | string | no | 'USER_ENTERED' (default - enables currency/percent/date rendering) or 'RAW'. |
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
White-label only: titles, tab names, headers and cells carry only the client's branding, never Claude, MCP or Anthropic, nor a Scalix-internal marker (Scalix policy: a new file's title or tab name with Claude, MCP or Anthropic as a whole word is refused). Export only the authorizing client's own data; the spreadsheet is created in and owned by the client's Drive (strict per-account isolation). Data-usage: 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; forward only the client's OWN leads, with consent, and hash PII where supported. Strip all LinkedIn member-derived fields from the payload before export; never persist member data. Honor deletion on request; member profile data caches <=24h, social activity <=48h.
Reminder
Preview the destination (create vs reuse) with the user; commit only with the preview_id the preview returned.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
auth_error | Missing or expired Google authorization, invalid session, or ungranted spreadsheets scope (401). | Reconnect Google in the Scalix dashboard (the connection requests the spreadsheets scope), then retry. | no |
permission_error | Account cannot create files or lacks edit access to the reuse target (403). | Confirm the connected Google account can create files and edit the destination; fix access then retry. | no |
not_found_error | Provided spreadsheet_id not found or not visible to this app/account (404), or named tab missing on a reuse with mode=append. | Verify the spreadsheet_id/tab, or omit spreadsheet_id to create a new file; do not retry blindly. | no |
rate_limit_error | Sheets API quota exceeded across the create+write calls (429): 60 writes/min/user, 300/min/project. | Retry the failed sub-step with truncated exponential backoff min((2^n + random_ms), 64s). | yes |
validation_error | Google refused a sub-call (400), e.g. sheet_title is not a tab of the existing spreadsheet, or a value it cannot parse. Surface Google's message for the failing sub-call. | Fix the payload field indicated and re-preview (call without preview_id) before committing. | no |
white_label_required | Scalix policy: new_spreadsheet_title, or sheet_title when a new file is created, has Claude, MCP or Anthropic as a whole word (any case). Refused before any preview_id; nothing is created or written. | Rename it without that word, for example with the client's own name, then call again for a new preview. | no |
outcome_unknown | Google Sheets answered a 5xx (e.g. 500/503) to a write, or the connection timed out or dropped once it was open, so the write may have landed. If it was the create, a file named new_spreadsheet_title may exist, without the rows. | Check first, never retry blindly. After an unconfirmed create: look in the user's Drive for that file; if it is there, re-preview with spreadsheet_id=<its id> instead of new_spreadsheet_title, otherwise start over. After an unconfirmed write into spreadsheet_id: read the tab back with sheets_get_values and start over only if the rows are not there. | no |
partially_applied | The new file was created, but writing the rows into it failed; the message names its spreadsheet_id, and the attempt is audited as partial. | Follow the cause's next step first (after a 5xx the rows may already be in the file); any re-preview must use spreadsheet_id=<that id> instead of new_spreadsheet_title, so the rows go into this file, not another new one. | no |
Edge cases
- Preview (no preview_id) echoes the create-or-reuse destination and the row count; nothing is created or written.
- Idempotent upsert on reuse: with spreadsheet_id + mode='overwrite', re-running replaces the report area in place (no duplicate file) - the preferred way to refresh a recurring client report.
- Create path is NOT idempotent - if create succeeds but a later sub-step fails, the returned spreadsheet_id must be reused on retry to avoid orphaned duplicate files.
- Pagination/large reports: payloads over ~2MB or very large row counts should be chunked across multiple append writes; respect the 10,000,000-cell-per-spreadsheet ceiling (across all tabs).
- Dedupe in append mode: detect a matching key (e.g. report period) before appending to avoid duplicate report blocks.
- Retention/consent: strip LinkedIn member-derived fields entirely; never export member-level rows and never persist them, honoring the 24h/48h purge constraint; forward only the client's own consented leads.