{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Sync: Import, Export & Upsert Datasets",
    "description": "Export any Apify dataset or actor run to Google Sheets, or import a sheet into a dataset: append, replace, upsert by key or mirror sync, retried through Google's rate limits. Runs after any actor as an integration. Share the sheet once; no Google sign-in. $0.10 per 1,000 rows.",
    "version": "0.1",
    "x-build-id": "GxuZ7pD8rVITeWyzt"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/cleanpull~google-sheets-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-cleanpull-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/cleanpull~google-sheets-sync/runs": {
      "post": {
        "operationId": "runs-sync-cleanpull-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/cleanpull~google-sheets-sync/run-sync": {
      "post": {
        "operationId": "run-sync-cleanpull-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": {
          "spreadsheet": {
            "title": "Spreadsheet",
            "pattern": "^(|\\s*[A-Za-z0-9_-]{20,}\\s*|.*/spreadsheets/d/[A-Za-z0-9_-]+.*)$",
            "type": "string",
            "description": "The Google Sheets URL (or its id). Share the spreadsheet with cleanpull-sheets-1@cleanpull-sheets.iam.gserviceaccount.com as Editor first (Share → add the address → Editor). A URL ending in #gid=… writes to that tab. Leave it empty to preview the rows a run would write, free, without writing anything."
          },
          "tab": {
            "title": "Tab",
            "type": "string",
            "description": "Tab name; created if missing. Placeholders: {date}, {datetime}, {runId}, and {value} with \"Split into tabs by field\". Empty: the tab in the URL, or the first tab."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "upsert",
              "sync",
              "read",
              "modify",
              "backup",
              "restore",
              "clear",
              "load backup"
            ],
            "type": "string",
            "description": "What to do with the tab.",
            "default": "append"
          },
          "keyFields": {
            "title": "Key fields (upsert, sync, incremental)",
            "type": "array",
            "description": "Field(s) that identify a row, e.g. sku, or url. Needed for upsert and sync.",
            "items": {
              "type": "string"
            }
          },
          "onRemoved": {
            "title": "Rows that are gone (sync)",
            "enum": [
              "delete",
              "move",
              "mark"
            ],
            "type": "string",
            "description": "What sync does with sheet rows whose key is no longer in the data.",
            "default": "delete"
          },
          "datasetId": {
            "title": "Dataset",
            "type": "string",
            "description": "The id of an Apify dataset. Any size: it is read in pages. When this actor runs after another one through an Apify integration, the finished run's dataset is used automatically."
          },
          "runId": {
            "title": "Run",
            "type": "string",
            "description": "Or: an Apify run id; its dataset is written."
          },
          "actorId": {
            "title": "Actor (its last successful run)",
            "type": "string",
            "description": "Or: an actor id or name (e.g. cleanpull/amazon-bestsellers-tracker); its last successful run's dataset is written."
          },
          "taskId": {
            "title": "Task (its last successful run)",
            "type": "string",
            "description": "Or: a saved task id; its last successful run's dataset is written."
          },
          "url": {
            "title": "URL (JSON or CSV)",
            "type": "string",
            "description": "Or: a URL returning a JSON array or a CSV file."
          },
          "rawData": {
            "title": "Raw data",
            "type": "array",
            "description": "Or: rows given here as a JSON array of objects. Without a spreadsheet, the run previews the rows it would write (in the dataset, free)."
          },
          "keyValueRecord": {
            "title": "Key-value record",
            "type": "object",
            "description": "Or: {\"storeId\": \"…\", \"key\": \"…\"} of a record holding JSON or CSV."
          },
          "targets": {
            "title": "More targets",
            "type": "array",
            "description": "Write the same data to several places in one run: [{\"spreadsheet\": \"…\", \"tab\": \"…\", \"mode\": \"upsert\", \"keyFields\": [\"sku\"]}]."
          },
          "splitByField": {
            "title": "Split into tabs by field",
            "type": "string",
            "description": "One tab per value of this field (e.g. country). The tab name is the value, or the tab template with {value}."
          },
          "incremental": {
            "title": "Only rows not sent before",
            "type": "boolean",
            "description": "Remember what was written to this tab (by key fields, or by the whole item) and skip it next time.",
            "default": false
          },
          "limit": {
            "title": "Maximum items",
            "minimum": 1,
            "type": "integer",
            "description": "Write at most this many items."
          },
          "offset": {
            "title": "Skip items",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many items at the start.",
            "default": 0
          },
          "dedupe": {
            "title": "Remove duplicates",
            "type": "boolean",
            "description": "Write each key (or each identical item) once.",
            "default": false
          },
          "columns": {
            "title": "Columns",
            "type": "array",
            "description": "Choose and order columns: one field per line; \"field: Header\" renames. Empty: every field, in the order first seen, after the sheet's existing columns.",
            "items": {
              "type": "string"
            }
          },
          "columnsOrder": {
            "title": "Columns first",
            "type": "array",
            "description": "Optional. Fields to put first, in this order, when the actor creates the header; every other field follows. (Columns, above, instead fixes the exact list.)",
            "items": {
              "type": "string"
            }
          },
          "flatten": {
            "title": "Nested fields as columns",
            "type": "boolean",
            "description": "price.amount and price.currency become their own columns. Off: nested objects as JSON text.",
            "default": true
          },
          "flattenSeparator": {
            "title": "Nested field separator",
            "minLength": 1,
            "maxLength": 5,
            "type": "string",
            "description": "Optional. Joins nested keys in column names: \".\" by default (price.amount). Inputs that use spreadsheetId use \"/\" (hobbies/0) automatically, so existing sheets keep their columns."
          },
          "arrays": {
            "title": "Lists",
            "enum": [
              "join",
              "json"
            ],
            "type": "string",
            "description": "How a list of values is written.",
            "default": "join"
          },
          "arraySeparator": {
            "title": "List separator",
            "type": "string",
            "description": "Used when lists are joined.",
            "default": ", "
          },
          "addSyncedAt": {
            "title": "Add a syncedAt column",
            "type": "boolean",
            "description": "The time of this run, on every row written.",
            "default": false
          },
          "valueInput": {
            "title": "Values",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW keeps every value as given. USER_ENTERED lets Google parse dates and numbers; text that would start a formula is kept as text unless its column is a formula column.",
            "default": "RAW"
          },
          "formulaColumns": {
            "title": "Formula columns",
            "type": "array",
            "description": "With typed values: columns whose text is a formula, e.g. =IMAGE(…) or =HYPERLINK(…).",
            "items": {
              "type": "string"
            }
          },
          "freezeHeader": {
            "title": "Freeze the header row",
            "type": "boolean",
            "description": "Keep the header row visible while scrolling.",
            "default": true
          },
          "boldHeader": {
            "title": "Bold header",
            "type": "boolean",
            "description": "Make the header row bold.",
            "default": true
          },
          "autoResize": {
            "title": "Fit column widths",
            "type": "boolean",
            "description": "Fit column widths to their contents after writing.",
            "default": true
          },
          "createBackup": {
            "title": "Back up before replacing or syncing",
            "type": "boolean",
            "description": "Saves the tab to this actor's store first; the run summary gives the backup key to restore.",
            "default": false
          },
          "backupKey": {
            "title": "Backup to restore",
            "type": "string",
            "description": "Mode restore: the backup key from a run summary."
          },
          "headerRow": {
            "title": "Header row (read)",
            "minimum": 1,
            "type": "integer",
            "description": "Mode read: the row holding field names.",
            "default": 1
          },
          "publicSheet": {
            "title": "Public sheet (read without sharing)",
            "type": "boolean",
            "description": "Mode read: read a sheet published to the web, without sharing it with us."
          },
          "serviceAccountJson": {
            "title": "Your service account key (optional)",
            "type": "string",
            "description": "Use your own Google Cloud service account instead of ours: paste its JSON key. Share the sheet with that account's address. Your own quota, and nothing shared with us."
          },
          "oauthClientId": {
            "title": "OAuth client id (optional)",
            "type": "string",
            "description": "With client secret and refresh token: act as your own Google account."
          },
          "oauthClientSecret": {
            "title": "OAuth client secret",
            "type": "string",
            "description": "With OAuth: your client secret."
          },
          "oauthRefreshToken": {
            "title": "OAuth refresh token",
            "type": "string",
            "description": "With OAuth: a refresh token for your Google account, with the spreadsheets scope."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}