{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Export: Apify Dataset to Sheets",
    "description": "Write an Apify dataset, JSON URL or JSON array to a Google Sheets tab. Append, replace, upsert by key or append only new rows. New fields become new columns instead of breaking the run. Uses your own service account key; no Google sign-in prompt.",
    "version": "1.0",
    "x-build-id": "xdEw6YX1m3V2cSVUV"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/plainsource~google-sheets-export/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-plainsource-google-sheets-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/plainsource~google-sheets-export/runs": {
      "post": {
        "operationId": "runs-sync-plainsource-google-sheets-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/plainsource~google-sheets-export/run-sync": {
      "post": {
        "operationId": "run-sync-plainsource-google-sheets-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",
        "properties": {
          "serviceAccountKey": {
            "title": "Google service account key (JSON)",
            "type": "string",
            "description": "Paste the whole JSON key file of a Google Cloud service account, then share the spreadsheet with that account's email (client_email) as Editor. The README shows how to create one. The key is stored encrypted by Apify and is never logged."
          },
          "spreadsheetId": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "The URL from the browser address bar, or the part between /d/ and /edit."
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "The tab to write to. Created if it doesn't exist. Leave empty to use the first tab."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "upsert",
              "dedupe-append"
            ],
            "type": "string",
            "description": "append: add rows below the existing data. replace: overwrite the tab with this data. upsert: update rows whose key already exists and append the rest. dedupe-append: append only rows whose key is not in the tab yet.",
            "default": "append"
          },
          "keyColumns": {
            "title": "Key columns",
            "type": "array",
            "description": "Required for upsert and dedupe-append. Column header(s) or field path(s) that identify a row, e.g. url or id. Several columns form a combined key.",
            "items": {
              "type": "string"
            }
          },
          "dryRun": {
            "title": "Dry run (preview only)",
            "type": "boolean",
            "description": "Output the exact rows and columns that would be written, without writing anything and without charging. With a key, the preview is checked against the real tab (existing header, keys and row numbers). Turn it off to write.",
            "default": false
          },
          "datasetId": {
            "title": "Dataset",
            "type": "string",
            "description": "An Apify dataset. Pick one, or paste its ID. For automatic runs after another Actor, set it to {{resource.defaultDatasetId}} (see the README)."
          },
          "dataUrl": {
            "title": "JSON URL",
            "type": "string",
            "description": "A public URL returning a JSON array, JSON Lines, or an object with an items, data or results array."
          },
          "rawData": {
            "title": "JSON array",
            "type": "array",
            "description": "Rows as objects, or as arrays whose first array is the header."
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Write at most this many input rows. Empty or 0 means all."
          },
          "offset": {
            "title": "Skip first rows",
            "minimum": 0,
            "type": "integer",
            "description": "Skip this many input rows before reading.",
            "default": 0
          },
          "columns": {
            "title": "Columns to write",
            "type": "array",
            "description": "Only these fields, in this order. Use dot paths for nested fields, e.g. price.value. Leave empty to write every field in the order first seen.",
            "items": {
              "type": "string"
            }
          },
          "excludeColumns": {
            "title": "Columns to leave out",
            "type": "array",
            "description": "Fields to skip when \"Columns to write\" is empty.",
            "items": {
              "type": "string"
            }
          },
          "columnRenames": {
            "title": "Header names",
            "type": "object",
            "description": "Rename headers: {\"price.value\": \"Price\"}. Keys are field paths, values are the header text in the sheet."
          },
          "addNewColumns": {
            "title": "Add new fields as columns",
            "type": "boolean",
            "description": "When the data has fields that the tab's header row doesn't, add them as columns on the right. Off: leave those fields out.",
            "default": true
          },
          "flatten": {
            "title": "Flatten nested objects",
            "type": "boolean",
            "description": "Turn {\"price\": {\"value\": 1}} into a price.value column. Off: nested objects are written as JSON text.",
            "default": true
          },
          "arrayHandling": {
            "title": "Arrays",
            "enum": [
              "join",
              "json",
              "expand"
            ],
            "type": "string",
            "description": "join: one cell with the items joined by the separator. json: one cell with JSON text. expand: one column per item (tags.0, tags.1, ...).",
            "default": "join"
          },
          "arraySeparator": {
            "title": "Array separator",
            "type": "string",
            "description": "Used when Arrays is join.",
            "default": ", "
          },
          "valueInputOption": {
            "title": "How Sheets reads values",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW: text stays text, so values starting with = are not run as formulas. USER_ENTERED: Sheets parses values as if typed (dates, formulas, 00123 becomes 123).",
            "default": "RAW"
          },
          "previewLimit": {
            "title": "Dry run preview rows",
            "minimum": 0,
            "type": "integer",
            "description": "How many rows a dry run outputs. Counts in the summary always cover every row.",
            "default": 200
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}