{
  "name": "Cleaning Inspection - Load",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "GET",
        "path": "inspection-load",
        "responseMode": "responseNode",
        "options": {
          "allowedOrigins": "*"
        }
      },
      "id": "webhook-load",
      "name": "Webhook - Load",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        260,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Load inspection by ID from workflow static data\nconst query = $input.first().json.query;\nconst id = query?.id;\n\nif (!id) {\n  return [{ json: { error: 'Missing id parameter', status: 400 } }];\n}\n\n// Get from workflow static data\nconst staticData = $getWorkflowStaticData('global');\nconst inspection = staticData.inspections?.[id];\n\nif (!inspection) {\n  return [{ json: { error: 'Inspection not found', id: id, status: 404 } }];\n}\n\nreturn [{ json: { found: true, data: inspection } }];"
      },
      "id": "code-load",
      "name": "Load Inspection",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "has-error",
              "leftValue": "={{ $json.error }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-error",
      "name": "Has Error?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ success: false, error: $json.error }) }}",
        "options": {
          "responseCode": "={{ $json.status || 400 }}",
          "responseHeaders": {
            "entries": [
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              }
            ]
          }
        }
      },
      "id": "respond-error",
      "name": "Respond Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        920,
        200
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json.data) }}",
        "options": {
          "responseCode": 200,
          "responseHeaders": {
            "entries": [
              {
                "name": "Access-Control-Allow-Origin",
                "value": "*"
              }
            ]
          }
        }
      },
      "id": "respond-success",
      "name": "Respond Found",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        920,
        400
      ]
    }
  ],
  "connections": {
    "Webhook - Load": {
      "main": [
        [
          {
            "node": "Load Inspection",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Inspection": {
      "main": [
        [
          {
            "node": "Has Error?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Error?": {
      "main": [
        [
          {
            "node": "Respond Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Found",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "Sparkery"
    },
    {
      "name": "Cleaning Inspection"
    }
  ]
}