Google Drive & Sheets

Create spreadsheets and save files in the connected Google account, add rows, read them back.

Overview

The Google Drive & Sheets Core API works in the organization's connected Google account — one connection, "Google Drive & Sheets". It creates spreadsheets, adds rows and reads them back, and it saves files into the Drive and reads the text of files Analify made or the member picked. It is how an agent turns what it already read into something the founder can open — "make a sheet of my creatives for the last 20 days" → a Google Sheets link; "save this week's summary to my Drive" → a Google Docs link.

Base paths/api/core/google-sheets (spreadsheets) · /api/core/google-drive (files)
Auththe organization's own stored Google credentials, from its Google Drive & Sheets connection (google_sheets integration; Settings → Integrations → Files & Sheets). You never pass a Google token yourself
Scopeanalytics.reports — a file of the business's numbers or notes is a report leaving Analify
Every requestrequires ?organizationId=<uuid>

Only Analify's files. Google's drive.file permission means Analify can create files and spreadsheets and open the ones it created or the member picked in Analify — never browse or open anything else in the Drive. Any other id answers 404 NOT_FOUND.

Private by default. A new spreadsheet or file lives in the connected account's Drive (ownerEmail in the response) and only that account can open it, unless you pass shareWithLink: true (anyone with the link can view).

API Endpoints

Files in the org's connected Google account — ONE connection, "Google Drive
& Sheets" (platform = 'google_sheets'; Settings → Integrations → Files &
Sheets). Google's drive.file grant means Analify can create files and
spreadsheets and open the ones it created or the member picked in the Google
Picker — never browse or open the rest of the Drive (those answer 404 NOT_FOUND).
Every read and write below stays inside that grant — nothing here needs a wider
Google scope. Deliberately absent: delete, and a standalone "share with link"
(sharing a picked file — e.g. the revenue sheet picked for a Finance import —
would widen who can see it; the only share is the opt-in shareWithLink on a
file Analify just created).
Scope analytics.reports (SCOPE_ROUTES, both /google-sheets and
/google-drive): a file of the business's numbers or notes is a report leaving
Analify.

