{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Import & Export: Append & Upsert",
    "description": "Send an Apify dataset or JSON to a Google Sheet, or pull a tab back into a dataset. Append, upsert by key without touching your own columns, or replace with an automatic backup. Service-account auth for unattended schedules, Google-recommended retries and a 10M-cell check before writing.",
    "version": "0.1",
    "x-build-id": "yd9OIYhdyApN2aMib"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/drop_data_solutions~google-sheets-io/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-drop_data_solutions-google-sheets-io",
        "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/drop_data_solutions~google-sheets-io/runs": {
      "post": {
        "operationId": "runs-sync-drop_data_solutions-google-sheets-io",
        "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/drop_data_solutions~google-sheets-io/run-sync": {
      "post": {
        "operationId": "run-sync-drop_data_solutions-google-sheets-io",
        "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": [
          "spreadsheet"
        ],
        "properties": {
          "operation": {
            "title": "What to do",
            "enum": [
              "import",
              "export"
            ],
            "type": "string",
            "description": "Import writes a dataset/JSON into a sheet (needs credentials). Export reads a tab or range into this run's dataset; public sheets (\"Anyone with the link: Viewer\") can be exported without credentials. The prefilled example exports Google's public sample sheet.",
            "default": "import"
          },
          "spreadsheet": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Paste the address bar URL (https://docs.google.com/spreadsheets/d/.../edit). If the URL contains #gid=..., that tab is used when no tab name is set. The prefill is Google's public sample spreadsheet, so a first run works without any setup."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "Tab to write to or read from. Created automatically on import if missing. Default: the tab in the URL's #gid, else the first tab."
          },
          "serviceAccountJson": {
            "title": "Service account JSON key (recommended)",
            "type": "string",
            "description": "Paste the full contents of the JSON key file (raw or base64). Stored encrypted by Apify. Required for import; for export it's only needed when the sheet isn't public."
          },
          "oauthClientId": {
            "title": "OAuth client ID (optional alternative)",
            "type": "string",
            "description": "Only if you cannot use a service account. Needs client ID, client secret and a refresh token with the spreadsheets scope."
          },
          "oauthClientSecret": {
            "title": "OAuth client secret",
            "type": "string",
            "description": "OAuth client secret."
          },
          "oauthRefreshToken": {
            "title": "OAuth refresh token",
            "type": "string",
            "description": "Long-lived refresh token. Note: apps in Google's 'Testing' mode expire refresh tokens after 7 days."
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "An Apify dataset, e.g. a scraper run's default dataset. In an integration/webhook use {{resource.defaultDatasetId}}."
          },
          "data": {
            "title": "JSON data",
            "type": "array",
            "description": "Array of objects ([{\"name\":\"A\"}]) or array of arrays with a header row first ([[\"name\"],[\"A\"]]). Max ~9 MB (Apify input limit); use a dataset for more."
          },
          "dataUrl": {
            "title": "JSON URL",
            "type": "string",
            "description": "Public URL returning a JSON array (or {\"items\": [...]})."
          },
          "writeMode": {
            "title": "Write mode",
            "enum": [
              "append",
              "upsert",
              "replace"
            ],
            "type": "string",
            "description": "Append only adds rows (and new columns on the right for new fields); it doesn't clear existing data. Upsert only touches the columns your data has, so your own notes/formula columns are left as they are. Replace saves a BACKUP record first and refuses to run on empty input unless you allow it.",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key columns (upsert)",
            "type": "array",
            "description": "Field(s) that identify a row, e.g. url or id. Several fields form a composite key. Matching ignores surrounding spaces.",
            "items": {
              "type": "string"
            }
          },
          "columns": {
            "title": "Columns to include (and order)",
            "type": "array",
            "description": "Field names from your data, in the order you want. Nested fields use dots: price.value. Default: all fields in first-seen order.",
            "items": {
              "type": "string"
            }
          },
          "excludeColumns": {
            "title": "Columns to exclude",
            "type": "array",
            "description": "Field names to leave out.",
            "items": {
              "type": "string"
            }
          },
          "headerMap": {
            "title": "Header mapping",
            "type": "object",
            "description": "Rename fields to sheet headers: {\"title\": \"Product name\", \"price.value\": \"Price\"}. Key columns may use either name."
          },
          "flattenArrays": {
            "title": "Arrays",
            "enum": [
              "json",
              "index"
            ],
            "type": "string",
            "description": "How arrays inside items become cells. Nested objects are flattened into dotted columns (up to 5 levels deep; anything deeper is stored as JSON text).",
            "default": "json"
          },
          "parseValuesAsTyped": {
            "title": "Let Google parse values (USER_ENTERED)",
            "type": "boolean",
            "description": "Off (default): values are stored exactly as sent (RAW), so scraped text starting with '=' is stored as text, not evaluated as a formula. On: Google parses dates, currency and formulas as if you typed them in.",
            "default": false
          },
          "allowEmptyReplace": {
            "title": "Allow empty replace",
            "type": "boolean",
            "description": "Replace mode with zero input rows normally stops to protect your sheet. Enable to clear the tab intentionally.",
            "default": false
          },
          "backupBeforeReplace": {
            "title": "Backup before replace",
            "type": "boolean",
            "description": "Save the old tab contents to the key-value store record BACKUP before replacing.",
            "default": true
          },
          "range": {
            "title": "Range to export (A1)",
            "type": "string",
            "description": "e.g. Leads!A1:F or 'My tab'!B2:H500. Default: the whole tab."
          },
          "hasHeaderRow": {
            "title": "First row is the header",
            "type": "boolean",
            "description": "Use the first row as field names (blank headers become column_N, duplicates name_2).",
            "default": true
          },
          "skipEmptyRows": {
            "title": "Skip empty rows",
            "type": "boolean",
            "description": "Drop rows where every cell is empty.",
            "default": true
          },
          "exportFormattedValues": {
            "title": "Export formatted values",
            "type": "boolean",
            "description": "On: '$1,234.50' as displayed. Off: raw numbers (1234.5).",
            "default": false
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many rows (0 = no limit). Also capped automatically by your max cost per run."
          },
          "offset": {
            "title": "Skip first N items",
            "minimum": 0,
            "type": "integer",
            "description": "Import only: skip this many input items.",
            "default": 0
          },
          "dryRun": {
            "title": "Dry run",
            "type": "boolean",
            "description": "Connect, read and plan (rows to append/update, columns to add) without writing anything or being charged per row.",
            "default": false
          },
          "requestsPerMinute": {
            "title": "Max Google API requests per minute",
            "minimum": 1,
            "maximum": 300,
            "type": "integer",
            "description": "Google allows 60 per minute per user per project; 55 leaves headroom. Lower it if other tools share your Google Cloud project.",
            "default": 55
          },
          "maxRetries": {
            "title": "Max retries per request",
            "minimum": 0,
            "maximum": 15,
            "type": "integer",
            "description": "Retries for 429/5xx/network errors with exponential backoff (1s, 2s, 4s ... capped at 64s).",
            "default": 8
          },
          "batchRows": {
            "title": "Max rows per request",
            "minimum": 1,
            "type": "integer",
            "description": "Upper bound of rows per write request.",
            "default": 5000
          },
          "maxCellsPerRequest": {
            "title": "Max cells per request",
            "minimum": 100,
            "type": "integer",
            "description": "Keeps each request near Google's recommended 2 MB payload.",
            "default": 40000
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}