{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Export Pro: Append, Upsert & Replace",
    "description": "Export Apify datasets or JSON to Google Sheets reliably: append, upsert by key (no duplicates) or replace. Batched, auto-retry on 429, resumable. Pay per row.",
    "version": "0.1",
    "x-build-id": "QbETWZf6covT9rP9n"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/grace_hartwell~google-sheets-export-pro/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-grace_hartwell-google-sheets-export-pro",
        "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/grace_hartwell~google-sheets-export-pro/runs": {
      "post": {
        "operationId": "runs-sync-grace_hartwell-google-sheets-export-pro",
        "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/grace_hartwell~google-sheets-export-pro/run-sync": {
      "post": {
        "operationId": "run-sync-grace_hartwell-google-sheets-export-pro",
        "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",
        "required": [
          "spreadsheetId"
        ],
        "properties": {
          "datasetId": {
            "title": "Dataset",
            "type": "string",
            "description": "The Apify dataset to export, e.g. the default dataset of a scraper run. The picker grants this run READ access to exactly this dataset (limited permissions). In integrations, pass {{resource.defaultDatasetId}}."
          },
          "items": {
            "title": "Items (JSON) – instead of a dataset",
            "type": "array",
            "description": "Array of JSON objects to export, e.g. from n8n, Make or your own code. Use either this or \"Dataset\"."
          },
          "datasetOffset": {
            "title": "Skip first N items",
            "minimum": 0,
            "type": "integer",
            "description": "Start at this item index (for splitting very large exports).",
            "default": 0
          },
          "datasetLimit": {
            "title": "Max items to read",
            "minimum": 1,
            "type": "integer",
            "description": "Read at most this many items. Empty = all."
          },
          "spreadsheetId": {
            "title": "Spreadsheet ID or URL",
            "type": "string",
            "description": "Paste the Google Sheets URL (https://docs.google.com/spreadsheets/d/<ID>/edit#gid=0) or just the ID. A #gid in the URL selects that tab when \"Sheet (tab) name\" is empty."
          },
          "sheetName": {
            "title": "Sheet (tab) name",
            "type": "string",
            "description": "Tab to write to, e.g. \"Leads\". Empty = the tab from the URL's #gid, otherwise the first tab."
          },
          "createSheetIfMissing": {
            "title": "Create the tab if missing",
            "type": "boolean",
            "description": "Creates the tab named above when it does not exist yet.",
            "default": true
          },
          "mode": {
            "title": "Write mode",
            "enum": [
              "append",
              "upsert",
              "replace"
            ],
            "type": "string",
            "description": "append: add rows below the existing data. upsert: update rows whose key already exists and append new ones – no duplicates, ideal for scheduled scrapers. replace: overwrite the tab with this data (old rows below are cleared).",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key column(s) (upsert)",
            "type": "array",
            "description": "Column(s) that identify a row, e.g. [\"url\"] or [\"shop\", \"product.id\"] (dot notation for nested fields). Required for upsert.",
            "items": {
              "type": "string"
            }
          },
          "skipUnchangedRows": {
            "title": "Skip unchanged rows (upsert)",
            "type": "boolean",
            "description": "Do not rewrite (or charge) rows whose values are already identical in the sheet.",
            "default": true
          },
          "missingFieldsOnUpdate": {
            "title": "Fields missing in an item (upsert)",
            "enum": [
              "keep",
              "clear"
            ],
            "type": "string",
            "description": "keep: leave the existing cell untouched. clear: empty the cell.",
            "default": "keep"
          },
          "rowsWithoutKey": {
            "title": "Items without a key value (upsert)",
            "enum": [
              "skip",
              "append"
            ],
            "type": "string",
            "description": "What to do with items whose key column(s) are all empty.",
            "default": "skip"
          },
          "caseInsensitiveKeys": {
            "title": "Case-insensitive keys",
            "type": "boolean",
            "description": "Treat \"ABC\" and \"abc\" as the same key.",
            "default": false
          },
          "trimKeys": {
            "title": "Trim whitespace in keys",
            "type": "boolean",
            "description": "Ignore leading/trailing spaces when matching keys.",
            "default": true
          },
          "columns": {
            "title": "Columns (order / whitelist)",
            "type": "array",
            "description": "Column order for the header, e.g. [\"title\", \"price.value\", \"url\"]. Other columns follow unless \"Only listed columns\" is on.",
            "items": {
              "type": "string"
            }
          },
          "onlyListedColumns": {
            "title": "Only listed columns",
            "type": "boolean",
            "description": "Export only the columns listed above (plus key columns).",
            "default": false
          },
          "headerMode": {
            "title": "Header handling",
            "enum": [
              "merge",
              "existing-only"
            ],
            "type": "string",
            "description": "merge: keep the existing header and add new columns at the end. existing-only: never add columns; fields without a column are dropped (reported in the summary).",
            "default": "merge"
          },
          "flattenObjects": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "{\"price\":{\"value\":9}} becomes column price.value. Off = JSON text in one cell.",
            "default": true
          },
          "arrayMode": {
            "title": "Arrays",
            "enum": [
              "join",
              "json",
              "index"
            ],
            "type": "string",
            "description": "join: [\"a\",\"b\"] → \"a, b\" (arrays of objects become JSON). json: JSON text. index: tags.0, tags.1 … columns.",
            "default": "join"
          },
          "arraySeparator": {
            "title": "Array separator",
            "type": "string",
            "description": "Separator for joined arrays.",
            "default": ", "
          },
          "maxDepth": {
            "title": "Max flatten depth",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "Deeper objects are written as JSON text.",
            "default": 10
          },
          "valueInputOption": {
            "title": "Value input option",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW: values are stored exactly as sent (safest; numbers stay numbers). USER_ENTERED: Google parses values like typed by a user (dates, percentages). Key cells always stay text.",
            "default": "RAW"
          },
          "escapeFormulas": {
            "title": "Write formulas as text (USER_ENTERED)",
            "type": "boolean",
            "description": "Prevents scraped values starting with \"=\" from being executed as formulas.",
            "default": true
          },
          "freezeHeaderRow": {
            "title": "Freeze header row",
            "type": "boolean",
            "description": "Freeze row 1 when the Actor writes the header into an empty tab.",
            "default": true
          },
          "serviceAccountKey": {
            "title": "Service account key (JSON)",
            "type": "string",
            "description": "Paste the full JSON key of a Google Cloud service account (Google Cloud Console → IAM & Admin → Service accounts → Keys → Add key → JSON). Enable the Google Sheets API in that project and share the spreadsheet with the key's client_email as Editor. Stored encrypted, never logged."
          },
          "oauthAccessToken": {
            "title": "OAuth access token (alternative)",
            "type": "string",
            "description": "Optional instead of a service account: a Google OAuth 2.0 access token with scope https://www.googleapis.com/auth/spreadsheets (valid ~1 hour, so not suited for schedules). Never logged."
          },
          "batchSize": {
            "title": "Batch size (rows per request)",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Rows per write request. Requests are additionally split at ~2 MB. Larger = fewer API calls.",
            "default": 1000
          },
          "maxRequestsPerMinute": {
            "title": "Max requests per minute",
            "minimum": 1,
            "maximum": 300,
            "type": "integer",
            "description": "Client-side throttle below Google's default quota of 60 requests per minute per user. 429 responses are retried with exponential backoff anyway.",
            "default": 50
          },
          "maxRowsToWrite": {
            "title": "Max rows to write",
            "minimum": 1,
            "type": "integer",
            "description": "Stop after this many rows were appended/updated. Empty = no limit (your max total charge is respected anyway)."
          },
          "dryRun": {
            "title": "Dry run",
            "type": "boolean",
            "description": "Check access and compute what would be appended/updated without writing or charging anything. Works without credentials as an offline column preview.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}