{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Import & Export — Append, Upsert, Read",
    "description": "Write Apify datasets or JSON to Google Sheets: append, replace or upsert rows by key, skip duplicates, add new columns. Or read a sheet into a dataset. Service account or Apps Script access that does not expire. $0.30 per 1,000 rows.",
    "version": "0.0",
    "x-build-id": "5csUuj5tTS4NVZfTj"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/saliga~google-sheets-import-export/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-saliga-google-sheets-import-export",
        "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/saliga~google-sheets-import-export/runs": {
      "post": {
        "operationId": "runs-sync-saliga-google-sheets-import-export",
        "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/saliga~google-sheets-import-export/run-sync": {
      "post": {
        "operationId": "run-sync-saliga-google-sheets-import-export",
        "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": {
          "spreadsheet": {
            "title": "Spreadsheet link or ID",
            "type": "string",
            "description": "The Google Sheets link (https://docs.google.com/spreadsheets/d/…) or just its ID. When the link points to a tab (#gid=…), that tab is used unless you name one below."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "upsert",
              "read"
            ],
            "type": "string",
            "description": "Append keeps what is in the tab and adds rows at the end (new columns are added on the right). Replace clears the tab and writes the data. Upsert updates rows whose key is already in the tab and adds the rest. Read copies the tab into this run's dataset. Empty: append when data is given, otherwise read."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "The tab (sheet) to use, e.g. Leads. Created if it does not exist (except in read mode). Empty: the tab in the link, or the first tab."
          },
          "datasetId": {
            "title": "Dataset to write",
            "type": "string",
            "description": "The Apify dataset to write, e.g. the output of a scraper run. Pick it here so the run may read it. In an integration (run after another Actor), map the default dataset ID of that run here."
          },
          "rawData": {
            "title": "Rows (JSON)",
            "type": "array",
            "description": "Rows given directly as a JSON array of objects, instead of or in addition to a dataset. Handy for AI agents and quick tests."
          },
          "limit": {
            "title": "Limit rows",
            "minimum": 1,
            "type": "integer",
            "description": "Write (or read) at most this many rows. Empty: all."
          },
          "offset": {
            "title": "Skip rows",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many rows of the data (or of the tab in read mode) first.",
            "default": 0
          },
          "keyFields": {
            "title": "Key columns (upsert)",
            "type": "array",
            "description": "Upsert only: the column(s) that identify a row, e.g. url or id. A row whose key is already in the tab replaces the values of that row; columns not in the data keep their value.",
            "items": {
              "type": "string"
            }
          },
          "dedupeFields": {
            "title": "Skip duplicates by column (append)",
            "type": "array",
            "description": "Append only: skip rows whose value in these column(s) is already in the tab or earlier in the data. Skipped rows are free.",
            "items": {
              "type": "string"
            }
          },
          "dedupeWholeRow": {
            "title": "Skip rows identical to an existing row (append)",
            "type": "boolean",
            "description": "Append only: skip a row when all its values equal a row already in the tab or earlier in the data.",
            "default": false
          },
          "columnsOrder": {
            "title": "Columns first",
            "type": "array",
            "description": "Put these columns first, in this order. Nested fields use a slash, e.g. address/city.",
            "items": {
              "type": "string"
            }
          },
          "keepOnlyListedColumns": {
            "title": "Write only the listed columns",
            "type": "boolean",
            "description": "Write only the columns in \"Columns first\" (plus columns already in the tab).",
            "default": false
          },
          "keepSheetColumnOrder": {
            "title": "Keep the tab's column order (replace)",
            "type": "boolean",
            "description": "Replace only: keep the columns of the current header in their place and add new ones on the right.",
            "default": false
          },
          "flatten": {
            "title": "Flatten nested fields",
            "type": "boolean",
            "description": "Nested objects and lists become columns like address/city and tags/0, like Apify's CSV export. Off: they are written as JSON text.",
            "default": true
          },
          "valueInput": {
            "title": "How values are entered",
            "enum": [
              "raw",
              "user_entered"
            ],
            "type": "string",
            "description": "Raw writes every value exactly as it is. As if typed lets Google parse \"=SUM(A1:A3)\", dates and \"1,234\".",
            "default": "raw"
          },
          "serviceAccountKey": {
            "title": "Service account key (JSON)",
            "type": "string",
            "description": "Option 1: the whole JSON key of a Google service account. Share the spreadsheet with the service account's e-mail (client_email) as Editor. Stored encrypted. See the README for the 3-minute setup."
          },
          "appsScriptUrl": {
            "title": "Apps Script web app URL",
            "type": "string",
            "description": "Option 2, no Google Cloud project: paste the script from the README into Extensions → Apps Script of the spreadsheet, deploy it as a web app and paste the /exec URL here."
          },
          "appsScriptToken": {
            "title": "Apps Script token",
            "type": "string",
            "description": "The TOKEN you set in the script, so nobody else can write to your sheet through it."
          },
          "publicSpreadsheet": {
            "title": "Public sheet (read only)",
            "type": "boolean",
            "description": "Option 3, read mode only: the sheet is shared as \"Anyone with the link can view\". No setup; values come back as text.",
            "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}