{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Sync: Import, Export, Append & Upsert",
    "description": "Send any Apify dataset to Google Sheets, or pull a sheet into a dataset. Append, append-only-new, upsert or replace, with retries, batching and plain-English errors. Service account, no OAuth. Drop-in for old Google Sheets actor inputs.",
    "version": "1.0",
    "x-build-id": "2hbCQN5BCfYZZL9D4"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rationalistic_canoe~google-sheets-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rationalistic_canoe-google-sheets-sync",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/rationalistic_canoe~google-sheets-sync/runs": {
      "post": {
        "operationId": "runs-sync-rationalistic_canoe-google-sheets-sync",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/rationalistic_canoe~google-sheets-sync/run-sync": {
      "post": {
        "operationId": "run-sync-rationalistic_canoe-google-sheets-sync",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "mode": {
            "title": "What to do",
            "enum": [
              "export",
              "import",
              "append",
              "replace",
              "modify",
              "read",
              "load backup"
            ],
            "type": "string",
            "description": "<b>Export</b>: write a dataset (or raw JSON) into a sheet. <b>Import</b>: read a sheet into this run's dataset. The default (import a public sample sheet) runs with no setup so you can see the output first. The \"Old actor\" modes accept the same fields as the OAuth-based Google Sheets actor, so existing tasks keep working once you add a service-account key.",
            "default": "import"
          },
          "spreadsheet": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Paste the sheet's browser URL. If it contains <code>#gid=…</code> that tab is used."
          },
          "sheetName": {
            "title": "Sheet (tab) name",
            "type": "string",
            "description": "Tab to read or write. Empty = the tab in the URL, or the first tab."
          },
          "authMode": {
            "title": "Authentication",
            "enum": [
              "serviceAccount",
              "apiKey",
              "public"
            ],
            "type": "string",
            "description": "<b>Service account</b>: read and write, works with private sheets (share the sheet with the service account's email). <b>API key</b>: read-only, sheet must be shared as 'Anyone with the link'. <b>Public link</b>: read-only, no credentials at all.",
            "default": "public"
          },
          "serviceAccountKey": {
            "title": "Service account JSON key",
            "type": "string",
            "description": "Paste the whole JSON key file. Stored encrypted. See the README for the 3-minute setup."
          },
          "apiKey": {
            "title": "Google API key",
            "type": "string",
            "description": "Only for API-key mode. Enable the Google Sheets API for the key's project."
          },
          "datasetId": {
            "title": "Dataset ID (export)",
            "type": "string",
            "description": "Dataset to export. When this actor runs as an integration after another actor, leave empty and the finished run's dataset is used."
          },
          "rawData": {
            "title": "Raw data (export)",
            "type": "array",
            "description": "Alternative to a dataset: a JSON array of objects, or an array of arrays with the header first."
          },
          "writeMode": {
            "title": "Write mode",
            "enum": [
              "append",
              "appendNew",
              "upsert",
              "replace"
            ],
            "type": "string",
            "description": "<b>Append</b>: add rows at the bottom. <b>Append only new</b>: skip rows whose key columns already exist in the sheet. <b>Upsert</b>: update rows with a matching key in place, add the rest. <b>Replace</b>: back up, clear the tab and write fresh.",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key columns",
            "type": "array",
            "description": "Field(s) that identify a row, e.g. url or sku. Required for 'Append only new' and 'Upsert'; also used to remove duplicates from the input.",
            "items": {
              "type": "string"
            }
          },
          "dedupeInput": {
            "title": "Remove duplicates from the input",
            "type": "boolean",
            "description": "Drop repeated items (by key columns, or identical rows if no key is set) before writing.",
            "default": true
          },
          "fields": {
            "title": "Fields to export",
            "type": "array",
            "description": "Only export these fields (after flattening, e.g. address/city). Empty = all.",
            "items": {
              "type": "string"
            }
          },
          "omitFields": {
            "title": "Fields to leave out",
            "type": "array",
            "description": "Fields never written to the sheet.",
            "items": {
              "type": "string"
            }
          },
          "columnsOrder": {
            "title": "Column order for new columns",
            "type": "array",
            "description": "Order for columns this actor creates. Existing sheet columns are never reordered.",
            "items": {
              "type": "string"
            }
          },
          "addNewColumns": {
            "title": "Add new fields as new columns",
            "type": "boolean",
            "description": "When the data has fields the sheet doesn't, add them at the right. Off = ignore them.",
            "default": true
          },
          "parseValues": {
            "title": "Let Google parse values (formulas, dates, currency)",
            "type": "boolean",
            "description": "Off (recommended for scraped data): every value is written exactly as-is, so text like '=IMPORTXML(…)' can never run as a formula. On: Google interprets values as if typed by a user.",
            "default": false
          },
          "flattenArrays": {
            "title": "Arrays",
            "enum": [
              "expand",
              "join",
              "json"
            ],
            "type": "string",
            "description": "How to write lists: one column per item (tags/0, tags/1…), joined in one cell, or as JSON.",
            "default": "expand"
          },
          "createSheet": {
            "title": "Create the tab if missing",
            "type": "boolean",
            "description": "When exporting to a tab name that does not exist yet, create it.",
            "default": true
          },
          "backupBeforeReplace": {
            "title": "Back up before replacing",
            "type": "boolean",
            "description": "Saves the old tab contents to the key-value store record BACKUP before a Replace.",
            "default": true
          },
          "dryRun": {
            "title": "Dry run (preview only)",
            "type": "boolean",
            "description": "Shows what would be appended/updated/skipped without writing anything.",
            "default": false
          },
          "datasetOffset": {
            "title": "Skip first N dataset items",
            "minimum": 0,
            "type": "integer",
            "description": "Start exporting from this item index.",
            "default": 0
          },
          "datasetLimit": {
            "title": "Max dataset items",
            "minimum": 0,
            "type": "integer",
            "description": "0 = all.",
            "default": 0
          },
          "range": {
            "title": "Range (import)",
            "type": "string",
            "description": "Optional A1 range inside the tab, e.g. A1:F500. Empty = whole tab."
          },
          "headerRow": {
            "title": "Header row number",
            "minimum": 1,
            "type": "integer",
            "description": "Row that holds the column names (usually 1).",
            "default": 1
          },
          "valueRender": {
            "title": "Values as",
            "enum": [
              "UNFORMATTED_VALUE",
              "FORMATTED_VALUE",
              "FORMULA"
            ],
            "type": "string",
            "description": "How cell values are returned when importing with a service account or API key.",
            "default": "UNFORMATTED_VALUE"
          },
          "inferTypes": {
            "title": "Detect numbers and true/false",
            "type": "boolean",
            "description": "For public-link mode (CSV): turn '42' into 42 and 'TRUE' into true. Codes with leading zeros stay text.",
            "default": true
          },
          "skipEmptyRows": {
            "title": "Skip empty rows",
            "type": "boolean",
            "description": "Leave out rows where every cell is empty.",
            "default": true
          },
          "importLimit": {
            "title": "Max rows to import",
            "minimum": 0,
            "type": "integer",
            "description": "0 = all.",
            "default": 0
          },
          "rowsPerRequest": {
            "title": "Rows per request",
            "minimum": 100,
            "maximum": 20000,
            "type": "integer",
            "description": "Batch size for writes (also capped at ~4 MB per request).",
            "default": 5000
          },
          "requestsPerMinute": {
            "title": "Max Google API requests per minute",
            "minimum": 1,
            "maximum": 300,
            "type": "integer",
            "description": "Google's default per-user quota is 60/min. Lower this if several runs write to the same sheet.",
            "default": 55
          },
          "deduplicateByField": {
            "title": "Deduplicate by field (old actor)",
            "type": "string",
            "description": "Rows with the same value in this field are kept once. In append mode only rows whose value is not already in the sheet are added."
          },
          "deduplicateByEquality": {
            "title": "Deduplicate by equality (old actor)",
            "type": "boolean",
            "description": "Identical rows (same non-empty values) are kept once, across the sheet and the new data."
          },
          "transformFunction": {
            "title": "Transform function (old actor)",
            "type": "string",
            "description": "({ spreadsheetData, datasetData }) => rows. Its result replaces the tab. Runs with a 30-second limit; must return an array directly."
          },
          "createBackup": {
            "title": "Back up the tab first (old actor)",
            "type": "boolean",
            "description": "Saves the current rows to the key-value store records \"backup\" and \"BACKUP\" before the tab is rewritten."
          },
          "backupStore": {
            "title": "Backup store ID (old actor, load backup)",
            "type": "string",
            "description": "Key-value store that holds the backup to restore."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}