{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets Export & Sync: Append, Upsert",
    "description": "Writes any Apify dataset, Actor run output or JSON rows to a Google Sheet and returns a sync summary (rows appended, updated, unchanged). Modes: append, replace, or upsert by key column. Auto headers, nested-field flattening, quota retries, service-account auth. $0.50 per 1,000 rows written.",
    "version": "1.0",
    "x-build-id": "SaoY3mlWMaTFI5HSd"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/brasspage~google-sheets-sync/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-brasspage-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/brasspage~google-sheets-sync/runs": {
      "post": {
        "operationId": "runs-sync-brasspage-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/brasspage~google-sheets-sync/run-sync": {
      "post": {
        "operationId": "run-sync-brasspage-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": {
          "spreadsheetId": {
            "title": "Spreadsheet ID or URL",
            "type": "string",
            "description": "The Google Sheet to write to. Paste the full URL or only the ID (the part between /d/ and /edit). Share this sheet with your service-account email as Editor."
          },
          "sheetName": {
            "title": "Sheet (tab) name",
            "type": "string",
            "description": "The tab to write to. If the tab does not exist, the Actor creates it. Empty = the first tab."
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "append",
              "replace",
              "upsert"
            ],
            "type": "string",
            "description": "append adds new rows. replace overwrites the tab. upsert updates the rows whose key columns match and adds the others (needs Key columns).",
            "default": "append"
          },
          "keyFields": {
            "title": "Key columns (for upsert and dedupe)",
            "type": "array",
            "description": "One or more field names that identify a row, for example \"url\" or \"sku\". Upsert needs them. In append mode they skip rows whose key is already in the sheet. Nested fields use a slash, for example \"product/id\".",
            "items": {
              "type": "string"
            }
          },
          "serviceAccountJson": {
            "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 the \"client_email\" from this file as Editor. The value is stored encrypted."
          },
          "oauthClientId": {
            "title": "OAuth client ID (optional)",
            "type": "string",
            "description": "Only if you do not use a service account. Client ID of your own Google OAuth client."
          },
          "oauthClientSecret": {
            "title": "OAuth client secret (optional)",
            "type": "string",
            "description": "Client secret of the same OAuth client."
          },
          "oauthRefreshToken": {
            "title": "OAuth refresh token (optional)",
            "type": "string",
            "description": "Refresh token with the scope https://www.googleapis.com/auth/spreadsheets. Tokens of OAuth apps in \"Testing\" status expire after 7 days."
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "The Apify dataset to export, for example the default dataset of a scraper run (Storage > Datasets, or the run's Storage tab). In an integration, set it to {{resource.defaultDatasetId}}."
          },
          "rows": {
            "title": "Raw JSON rows",
            "type": "array",
            "description": "An array of objects to write, for example [{\"name\": \"A\", \"price\": 10}]. Use this when the data does not come from a dataset."
          },
          "columns": {
            "title": "Columns to export",
            "type": "array",
            "description": "Pick and order the fields to write. Empty = all fields. Nested fields use a slash, for example \"price/value\" or \"images/0\".",
            "items": {
              "type": "string"
            }
          },
          "flattenNested": {
            "title": "Flatten nested fields",
            "type": "boolean",
            "description": "On: {\"price\": {\"value\": 5}} becomes a column \"price/value\". Off: nested objects are written as JSON text in one cell.",
            "default": true
          },
          "valueInputOption": {
            "title": "How Google reads the values",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW keeps text as text, so \"00123\" keeps its zeros and a value that starts with \"=\" is not run as a formula. USER_ENTERED makes Sheets parse values as if you typed them.",
            "default": "RAW"
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}