{
  "updatedAt": "2026-03-15T20:44:53.646Z",
  "createdAt": "2026-03-08T19:25:50.732Z",
  "id": "XZAZP8vd6PxIdmj9",
  "name": "VenueDesk \u2014 API: Get Activity",
  "description": null,
  "active": true,
  "isArchived": false,
  "nodes": [
    {
      "id": "wh4",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        200,
        300
      ],
      "parameters": {
        "path": "leads-activity",
        "httpMethod": "GET",
        "responseMode": "responseNode",
        "authentication": "none"
      },
      "credentials": {}
    },
    {
      "id": "ext4",
      "name": "Extract Tenant",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        420,
        300
      ],
      "parameters": {
        "jsCode": "// FIX: Extract tenant_id from header \u2014 never trust request body\nconst tenantId = parseInt($input.first().json.headers['x-tenant-id'] || '0', 10);\nif (!tenantId || tenantId < 1) {\n  throw new Error('Missing or invalid X-Tenant-ID header');\n}\nreturn { json: { tenant_id: tenantId } };"
      }
    },
    {
      "id": "pg4",
      "name": "Get Activity",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2,
      "position": [
        640,
        300
      ],
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT a.*,l.venue_name FROM lead_activity a LEFT JOIN leads l ON l.id=a.lead_id WHERE l.tenant_id = $1 ORDER BY a.created_at DESC LIMIT 50",
        "options": {
          "queryReplacement": "={{ [$('Extract Tenant').first().json.tenant_id] }}"
        }
      }
    },
    {
      "id": "re4",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        880,
        300
      ],
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract Tenant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Tenant": {
      "main": [
        [
          {
            "node": "Get Activity",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Activity": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": true
  },
  "staticData": null,
  "meta": null,
  "versionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
  "activeVersionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
  "versionCounter": 10,
  "triggerCount": 1,
  "shared": [
    {
      "updatedAt": "2026-03-08T19:25:50.732Z",
      "createdAt": "2026-03-08T19:25:50.732Z",
      "role": "workflow:owner",
      "workflowId": "XZAZP8vd6PxIdmj9",
      "projectId": "xsdyFVsct988qLUy",
      "project": {
        "updatedAt": "2025-12-04T20:24:17.537Z",
        "createdAt": "2025-12-04T19:47:48.685Z",
        "id": "xsdyFVsct988qLUy",
        "name": "andrew johnson <andrew.ralston.johnson@gmail.com>",
        "type": "personal",
        "icon": null,
        "description": null,
        "creatorId": "e2485274-7097-4eb5-8502-e39b2308096c"
      }
    }
  ],
  "tags": [],
  "activeVersion": {
    "updatedAt": "2026-03-10T20:51:54.003Z",
    "createdAt": "2026-03-10T20:51:54.003Z",
    "versionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
    "workflowId": "XZAZP8vd6PxIdmj9",
    "nodes": [
      {
        "id": "wh4",
        "name": "Webhook",
        "type": "n8n-nodes-base.webhook",
        "typeVersion": 2,
        "position": [
          200,
          300
        ],
        "parameters": {
          "path": "leads-activity",
          "httpMethod": "GET",
          "responseMode": "responseNode",
          "authentication": "none"
        },
        "webhookId": "leads-activity",
        "credentials": {}
      },
      {
        "id": "ext4",
        "name": "Extract Tenant",
        "type": "n8n-nodes-base.code",
        "typeVersion": 2,
        "position": [
          420,
          300
        ],
        "parameters": {
          "jsCode": "// FIX: Extract tenant_id from header \u2014 never trust request body\nconst tenantId = parseInt($input.first().json.headers['x-tenant-id'] || '0', 10);\nif (!tenantId || tenantId < 1) {\n  throw new Error('Missing or invalid X-Tenant-ID header');\n}\nreturn { json: { tenant_id: tenantId } };"
        }
      },
      {
        "id": "pg4",
        "name": "Get Activity",
        "type": "n8n-nodes-base.postgres",
        "typeVersion": 2,
        "position": [
          640,
          300
        ],
        "credentials": {
          "postgres": {
            "id": "iEsRYyB7vjr5G7i8",
            "name": "Postgres account 3"
          }
        },
        "parameters": {
          "operation": "executeQuery",
          "query": "SELECT a.*,l.venue_name FROM lead_activity a LEFT JOIN leads l ON l.id=a.lead_id WHERE l.tenant_id = $1 ORDER BY a.created_at DESC LIMIT 50",
          "options": {
            "queryReplacement": "={{ [$('Extract Tenant').first().json.tenant_id] }}"
          }
        }
      },
      {
        "id": "re4",
        "name": "Respond",
        "type": "n8n-nodes-base.respondToWebhook",
        "typeVersion": 1,
        "position": [
          880,
          300
        ],
        "parameters": {
          "respondWith": "allIncomingItems",
          "options": {}
        }
      }
    ],
    "connections": {
      "Webhook": {
        "main": [
          [
            {
              "node": "Extract Tenant",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Extract Tenant": {
        "main": [
          [
            {
              "node": "Get Activity",
              "type": "main",
              "index": 0
            }
          ]
        ]
      },
      "Get Activity": {
        "main": [
          [
            {
              "node": "Respond",
              "type": "main",
              "index": 0
            }
          ]
        ]
      }
    },
    "authors": "andrew johnson",
    "name": null,
    "description": null,
    "autosaved": false,
    "workflowPublishHistory": [
      {
        "createdAt": "2026-03-10T20:51:54.024Z",
        "id": 941,
        "workflowId": "XZAZP8vd6PxIdmj9",
        "versionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
        "event": "deactivated",
        "userId": "e2485274-7097-4eb5-8502-e39b2308096c"
      },
      {
        "createdAt": "2026-03-10T20:51:54.035Z",
        "id": 942,
        "workflowId": "XZAZP8vd6PxIdmj9",
        "versionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
        "event": "activated",
        "userId": "e2485274-7097-4eb5-8502-e39b2308096c"
      },
      {
        "createdAt": "2026-03-15T20:44:53.665Z",
        "id": 1404,
        "workflowId": "XZAZP8vd6PxIdmj9",
        "versionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
        "event": "deactivated",
        "userId": "e2485274-7097-4eb5-8502-e39b2308096c"
      },
      {
        "createdAt": "2026-03-15T20:44:53.674Z",
        "id": 1405,
        "workflowId": "XZAZP8vd6PxIdmj9",
        "versionId": "cf19401a-7cd3-4fbe-90d7-237e10e5f1ad",
        "event": "activated",
        "userId": "e2485274-7097-4eb5-8502-e39b2308096c"
      }
    ]
  }
}