{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Sync – Reliable Import & Export",
    "description": "Import a Google Sheet into an Apify dataset or export a dataset/JSON into a Sheet tab. Public sheets need no auth; private sheets use your service-account JSON. Chunked writes with retries. $0.50 per 1,000 rows; failed writes are free.",
    "version": "0.0",
    "x-build-id": "eeaAt61buzLbo1VLm"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/chris_elder~google-sheets-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-chris_elder-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/chris_elder~google-sheets-sync/runs": {
      "post": {
        "operationId": "runs-sync-chris_elder-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/chris_elder~google-sheets-sync/run-sync": {
      "post": {
        "operationId": "run-sync-chris_elder-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": [
          "mode",
          "spreadsheetId"
        ],
        "properties": {
          "mode": {
            "title": "Mode",
            "enum": [
              "import",
              "export"
            ],
            "type": "string",
            "description": "import = Sheet → Apify dataset. export = dataset/JSON → Sheet. Prefill uses import on a public sample sheet (no auth, ~$0.015). Using this Actor as an integration after another Actor's run? Choose export – the triggering run's dataset is used automatically.",
            "default": "import"
          },
          "spreadsheetId": {
            "title": "Spreadsheet ID or URL",
            "type": "string",
            "description": "Google Sheet ID (the long string in /d/SHEET_ID/edit) or the full spreadsheet URL."
          },
          "sheetName": {
            "title": "Sheet / tab name",
            "type": "string",
            "description": "Tab name (exact). Leave empty to use the first tab (import) or create/use Sheet1 behaviour via API (export)."
          },
          "gid": {
            "title": "GID (public import only)",
            "type": "string",
            "description": "Optional numeric gid from the Sheet URL (#gid=…). Used only for public CSV import when sheetName is unreliable."
          },
          "serviceAccountJson": {
            "title": "Google service account JSON",
            "type": "string",
            "description": "Paste the full service-account key JSON. Required for export and for private sheets. Share the Sheet with the client_email as Editor. Never logged. Secret field."
          },
          "datasetId": {
            "title": "Apify dataset ID (export)",
            "type": "string",
            "description": "Export mode: the Apify dataset to write into the Sheet. Use this OR items. Using this Actor as an integration (Integrations tab of another Actor/task)? Set this to {{resource.defaultDatasetId}} – Apify fills in the triggering run's dataset and grants this Actor read access to it."
          },
          "items": {
            "title": "Items JSON array (export)",
            "type": "array",
            "description": "Export mode: paste rows directly instead of datasetId."
          },
          "writeMode": {
            "title": "Write mode (export)",
            "enum": [
              "append",
              "replace"
            ],
            "type": "string",
            "description": "append = add rows under existing data (keeps header if present). replace = clear the tab then write header + rows.",
            "default": "append"
          },
          "flattenNested": {
            "title": "Flatten nested objects (export)",
            "type": "boolean",
            "description": "Turn { meta: { city } } into a meta.city column. Arrays become JSON strings.",
            "default": true
          },
          "dryRun": {
            "title": "Dry run (export preview, free)",
            "type": "boolean",
            "description": "Export mode: resolve the dataset (or integration payload), flatten it and output the column headers + 3 sample rows WITHOUT writing to Google Sheets. No service account needed, no rows charged. Handy for testing an integration.",
            "default": false
          },
          "maxRows": {
            "title": "Max rows",
            "minimum": 1,
            "maximum": 500000,
            "type": "integer",
            "description": "Cap on rows read or written (protects cost). Charged only for successfully synced rows.",
            "default": 50000
          },
          "range": {
            "title": "A1 range (private import)",
            "type": "string",
            "description": "Optional A1 range for service-account import, e.g. 'Class Data'!A1:F100. Ignored for public CSV import."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}