{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Import/Export – Service Account, No OAuth Expiry",
    "description": "Append, upsert, replace, read or back up Google Sheets with a service-account key: no OAuth tokens that expire, no browser login. Idempotent upsert by key, nested JSON flattening, 50k+ rows in chunks, automatic 429 backoff, backup before overwrite. $0.002 per 1,000 rows.",
    "version": "1.0",
    "x-build-id": "VjsfToOM27AWx9wXb"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/characteristic_division~sheets-sync-service-account/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-characteristic_division-sheets-sync-service-account",
        "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/characteristic_division~sheets-sync-service-account/runs": {
      "post": {
        "operationId": "runs-sync-characteristic_division-sheets-sync-service-account",
        "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/characteristic_division~sheets-sync-service-account/run-sync": {
      "post": {
        "operationId": "run-sync-characteristic_division-sheets-sync-service-account",
        "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",
          "serviceAccountJson"
        ],
        "properties": {
          "spreadsheetId": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Full Google Sheets URL (https://docs.google.com/spreadsheets/d/…/edit) or just the spreadsheet ID. Share the spreadsheet with your service account's client_email as Editor (Viewer is enough for read/backup)."
          },
          "sheetName": {
            "title": "Sheet (tab) name",
            "type": "string",
            "description": "Name of the tab to read or write.",
            "default": "Sheet1"
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "upsert",
              "replace",
              "read",
              "backup"
            ],
            "type": "string",
            "description": "append: add rows after the last one. upsert: match rows by 'Upsert key' column, update only changed rows, insert new ones (re-running is idempotent). replace: clear the tab and write the data (a backup is saved first). read: one dataset item per sheet row. backup: save the tab's values as JSON in the key-value store.",
            "default": "append"
          },
          "serviceAccountJson": {
            "title": "Service account JSON key",
            "type": "string",
            "description": "Paste the full JSON key file of a Google Cloud service account (type \"service_account\") with the Google Sheets API enabled in its project. Stored encrypted; never logged or written to output."
          },
          "rows": {
            "title": "Rows (JSON array)",
            "type": "array",
            "description": "Rows to write, as an array of objects. Alternatively use 'Dataset ID' or 'JSON URL'."
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "Write all items of an Apify dataset (e.g. the output of another Actor run). Used when 'Rows' is empty."
          },
          "jsonUrl": {
            "title": "JSON URL",
            "type": "string",
            "description": "URL returning a JSON array of objects (or {items|data|rows: [...]}). Used when 'Rows' and 'Dataset ID' are empty."
          },
          "upsertKey": {
            "title": "Upsert key column",
            "type": "string",
            "description": "Column (header name) that uniquely identifies a row, e.g. id, sku or url. Required for upsert mode. Nested keys use '/' e.g. product/id."
          },
          "columnsOrder": {
            "title": "Column order",
            "type": "array",
            "description": "Optional: put these columns first, in this order, when creating new columns. Existing columns in the sheet never move.",
            "items": {
              "type": "string"
            }
          },
          "flattenNested": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "On: {seller:{name}} becomes column 'seller/name', arrays become 'tags/0', 'tags/1'. Off: nested values are written as JSON text.",
            "default": true
          },
          "deduplicate": {
            "title": "Skip duplicate rows (append)",
            "type": "boolean",
            "description": "Append mode only: skip rows identical to a row already in the sheet or earlier in the input.",
            "default": false
          },
          "createSheetIfMissing": {
            "title": "Create tab if missing",
            "type": "boolean",
            "description": "Create the tab when it does not exist yet.",
            "default": true
          },
          "createBackup": {
            "title": "Backup before overwrite",
            "type": "boolean",
            "description": "Save the tab's previous values to the key-value store before replace, or before upsert changes existing rows.",
            "default": true
          },
          "backupStoreName": {
            "title": "Named backup store (optional)",
            "type": "string",
            "description": "Name of a named key-value store to keep backups beyond the default storage retention. Leave empty to use the run's default store."
          },
          "valueInputOption": {
            "title": "Value input option",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW is safe against formula injection from scraped data. USER_ENTERED lets Sheets parse numbers, dates and formulas.",
            "default": "RAW"
          },
          "limit": {
            "title": "Max rows to read",
            "minimum": 1,
            "type": "integer",
            "description": "Read mode only: stop after this many rows."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}