🎉 Pipedream raises $20M Series A 🎉
Read the blog post and TC Techcrunch article.
← Google Sheets

Add Single Row with Google Sheets API

Pipedream makes it easy to connect APIs for Google Sheets and 700+ other apps remarkably fast.

Trigger workflow on
HTTP requests, schedules and app events
Next, do this
Add Single Row with the Google Sheets API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜
Trusted by 250,000+ developers from startups to Fortune 500 companies:
Trusted by 250,000+ developers from startups to Fortune 500 companies

Developers Pipedream

Getting Started

Create a workflow to Add Single Row with the Google Sheets API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the Add Single Row action
    1. Connect your Google Sheets account
    2. Optional- Select a Drive
    3. Select a Spreadsheet
    4. Select a Sheet Name
    5. Select a Does the first row of the sheet have headers?
  2. Select a trigger to run your workflow on HTTP requests, schedules or app events
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger


This is a pre-built, open source component from Pipedream's GitHub repo. The component is developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Add Single Row on Google Sheets
Description:Add a single row of data to Google Sheets


import googleSheets from "../../google_sheets.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
  key: "google_sheets-add-single-row",
  name: "Add Single Row",
  description: "Add a single row of data to Google Sheets",
  version: "2.0.8",
  type: "action",
  props: {
    drive: {
      propDefinition: [
    sheetId: {
      propDefinition: [
        (c) => ({
          driveId: googleSheets.methods.getDriveId(c.drive),
      description: "",
      withLabel: true,
    sheetName: {
      propDefinition: [
        (c) => ({
          sheetId: c.sheetId?.value || c.sheetId,
      description: "",
    hasHeaders: {
      type: "string",
      label: "Does the first row of the sheet have headers?",
      description: "If the first row of your document has headers we'll retrieve them to make it easy to enter the value for each column.",
      options: [
      reloadProps: true,
  async additionalProps() {
    const sheetId = this.sheetId?.value || this.sheetId;
    const props = {};
    if (this.hasHeaders === "Yes") {
      const { values } = await this.googleSheets.getSpreadsheetValues(sheetId, `${this.sheetName}!1:1`);
      if (!values[0]?.length) {
        throw new ConfigurationError("Cound not find a header row. Please either add headers and click \"Refresh fields\" or adjust the action configuration to continue.");
      for (let i = 0; i < values[0]?.length; i++) {
        props[`col_${i.toString().padStart(4, "0")}`] = {
          type: "string",
          label: values[0][i],
          optional: true,
    } else if (this.hasHeaders === "No") {
      props.myColumnData = {
        type: "string[]",
        label: "Values",
        description: "Provide a value for each cell of the row. Google Sheets accepts strings, numbers and boolean values for each cell. To set a cell to an empty value, pass an empty string.",
    return props;
  async run({ $ }) {
    const sheetId = this.sheetId?.value || this.sheetId;
    let cells;
    if (this.hasHeaders === "Yes") {
      // TODO: If we could create a variable using this.allColumns in additionalProps, we dont need
      // to call getSpreadsheetValues here again.
      const { values: rows } = await this.googleSheets.getSpreadsheetValues(sheetId, `${this.sheetName}!1:1`);
      const [
      ] = rows;
      cells = headers
        .map((_, i) => `col_${i.toString().padStart(4, "0")}`)
        .map((column) => this[column] ?? "");
    } else {
      cells = this.googleSheets.sanitizedArray(this.myColumnData);

    // validate input
    if (!cells || !cells.length) {
      throw new Error("Please enter an array of elements in `Cells / Column Values`.");
    } else if (!Array.isArray(cells)) {
      throw new Error("Cell / Column data is not an array. Please enter an array of elements in `Cells / Column Values`.");
    } else if (Array.isArray(cells[0])) {
      throw new Error("Cell / Column data is a multi-dimensional array. A one-dimensional is expected. If you're trying to send multiple rows to Google Sheets, search for the action to add multiple rows to Sheets.");

    const {
    } = this.googleSheets.arrayValuesToString(cells);

    const data = await this.googleSheets.addRowsToSheet({
      spreadsheetId: sheetId,
      range: this.sheetName,
      rows: [

    let summary = `Added 1 row to [${this.sheetId?.label || this.sheetId} (${data.updatedRange})](https://docs.google.com/spreadsheets/d/${sheetId}).`;
    if (convertedIndexes.length > 0) {
      summary += " We detected something other than a string/number/boolean in at least one of the fields and automatically converted it to a string.";
    $.export("$summary", summary);

    return data;


This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
Google SheetsgoogleSheetsappThis component uses the Google Sheets app.
DrivedrivestringSelect a value from the drop down menu.
SpreadsheetsheetIdstringSelect a value from the drop down menu.
Sheet NamesheetNamestringSelect a value from the drop down menu.
Does the first row of the sheet have headers?hasHeadersstringSelect a value from the drop down menu:YesNo


Google Sheets uses OAuth authentication. When you connect your Google Sheets account, Pipedream will open a popup window where you can sign into Google Sheets and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Google Sheets API.

Pipedream requests the following authorization scopes when you connect your account:


About Google Sheets

With Google Sheets, you can create, edit, and collaborate wherever you are

More Ways to Use Google Sheets