{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Sync: Append, Upsert & Dedupe Any Dataset",
    "description": "Export any Apify dataset or JSON to Google Sheets. Append that really appends, upsert by key, dedupe, auto-added columns, 10M-cell guard and plain-English errors. Works as an integration after any scraper. Uses your own service account.",
    "version": "0.1",
    "x-build-id": "E6M8e4uYjubJlsl8s"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/panthalus~google-sheets-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-panthalus-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/panthalus~google-sheets-sync/runs": {
      "post": {
        "operationId": "runs-sync-panthalus-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/panthalus~google-sheets-sync/run-sync": {
      "post": {
        "operationId": "run-sync-panthalus-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",
        "required": [
          "spreadsheetId"
        ],
        "properties": {
          "spreadsheetId": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Paste the spreadsheet URL from your browser (https://docs.google.com/spreadsheets/d/.../edit) or just the long ID between /d/ and /edit. If the URL ends in #gid=..., that tab is used when \"Tab name\" is empty. The prefilled link is Google's read-only sample sheet: with no key it gives a free demo dry run."
          },
          "serviceAccountKey": {
            "title": "Service account key (JSON)",
            "type": "string",
            "description": "Paste the whole content of your Google service-account .json key file. Stored encrypted by Apify, never logged or returned. Share the spreadsheet with the service account's email (client_email in the key) as Editor. Setup steps are in the README."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "Tab (sheet) to write to or read from. Created if it doesn't exist. Empty = the tab in the URL's #gid, else the first tab."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "upsert",
              "read"
            ],
            "type": "string",
            "description": "append: add rows below existing data. replace: clear the tab and write the new data (the tab is left untouched if there is no data). upsert: update rows whose key columns match, append the rest. read: copy the tab into this run's dataset.",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key columns",
            "type": "array",
            "description": "Column(s) that identify a row, e.g. url, or sku + store. Required for upsert; with dedupe in append mode, rows whose key is already in the sheet are skipped. Nested fields use dot notation (address.city).",
            "items": {
              "type": "string"
            }
          },
          "dedupe": {
            "title": "Skip duplicates",
            "type": "boolean",
            "description": "Skip rows already in the sheet and repeated rows within this run. Without key columns, a row is a duplicate when all its values match an existing row; with key columns, when its key matches.",
            "default": false
          },
          "datasetId": {
            "title": "Dataset",
            "type": "string",
            "description": "Apify dataset to export (ID or username~name). When this Actor is added as an integration, the triggering run's dataset is used automatically."
          },
          "items": {
            "title": "Items (JSON array)",
            "type": "array",
            "description": "Rows as a JSON array of objects, e.g. [{\"name\": \"A\", \"price\": 1}]. Handy for API and AI-agent calls."
          },
          "jsonUrl": {
            "title": "JSON URL",
            "type": "string",
            "description": "URL that returns a JSON array, an object with an items/data/results array, or JSON Lines. Max 200 MB."
          },
          "fields": {
            "title": "Columns to export (and their order)",
            "type": "array",
            "description": "Only these fields, in this order. Empty = all fields. Key columns are always included.",
            "items": {
              "type": "string"
            }
          },
          "flatten": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "Nested objects become dot.notation columns (address.city) and arrays of plain values are joined into one cell. Arrays of objects are stored as compact JSON. Off = nested values stored as JSON text.",
            "default": true
          },
          "arraySeparator": {
            "title": "Array separator",
            "type": "string",
            "description": "Text placed between array values when flattening, e.g. \", \" or \" | \".",
            "default": ", "
          },
          "valueInputOption": {
            "title": "How Google stores values",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW (recommended): text is stored exactly as given, so scraped text starting with = is never run as a formula. USER_ENTERED: Google parses values like a person typing (dates, currencies, formulas).",
            "default": "RAW"
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 1,
            "type": "integer",
            "description": "Process at most this many input rows (write modes) or sheet rows (read mode). Empty = all."
          },
          "maxRowsPerTab": {
            "title": "Max rows per tab (rollover)",
            "minimum": 1,
            "type": "integer",
            "description": "When a tab holds this many data rows, continue in a new tab named \"<Tab name> (2)\", \"(3)\"... Upsert and dedupe look across all of them. Empty = no limit."
          },
          "batchSize": {
            "title": "Rows per request",
            "minimum": 1,
            "maximum": 5000,
            "type": "integer",
            "description": "Rows sent to Google per write request (also capped at about 2 MB). Lower it if your rows are very wide.",
            "default": 1000
          },
          "dryRun": {
            "title": "Dry run",
            "type": "boolean",
            "description": "Validate everything and report what would change (rows to append/update/skip, new columns, tabs, a preview) without writing anything. Only the start fee is charged. Works even without a key (checks the data only).",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}