RouteMethodsWhat
/google-sheets/accountGET{ connected, email } — the Google account new spreadsheets are created in
/google-sheets/spreadsheetsPOSTCreate a spreadsheet. Body { title, tabs: [{ name, headers: string[], rows: (string|number|boolean|null)[][] }], shareWithLink? }. Header rows frozen; cells written as sent (RAW — 1/2 stays text, =SUM() stays text); money as EGP numbers. Private to the connected account unless shareWithLink (anyone with the link can view). → { spreadsheetId, url, title, tabs: [{ name, rows }], ownerEmail, sharedWithLink }
/google-sheets/spreadsheets/{spreadsheetId}GETRead — the spreadsheet's details, no values → { spreadsheetId, url, title, locale, timeZone, tabs: [{ sheetId, title, index, rowCount, columnCount, frozenRowCount }] }
/google-sheets/spreadsheets/{spreadsheetId}/valuesGET, POST, PUTGET ?range= (A1 range or tab name; first tab by default) → { title, tabs, range, values: string[][] }. POST { tab?, rows } appends under the last row → { tab, addedRows, updatedRange }. PUT { range, rows } overwrites cells from the range's top-left cell (RAW) → { updatedRange, updatedRows, updatedColumns, updatedCells }
/google-sheets/spreadsheets/{spreadsheetId}/values/clearPOSTErases every value in { range } (A1 range or a tab name); formatting stays. A write, not a read-style POST → { clearedRange }
/google-sheets/spreadsheets/{spreadsheetId}/tabsPOST, PATCHPOST { name, headers?, rows? } adds a tab at the end (header row frozen) → { sheetId, tab, rows }. PATCH { tab, name } renames a tab by its current name → { sheetId, from, tab }. A name already taken, or an unknown tab, is 400 INVALID_INPUT
/google-drive/filesGET, POSTGET (Read) lists the files Analify can open — created by Analify or picked in Analify, never the rest of the Drive — newest first: ?name= (name contains, ≤ 200 characters) &kind=spreadsheet|document|folder &folderId= (directly inside it) &pageSize= (1–100, default 50) &pageToken= → { files: [{ fileId, name, mimeType, modifiedTime, sizeBytes, parents, url }], nextPageToken }. POST saves a file. Body { name, content, format?: 'google_doc' (default) | 'text' | 'markdown' | 'csv', inAnalifyFolder?: boolean (default true), folderId?, shareWithLink? }. Saved in folderId when sent (a folder Analify can open), else an Analify folder (created once, found again) or the Drive root; a google_doc is converted from the text; the others get .txt / .md / .csv. Private unless shareWithLink. → { fileId, name, url, mimeType, folder, folderId, ownerEmail, sharedWithLink }
/google-drive/files/{fileId}GET, PATCHThe text of a file Analify created or the member picked → { fileId, name, mimeType (the file's own Drive type), url, text, truncated }. Google Docs and Slides as text; Sheets, Excel and CSV as tab-separated rows (one # <tab> block per tab); PDF, Word, text and Markdown as their text — the same parser as Brain files. Capped at 100,000 characters (truncated: true). PATCH { name } (≤ 200 characters) renames a file, spreadsheet or folder Analify can open → { fileId, name, mimeType, url }
/google-drive/foldersPOSTA new folder { name, parentId? } — at the Drive root or inside a folder Analify can open. Each call makes a new one → { folderId, name, url, parentId, ownerEmail }

Limits (enforced before Google is called, 400 INVALID_INPUT): 20 tabs, 10,000
rows per tab, 50 columns, 100,000 cells, title ≤ 200 characters, tab names ≤ 100
characters without [ ] * ? : / \. Google's own quota is 60 writes / minute /
user; a create costs 2 writes, an append, overwrite, clear or tab rename 1, a
new tab 1 (2 with cells). A create, append, new tab or new folder is not
retried
on a Google 5xx (it may already have landed) — it answers 502 UPSTREAM; check the Drive before retrying. Overwrite, clear, rename and the
reads are idempotent and retried once. The same holds for a Drive save
(one upload request; a 5xx is never retried). A Drive save takes a name ≤ 200
characters and content ≤ 2,000,000 characters. Reading takes Google's 10 MB
export cap for Docs / Sheets / Slides and 20 MB for an uploaded file.

Errors: 400 INVALID_INPUT (including Google's own 400 — a range it can't
parse — with Google's reason in the message) · 400 UNSUPPORTED_FILE (read only: an image,
video or other type Analify doesn't read) · 409 NOT_CONNECTED (not connected,
or reconnect) · 404 NOT_FOUND (not a file Analify created or the member
picked) · 403 NO_ACCESS · 413 TOO_LARGE · 502 UPSTREAM.

MCP tools: analify_google_sheets_account_get, analify_google_sheets_create
(write), analify_google_sheets_get, analify_google_sheets_values_get,
analify_google_sheets_append (write), analify_google_sheets_values_update
(write), analify_google_sheets_values_clear (write),
analify_google_sheets_tab_add (write), analify_google_sheets_tab_rename
(write), analify_google_drive_files_list, analify_google_drive_file_get,
analify_google_drive_create (write), analify_google_drive_file_rename
(write), analify_google_drive_folder_create (write). Writes need mcp:write
(analify_call_write_tool); __tests__/workers/mcp-analify/src/google-drive-sheets-catalog.test.ts
fails when a route here has no tool.
The in-app Analify Agent creates through its own approval cards,
create_google_sheet and create_google_drive_file (reports:write), which
run the same validators and Core functions.

Intentionally unrouted: modules/core-api/google-sheets/fetch-sheet.ts
(fetchGoogleSheet(orgId, fileId) → a picked Google Sheet as XLSX bytes, or an
.xlsx / .csv stored in Drive as-is; fetchGoogleDriveFile(orgId, fileId, 'document') → any file the Brain reads). Consumers reach it through their own
routes: Finance imports take { googleSheet: { fileId } }, Brain files take
{ googleDrive: { fileId } } (or googleSheet). Connection management is
/api/integrations/google_sheets/* (Settings → Integrations → Files & Sheets).

Detailed examples for the original routes follow.

Account

GET /api/core/google-sheets/account

curl "https://analify.scalyax.ai/api/core/google-sheets/account?organizationId={organizationId}" \
  -H "Authorization: Bearer {anlfy_token}"
{ "success": true, "data": { "connected": true, "email": "[email protected]" } }

Check this before creating a sheet or a file. When connected is false, a member connects Google Drive & Sheets in Analify — it cannot be connected through the API.

Spreadsheets

POST /api/core/google-sheets/spreadsheets

curl -X POST "https://analify.scalyax.ai/api/core/google-sheets/spreadsheets?organizationId={organizationId}" \
  -H "Authorization: Bearer {anlfy_token}" -H "Content-Type: application/json" \
  -d '{
    "title": "Creatives — 24 Sep to 13 Oct 2026",
    "tabs": [
      {
        "name": "Creatives",
        "headers": ["Ad", "Spend (EGP)", "Purchases", "ROAS"],
        "rows": [["Review ad", 12450.5, 38, 2.4], ["Summer video", 8300, 11, 0.9]]
      }
    ],
    "shareWithLink": false
  }'
FieldTypeNotes
titlestringRequired, up to 200 characters
tabs[].namestringUp to 100 characters, no [ ] * ? : / \; Sheet1… when blank
tabs[].headersstring[]The first row — frozen in the sheet
tabs[].rows(string | number | boolean | null)[][]Cells written exactly as sent (RAW): 1/2 stays text, =SUM(…) stays text. Put money in as numbers in a stated currency (EGP), not piasters
shareWithLinkbooleanOptional, default false
{
  "success": true,
  "data": {
    "spreadsheetId": "1Gqrta2v…",
    "url": "https://docs.google.com/spreadsheets/d/1Gqrta2v…/edit",
    "title": "Creatives — 24 Sep to 13 Oct 2026",
    "tabs": [{ "name": "Creatives", "rows": 2 }],
    "ownerEmail": "[email protected]",
    "sharedWithLink": false
  }
}

Limits (checked before Google is called, 400 INVALID_INPUT): 20 tabs, 10,000 rows per tab, 50 columns, 100,000 cells per spreadsheet.

⚠️

Call it once. Every call creates a new file. A Google 5xx is not retried (the file may already exist) — it answers 502 UPSTREAM; check the Drive before trying again.

Values

GET /api/core/google-sheets/spreadsheets/{spreadsheetId}/values

Optional ?range= — an A1 range (Creatives!A1:F50) or a tab name; the first tab when omitted. Every cell comes back as text.

curl "https://analify.scalyax.ai/api/core/google-sheets/spreadsheets/{spreadsheetId}/values?organizationId={organizationId}&range=Creatives!A1:D20" \
  -H "Authorization: Bearer {anlfy_token}"
{ "success": true, "data": { "spreadsheetId": "…", "url": "…", "title": "…", "tabs": ["Creatives"], "range": "Creatives!A1:D3", "values": [["Ad", "Spend (EGP)"], ["Review ad", "12450.5"]] } }

POST /api/core/google-sheets/spreadsheets/{spreadsheetId}/values

Adds rows under the last row of a tab (the first tab when tab is omitted). Same cell rules as create.

curl -X POST "https://analify.scalyax.ai/api/core/google-sheets/spreadsheets/{spreadsheetId}/values?organizationId={organizationId}" \
  -H "Authorization: Bearer {anlfy_token}" -H "Content-Type: application/json" \
  -d '{ "tab": "Creatives", "rows": [["New ad", 900, 3, 1.6]] }'
{ "success": true, "data": { "tab": "Creatives", "addedRows": 1, "updatedRange": "'Creatives'!A4:D4", "url": "…" } }
⚠️

Appending twice adds the rows twice. A Google 5xx is not retried.

Drive files

POST /api/core/google-drive/files

curl -X POST "https://analify.scalyax.ai/api/core/google-drive/files?organizationId={organizationId}" \
  -H "Authorization: Bearer {anlfy_token}" -H "Content-Type: application/json" \
  -d '{
    "name": "Weekly summary — 6 to 12 Oct 2026",
    "content": "Sales: 48,200 EGP across 121 orders.\nAd spend: 14,900 EGP.",
    "format": "google_doc"
  }'
FieldTypeNotes
namestringRequired, up to 200 characters. .txt / .md / .csv is added for those formats
contentstringRequired, the file's text, up to 2,000,000 characters. Write numbers exactly as a read returned them, money in a stated currency (EGP)
formatgoogle_doc | text | markdown | csvOptional, default google_doc — the text becomes a Google Doc
inAnalifyFolderbooleanOptional, default true — saved in an "Analify" folder (created once, then reused); false saves at the Drive root
shareWithLinkbooleanOptional, default false
{
  "success": true,
  "data": {
    "fileId": "11AsWCTg…",
    "name": "Weekly summary — 6 to 12 Oct 2026",
    "url": "https://docs.google.com/document/d/11AsWCTg…/edit",
    "mimeType": "application/vnd.google-apps.document",
    "folder": "Analify",
    "ownerEmail": "[email protected]",
    "sharedWithLink": false
  }
}
⚠️

Call it once. Every call creates a new file. A Google 5xx is not retried (the file may already exist) — it answers 502 UPSTREAM; check the Drive before trying again.

GET /api/core/google-drive/files/{fileId}

The text of a file Analify created or the member picked: Google Docs and Slides as text; Google Sheets, Excel and CSV as tab-separated rows (one # <tab> block per tab); PDF, Word, text and Markdown as their text — the same reader as Brain files. Cut at 100,000 characters (truncated: true). Google exports up to 10 MB; an uploaded file up to 20 MB.

curl "https://analify.scalyax.ai/api/core/google-drive/files/{fileId}?organizationId={organizationId}" \
  -H "Authorization: Bearer {anlfy_token}"
{ "success": true, "data": { "fileId": "…", "name": "Return policy.txt", "mimeType": "application/vnd.google-apps.document", "url": "https://drive.google.com/file/d/…/view", "text": "Returns are accepted within 14 days…", "truncated": false } }

Error Shape

CodeStatusMeaning
INVALID_INPUT400Malformed body, a bad tab name or format, or over a limit
UNSUPPORTED_FILE400Reading a Drive file Analify doesn't read (an image, a video), or one with no text
NOT_CONNECTED409Google Drive & Sheets isn't connected for this organization, or it needs reconnecting
NO_ACCESS403The connected Google account can't open or edit that file
NOT_FOUND404Not a file Analify created or the member picked
TOO_LARGE413More than Google accepts in one request
UPSTREAM502Google didn't answer — for anything that creates or appends, check the Drive before retrying

Rate limits

Google allows 60 write requests per minute per Google account. A create costs 2 writes (the file, then every tab's cells in one batch); an append costs 1. A Drive save is one request, under Drive's own, much larger quota.

MCP and the Analify Agent

ChatGPT, Claude and other MCP clients reach these routes as analify_google_sheets_account_get, analify_google_sheets_create (write), analify_google_sheets_values_get, analify_google_sheets_append (write), analify_google_drive_file_get and analify_google_drive_create (write). In the Analify app, the Agent creates a sheet or saves a Drive file through an approval card the founder confirms, then replies with the link.


Did this page help you?