{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "f0d1265c-9eee-4918-b9f6-2eb8e3c80b10",
      "name": "Portfolio Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1008,
        2400
      ],
      "parameters": {
        "path": "abc47c61-9eed-4023-b0aa-00b0815eee24",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "388ef965-a86f-4cde-b104-922f6abc84e2",
      "name": "Normalize Input Data",
      "type": "n8n-nodes-base.set",
      "onError": "continueRegularOutput",
      "position": [
        -800,
        2400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a7b430e3-292a-46d9-90ca-6e3be660d9e5",
              "name": "asset",
              "type": "string",
              "value": "={{ $json.body.asset.toUpperCase() }}"
            },
            {
              "id": "554c202a-9c0e-4613-bacc-974a84f66734",
              "name": "amount",
              "type": "number",
              "value": "={{ Number($json.body.amount) || 0 }}"
            },
            {
              "id": "8090b2d5-bf8d-49b0-be84-48d1ea9c3d9d",
              "name": "price",
              "type": "number",
              "value": "={{ Number($json.body.price) || 0 }}"
            },
            {
              "id": "40e51350-1b1e-459c-86f1-0d3994e92f86",
              "name": "value",
              "type": "number",
              "value": "={{ (Number($json.body.amount)||0) * (Number($json.body.price)||0) }}"
            },
            {
              "id": "30d6f94c-2b1b-4ca9-9fd4-a176db81770c",
              "name": "action",
              "type": "string",
              "value": "={{ $json.body.action }}"
            }
          ]
        }
      },
      "typeVersion": 3.4,
      "alwaysOutputData": true
    },
    {
      "id": "bb58e644-195d-4bdc-9c57-c435406b10ac",
      "name": "Validate Amount & Price",
      "type": "n8n-nodes-base.if",
      "position": [
        -624,
        2400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5fa178da-322c-4866-8120-ab4410a5db40",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.amount }}",
              "rightValue": 0
            },
            {
              "id": "de0caf9b-dca3-4862-a094-e0726e6a27aa",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.price }}",
              "rightValue": 0
            },
            {
              "id": "40e13079-c970-4050-adc4-21d0b3351ca3",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.value }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "c5962a88-dae0-42df-83b6-e2504ec2b527",
      "name": "Route by Action (Add/Update/Delete)",
      "type": "n8n-nodes-base.switch",
      "position": [
        -368,
        2336
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "fad9b9fb-a49f-4c4b-80c5-7f819d75fea0",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.action }}",
                    "rightValue": "add"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3b994185-6517-4a77-9cc1-615c6f150f14",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.action }}",
                    "rightValue": "update"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "73d6eaac-b3cb-4eaa-8cec-8b945b3c30a7",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.action }}",
                    "rightValue": "delete"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a64a60a4-d095-4c6f-80cb-f35144f252f4",
                    "operator": {
                      "type": "string",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.action }}",
                    "rightValue": ""
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cde6c1be-c7dd-4610-8840-5629f3794db6",
                    "operator": {
                      "type": "string",
                      "operation": "notContains"
                    },
                    "leftValue": "={{ $json.action }}",
                    "rightValue": "={{ [\"add\", \"update\", \"delete\"] }}"
                  }
                ]
              }
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "1175ada9-2bfd-4510-ae86-cc27e848753f",
      "name": "Add New Asset",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        784,
        1888
      ],
      "parameters": {
        "columns": {
          "value": {
            "Asset": "={{ $('Normalize Input Data').item.json.asset }}",
            "Price": "={{ $('Normalize Input Data').item.json.price }}",
            "Value": "={{ $('Normalize Input Data').item.json.value }}",
            "Amount": "={{ $('Normalize Input Data').item.json.amount }}"
          },
          "schema": [
            {
              "id": "Asset",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Asset",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Value",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Value",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1403427434,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit#gid=1403427434",
          "cachedResultName": "General Portfolio"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit?usp=drivesdk",
          "cachedResultName": "N8N - PRACTICE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ad6b3c21-ea30-4cf6-a074-ba7c019bcff0",
      "name": "Error: Asset Already Exists",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        800,
        2128
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"error\": \"Asset:{{ $('Normalize Input Data').item.json.asset }} is already in your portfolio\"\n} "
      },
      "typeVersion": 1.5
    },
    {
      "id": "844e32f8-56da-4c52-8aca-b126b03597d0",
      "name": "Update Existing Asset",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        272,
        2336
      ],
      "parameters": {
        "columns": {
          "value": {
            "Asset": "={{ $('Normalize Input Data').item.json.asset }}",
            "Price": "={{ $('Normalize Input Data').item.json.price }}",
            "Value": "={{ $('Normalize Input Data').item.json.value }}",
            "Amount": "={{ $('Normalize Input Data').item.json.amount }}"
          },
          "schema": [
            {
              "id": "Asset",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Asset",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Value",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Value",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Asset"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1403427434,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit#gid=1403427434",
          "cachedResultName": "General Portfolio"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit?usp=drivesdk",
          "cachedResultName": "N8N - PRACTICE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "65127dc2-2992-4240-9a5c-e1c665df2452",
      "name": "Asset Found?",
      "type": "n8n-nodes-base.if",
      "position": [
        528,
        2336
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "48a58b07-3e75-4bc6-a374-d56bbcd5a2f9",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ Object.keys($json).length }}",
              "rightValue": 0
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "7811ec07-442a-4e31-b740-a0c3cb309b6a",
      "name": "Error: Asset Not Found",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        800,
        2432
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"error\": \"Asset:{{ $('Normalize Input Data').item.json.asset }} is not found in your portfolio\"\n} "
      },
      "typeVersion": 1.5
    },
    {
      "id": "be738a14-241d-4682-9720-0dcaf91684e3",
      "name": "Delete Asset Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        800,
        2704
      ],
      "parameters": {
        "operation": "delete",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1403427434,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit#gid=1403427434",
          "cachedResultName": "General Portfolio"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit?usp=drivesdk",
          "cachedResultName": "N8N - PRACTICE"
        },
        "startIndex": "={{ $json.row_number }}"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "8ee9dbd8-1988-46aa-9a66-19410e88213e",
      "name": "Error: Asset Not Found1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        800,
        2928
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"error\": \"Asset: {{ $('Normalize Input Data').item.json.asset }} is not found in your portfolio\"\n} "
      },
      "typeVersion": 1.5
    },
    {
      "id": "6a645ad6-6784-4ae9-b258-ddb2992da5b8",
      "name": "Error: Invalid Amount/Price",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -368,
        2624
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "{\n  \"error\": \"value of amount or price is not correct it should be in positive number\"\n}"
      },
      "typeVersion": 1.5
    },
    {
      "id": "5437ae05-2041-4665-aeed-2aa9241668b1",
      "name": "Error: Missing Action",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        288,
        3072
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "{\n    \"error\": \"action field is required, add key in json called action and in value add, update or delete.\"\n}"
      },
      "typeVersion": 1.5
    },
    {
      "id": "cc065b22-2c7c-4caa-808f-44478f617b19",
      "name": "Error: Invalid Action Value",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        288,
        3328
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "{\n  \"error\": \"action should contains only one of these three values ['add', 'update', 'delete'].\"\n}"
      },
      "typeVersion": 1.5
    },
    {
      "id": "998ad1fb-de87-444c-b1f7-fbc1edfb108e",
      "name": "Combine All Operation Outputs",
      "type": "n8n-nodes-base.merge",
      "position": [
        1280,
        2304
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "4b0d6703-0641-4a1d-86fd-87e515a9c40d",
      "name": "Fetch Full Portfolio",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1504,
        2320
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1403427434,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit#gid=1403427434",
          "cachedResultName": "General Portfolio"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit?usp=drivesdk",
          "cachedResultName": "N8N - PRACTICE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ca0214fc-59d1-468f-92e4-675960c51682",
      "name": "Calculate Portfolio Value",
      "type": "n8n-nodes-base.code",
      "position": [
        1712,
        2320
      ],
      "parameters": {
        "jsCode": "let totalPortfolioValue = 0;\nconst output = [];\nfor (const item of $input.all()) {\n    totalPortfolioValue += item.json.Value || 0;\n  output.push({\n    \"Asset\": item.json.Asset,\n    \"Amount\": item.json.Amount,\n    \"Price\": item.json.Price,\n    \"Value\": item.json.Value\n  })\n}\n\nreturn {\n    output,\n    totalPortfolioValue\n  }"
      },
      "typeVersion": 2
    },
    {
      "id": "291c364d-71e9-4d83-ba66-528370d12597",
      "name": "Final Response to User",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1904,
        2320
      ],
      "parameters": {
        "options": {},
        "respondWith": "json",
        "responseBody": "={\n  \"message\": \"Asset: {{ $('Normalize Input Data').item.json.asset }} is {{ $('Route by Action (Add/Update/Delete)').item.json.action }}, now your total portfolio value is: ${{ $json.totalPortfolioValue }}\",\n  \"Assets\": {{ JSON.stringify($json.output) }}\n}"
      },
      "typeVersion": 1.5
    },
    {
      "id": "9042f00c-a093-4506-84c8-397399e4db06",
      "name": "Check Asset Exists (Add)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        256,
        1984
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.asset }}",
              "lookupColumn": "Asset"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1403427434,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit#gid=1403427434",
          "cachedResultName": "General Portfolio"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit?usp=drivesdk",
          "cachedResultName": "N8N - PRACTICE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "a4b10f64-d3f0-4894-a29d-b487a1044093",
      "name": "Asset Exists? (Add)",
      "type": "n8n-nodes-base.if",
      "position": [
        528,
        1984
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8e25fe8d-0617-49ad-bb96-b419bb72f5f3",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{Object.keys($json).length}}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a25af66d-932f-4dd4-adcf-ae5ced402adc",
      "name": "Check Asset Exists (Delete)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        288,
        2720
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.asset }}",
              "lookupColumn": "Asset"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1403427434,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit#gid=1403427434",
          "cachedResultName": "General Portfolio"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fwvOWtXwLzgx1FF_v1FaxTMDEiIN0qPF_zE1uFJj1Q8/edit?usp=drivesdk",
          "cachedResultName": "N8N - PRACTICE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "d51bdb20-2ad4-4342-ae69-b49ae104d79b",
      "name": "Asset Found? (Delete)",
      "type": "n8n-nodes-base.if",
      "position": [
        528,
        2720
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "48a58b07-3e75-4bc6-a374-d56bbcd5a2f9",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ Object.keys($json).length }}",
              "rightValue": 0
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "73e12fdc-c7d3-4327-90a0-ecd4ceb6bad6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        1872
      ],
      "parameters": {
        "width": 496,
        "height": 464,
        "content": "### Title: Portfolio Management API (n8n + Google Sheets)\n\n### Description:\nThis workflow acts as a portfolio management API using a webhook. It accepts asset data (asset, amount, price, action) and performs add, update or delete operations in Google Sheets.\n\n### How it works:\nWebhook receives request\nData is normalized and validated\nAction is routed (add/update/delete)\nGoogle Sheets is updated accordingly\nFull portfolio is fetched and total value calculated\nResponse is returned with updated portfolio\n\n### Setup Steps:\nConnect Google Sheets OAuth credentials\nEnsure sheet has columns: Asset, Amount, Price, Value\nDeploy webhook and use POST requests\nProvide JSON body with: asset, amount, price, action"
      },
      "typeVersion": 1
    },
    {
      "id": "e4291340-0897-46f1-8bbe-64abf86a0ab0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        2240
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 544,
        "content": "### INPUT & VALIDATION\nHandles incoming request and prepares data for processing.\nIncludes webhook trigger, input normalization and validation of amount/price.\nEnsures all numeric values are positive before proceeding.\nIf invalid values are detected, the workflow immediately returns an error response."
      },
      "typeVersion": 1
    },
    {
      "id": "4d2ab959-af2a-4063-9adc-ead5789b01e1",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        1712
      ],
      "parameters": {
        "color": 7,
        "width": 832,
        "height": 848,
        "content": "### ADD & UPDATE OPERATIONS\n\nManages adding new assets and updating existing ones.\nChecks if asset already exists before adding to prevent duplicates.\nFor updates, ensures the asset exists before modifying it.\nReturns appropriate error responses if asset is missing or already present."
      },
      "typeVersion": 1
    },
    {
      "id": "41de1a31-ccad-41b6-a6db-d6186c83412a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        2656
      ],
      "parameters": {
        "color": 7,
        "width": 832,
        "height": 1008,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### DELETE & ACTION VALIDATION\n\nHandles asset deletion and validates action field.\nEnsures the asset exists before deleting from the sheet.\nAlso handles cases where action is missing or contains invalid values.\nPrevents unintended operations by enforcing strict action rules."
      },
      "typeVersion": 1
    },
    {
      "id": "6369a487-2e4a-454d-bd00-c8dc44ae9191",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        2112
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 416,
        "content": "### PORTFOLIO CALCULATION & RESPONSE\n\nCombines outputs from all operations and fetches full portfolio data.\nCalculates total portfolio value using JavaScript logic.\nFormats final structured response including assets and total value.\nReturns the final result back to the user via webhook response."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Asset Found?": {
      "main": [
        [
          {
            "node": "Combine All Operation Outputs",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Error: Asset Not Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add New Asset": {
      "main": [
        [
          {
            "node": "Combine All Operation Outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete Asset Row": {
      "main": [
        [
          {
            "node": "Combine All Operation Outputs",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Asset Exists? (Add)": {
      "main": [
        [
          {
            "node": "Add New Asset",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error: Asset Already Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Full Portfolio": {
      "main": [
        [
          {
            "node": "Calculate Portfolio Value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Input Data": {
      "main": [
        [
          {
            "node": "Validate Amount & Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Asset Found? (Delete)": {
      "main": [
        [
          {
            "node": "Delete Asset Row",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error: Asset Not Found1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Existing Asset": {
      "main": [
        [
          {
            "node": "Asset Found?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Amount & Price": {
      "main": [
        [
          {
            "node": "Route by Action (Add/Update/Delete)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error: Invalid Amount/Price",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Asset Exists (Add)": {
      "main": [
        [
          {
            "node": "Asset Exists? (Add)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Portfolio Value": {
      "main": [
        [
          {
            "node": "Final Response to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Portfolio Webhook Trigger": {
      "main": [
        [
          {
            "node": "Normalize Input Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Asset Exists (Delete)": {
      "main": [
        [
          {
            "node": "Asset Found? (Delete)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine All Operation Outputs": {
      "main": [
        [
          {
            "node": "Fetch Full Portfolio",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Action (Add/Update/Delete)": {
      "main": [
        [
          {
            "node": "Check Asset Exists (Add)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update Existing Asset",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Check Asset Exists (Delete)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error: Missing Action",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error: Invalid Action Value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}