{
  "openapi": "3.0.1",
  "info": {
    "title": "Google Sheets for AI Agents — Read, Append, Replace",
    "description": "Send any Apify scraper’s results straight into Google Sheets, or let AI agents read and write your sheets. Read, append, replace or clear. Just share your sheet with one email address: no OAuth, no Google Cloud setup. Reliable for scheduled runs.",
    "version": "0.2",
    "x-build-id": "4QRZOqiBOzywyaScP"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/brito17~google-sheets-for-ai-agents/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-brito17-google-sheets-for-ai-agents",
        "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/brito17~google-sheets-for-ai-agents/runs": {
      "post": {
        "operationId": "runs-sync-brito17-google-sheets-for-ai-agents",
        "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/brito17~google-sheets-for-ai-agents/run-sync": {
      "post": {
        "operationId": "run-sync-brito17-google-sheets-for-ai-agents",
        "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",
          "action"
        ],
        "properties": {
          "spreadsheet": {
            "title": "Spreadsheet URL or ID",
            "type": "string",
            "description": "Paste the full Google Sheets link (https://docs.google.com/spreadsheets/d/.../edit) or just the ID. IMPORTANT: share the sheet (Share button → add as Editor) with sheets-bot@sheets-bot-512104.iam.gserviceaccount.com."
          },
          "action": {
            "title": "Action",
            "enum": [
              "read",
              "append",
              "replace",
              "clear",
              "listTabs"
            ],
            "type": "string",
            "description": "read = get rows as JSON. append = add rows to the bottom. replace = clear the tab (or range) and write new rows. clear = empty the tab (or range). listTabs = list the tabs in the spreadsheet.",
            "default": "read"
          },
          "sheetName": {
            "title": "Tab name",
            "type": "string",
            "description": "Which tab to use. Leave empty to use the tab from the URL (gid=...) or the first tab. For append/replace, a missing tab is created automatically."
          },
          "rows": {
            "title": "Rows to write",
            "type": "array",
            "description": "For append/replace. Either objects (keys become column headers, matched case-insensitively to existing headers): [{\"name\":\"Ann\",\"email\":\"ann@x.com\"}] — or plain arrays: [[\"Ann\",\"ann@x.com\"]]. Not needed if you use Dataset ID."
          },
          "datasetId": {
            "title": "Dataset ID (results from another Actor)",
            "type": "string",
            "description": "Copy results from an Apify dataset into the sheet, e.g. a scraper run. In an Actor integration (run this after another Actor finishes), use {{resource.defaultDatasetId}}. Works with append and replace. If the dataset is empty, the sheet is left untouched."
          },
          "datasetFields": {
            "title": "Dataset fields to include (optional)",
            "type": "array",
            "description": "Only these fields, in this order, become columns. Nested fields use dots, e.g. location.lat. Leave empty for all fields.",
            "items": {
              "type": "string"
            }
          },
          "datasetLimit": {
            "title": "Max dataset items (optional)",
            "minimum": 1,
            "type": "integer",
            "description": "Stop after this many dataset items. Leave empty for all."
          },
          "flattenNested": {
            "title": "Flatten nested fields",
            "type": "boolean",
            "description": "Split nested objects into their own columns (address.city, address.zip) instead of putting JSON text in one cell.",
            "default": true
          },
          "range": {
            "title": "Range (optional)",
            "type": "string",
            "description": "A1 range to limit read/clear/replace, e.g. A1:D500, A:C or 2:100. Leave empty for the whole tab."
          },
          "firstRowIsHeader": {
            "title": "First row is the header (read)",
            "type": "boolean",
            "description": "When reading, use row 1 as field names and return each row as an object. Turn off to get raw arrays.",
            "default": true
          },
          "maxRows": {
            "title": "Max rows to read",
            "minimum": 1,
            "type": "integer",
            "description": "Stop after this many rows when reading. Leave empty for all."
          },
          "addMissingColumns": {
            "title": "Add missing columns (append)",
            "type": "boolean",
            "description": "When appending objects with fields the sheet doesn't have yet, add them as new header columns. If off, those fields are skipped (and listed in the log).",
            "default": true
          },
          "writeHeaders": {
            "title": "Write header row (replace)",
            "type": "boolean",
            "description": "When replacing with objects, write their keys as the first row.",
            "default": true
          },
          "valueInputOption": {
            "title": "How values are stored",
            "enum": [
              "RAW",
              "USER_ENTERED"
            ],
            "type": "string",
            "description": "RAW (default, safest) stores text exactly as sent, so scraped text like \"=IMPORTXML(...)\" can never run as a formula. USER_ENTERED makes Sheets parse values like typing them in: formulas, dates and currency.",
            "default": "RAW"
          },
          "rawValues": {
            "title": "Unformatted values (read)",
            "type": "boolean",
            "description": "Return numbers as numbers (1234.5) instead of as displayed (\"$1,234.50\").",
            "default": false
          },
          "readFormulas": {
            "title": "Read formulas instead of results (read)",
            "type": "boolean",
            "description": "When reading, return the formulas themselves (e.g. =SUM(A1:A5)) instead of their results.",
            "default": false
          },
          "createSheetIfMissing": {
            "title": "Create tab if missing (append/replace)",
            "type": "boolean",
            "description": "If the tab name doesn't exist, create it automatically when appending or replacing.",
            "default": true
          },
          "serviceAccountKey": {
            "title": "Your own service account key (optional, advanced)",
            "type": "string",
            "description": "Only if you don't want to share your sheet with our bot: paste your own Google Cloud service account JSON key. Stored encrypted."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}