{
  "name": "REST API with Google Sheets",
  "nodes": [
    {
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
          "mode": "list",
          "cachedResultName": "REST API data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "name": "={{ $json.body.name }}",
            "email": "={{ $json.body.email }}",
            "status": "={{ $json.body.status }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        224,
        0
      ],
      "id": "4b53d6ea-e083-4d89-b8af-6c4e37e4066e",
      "name": "Append row in sheet",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "items",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "70a88ee3-83ef-409f-b9fc-699b57aff26a",
      "name": "Webhook: Create"
    },
    {
      "parameters": {
        "path": "items/all",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        224
      ],
      "id": "4cb95925-d5be-4594-93d1-84cecaabc99d",
      "name": "Webhook: Read All"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"status\": \"success\",\n  \"message\": \"Record created.\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        448,
        0
      ],
      "id": "a18c5a15-92bf-4897-83c7-0c0a4aaeb58a",
      "name": "Respond to Webhook: Create"
    },
    {
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        448,
        224
      ],
      "id": "6ee8437b-6340-4cdc-b39b-1951461d4164",
      "name": "Respond to Webhook: Read All"
    },
    {
      "parameters": {
        "path": "items",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        448
      ],
      "id": "1560785d-b30e-49b5-94f4-27445538d086",
      "name": "Webhook: Read"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "documentId": {
          "__rl": true,
          "value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
          "mode": "list",
          "cachedResultName": "REST API data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        224,
        224
      ],
      "id": "46baff34-99e4-4c6a-9395-76fc5358c5a7",
      "name": "Get rows in sheet",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "documentId": {
          "__rl": true,
          "value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
          "mode": "list",
          "cachedResultName": "REST API data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "=row_number",
              "lookupValue": "={{ $json.query.id }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        224,
        448
      ],
      "id": "1cbcf7af-d1ba-4994-a795-d5c597439bad",
      "name": "Get row in sheet",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        448,
        448
      ],
      "id": "ebaf7824-73af-47c2-8e3d-a19947a91892",
      "name": "Respond to Webhook: Read"
    },
    {
      "parameters": {
        "httpMethod": "PUT",
        "path": "items",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        672
      ],
      "id": "6cbd2531-b9f4-4a3f-b821-bec3caf2d09d",
      "name": "Webhook: Update"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
          "mode": "list",
          "cachedResultName": "REST API data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {
            "row_number": "={{ $json.query.id }}",
            "name": "={{ $json.body.name }}",
            "email": "={{ $json.body.email }}",
            "status": "={{ $json.body.status }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "name",
              "displayName": "name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "email",
              "displayName": "email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        448,
        672
      ],
      "id": "b91994a3-ef36-4770-99dc-926640496693",
      "name": "Update row in sheet",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"status\": \"success\",\n  \"message\": \"Record updated.\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        672,
        672
      ],
      "id": "5180a531-5efa-4fba-a870-61f7223fcb93",
      "name": "Respond to Webhook: Update"
    },
    {
      "parameters": {
        "httpMethod": "DELETE",
        "path": "items",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        896
      ],
      "id": "ec3b5abd-17ae-4964-b792-5d320ad7a65b",
      "name": "Webhook: Delete"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "delete",
        "documentId": {
          "__rl": true,
          "value": "1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q",
          "mode": "list",
          "cachedResultName": "REST API data",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit#gid=0"
        },
        "startIndex": "={{ $json.query.id }}"
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        224,
        896
      ],
      "id": "b3950509-6173-4a30-bbaa-42ef34b15878",
      "name": "Delete rows or columns from sheet",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "{\n  \"status\": \"success\",\n  \"message\": \"Record deleted.\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        448,
        896
      ],
      "id": "0361a349-a259-4a3c-877e-2bb7bee0f9be",
      "name": "Respond to Webhook: Delete"
    },
    {
      "parameters": {
        "content": "## Simple REST API with Google Sheets\n\n### Introduction\n\nThis workflow template demonstrates how to quickly and easily create a simple REST API using n8n and a Google Sheet as a no-code database. It's a perfect starting point for building a backend for small applications, prototypes, or internal tools without writing any code.\n\n### Purpose\n\nThe purpose of this template is to provide a complete, ready-to-use n8n workflow that handles all fundamental CRUD (Create, Read, Update, Delete) operations. The workflow uses a single Webhook trigger to handle POST, GET, PUT, and DELETE requests, allowing you to manage data in your Google Sheet through standard API calls.\n\n### Setup Instructions\n\nTo get started with this template, follow these steps:\n\n1. **Prepare your Google Sheet:** Create a new Google Sheet and add the following column headers in the first row: `name`, `email`, and `status`. You can use this [example Google Sheet](https://docs.google.com/spreadsheets/d/1bQyl8pGVutkq1LRwK_-6TAAcXwNj4_TipeWHi-qmK1Q/edit?usp=sharing) as a starting point. This sheet will serve as your database.\n2. **Authenticate:** In the n8n workflow, connect your Google Account credentials to the Google Sheets nodes.\n3. **Select your data:** Choose the Google Sheet and the corresponding sheet name from the drop-down lists in each of the Google Sheets nodes.\n4. **Activate:** Save and activate the workflow.\n5. Test the API: Use a tool like `curl`, Postman, or Insomnia to test your new API endpoints. The base URL will be your n8n webhook URL followed by `/items`.\n\n#### Example `curl` Commands:\n* **POST (Create):** `curl -X POST YOUR_N8N_WEBHOOK_URL/items -H \"Content-Type: application/json\" -d '{\"name\": \"Alice\", \"email\": \"alice@example.com\", \"status\": \"active\"}'`\n* **GET (Read All):** `curl -X GET YOUR_N8N_WEBHOOK_URL/items/all`\n* **GET (Read Single):** `curl -X GET YOUR_N8N_WEBHOOK_URL/items?id=2`\n* **PUT (Update):** `curl -X PUT YOUR_N8N_WEBHOOK_URL/items?id=2 -H \"Content-Type: application/json\" -d '{\"status\": \"inactive\"}'`\n* **DELETE (Delete):** `curl -X DELETE YOUR_N8N_WEBHOOK_URL/items?id=2`\n\nFor more detailed instructions, including building the workflow in n8n, check out the full blog post: [Build a Simple REST API in 10 Minutes with n8n & Google Sheets](https://n8nplaybook.com/post/2025/08/n8n-google-sheets-rest-api/)",
        "height": 992,
        "width": 592
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        0
      ],
      "typeVersion": 1,
      "id": "ba367266-005d-42a0-aeba-2b48db0fea05",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "={\n  \"row_number\": {{ $json.query.id }}\n  {{ $if($json.body.keys().length > 0, ', ' + $json.body.toJsonString().replace('{', '').replace('}', ''), '') }}\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        224,
        672
      ],
      "id": "8264647e-c5b2-4bf1-90a7-6fc0e8e5c2b9",
      "name": "Prepare Fields for Update"
    }
  ],
  "connections": {
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Respond to Webhook: Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook: Create": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook: Read All": {
      "main": [
        [
          {
            "node": "Get rows in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook: Read": {
      "main": [
        [
          {
            "node": "Get row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get rows in sheet": {
      "main": [
        [
          {
            "node": "Respond to Webhook: Read All",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row in sheet": {
      "main": [
        [
          {
            "node": "Respond to Webhook: Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook: Update": {
      "main": [
        [
          {
            "node": "Prepare Fields for Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet": {
      "main": [
        [
          {
            "node": "Respond to Webhook: Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook: Delete": {
      "main": [
        [
          {
            "node": "Delete rows or columns from sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete rows or columns from sheet": {
      "main": [
        [
          {
            "node": "Respond to Webhook: Delete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Fields for Update": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a0da6d17-701f-4d0f-a49d-b66b5fecd7b2",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "6QvxWwgaPghd06wj",
  "tags": []
}