{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://growthpilot-ai.pages.dev/integrations/webhook-payload.schema.json",
  "title": "GrowthPilot AI Lead Webhook Payload",
  "description": "Schema for the live GrowthPilot AI lead webhook envelope sent to Airtable, HubSpot, Google Sheets, Notion, Zapier, Make, or a custom CRM endpoint.",
  "type": "object",
  "required": ["source", "lead"],
  "properties": {
    "source": {
      "type": "string",
      "const": "growthpilot-ai",
      "description": "Webhook source identifier used by downstream automation filters."
    },
    "lead": {
      "type": "object",
      "required": ["id", "createdAt", "contact", "productUrl", "leadScore", "leadPriority", "nextAction", "qualificationReasons"],
      "properties": {
        "id": { "type": "string", "description": "Unique lead id generated by GrowthPilot AI." },
        "createdAt": { "type": "string", "format": "date-time" },
        "businessName": { "type": "string" },
        "contact": { "type": "string", "description": "Email, LinkedIn, WeChat, or another contact path submitted by the prospect." },
        "productUrl": { "type": "string", "format": "uri" },
        "plan": { "type": "string" },
        "notes": { "type": "string" },
        "source": { "type": "string" },
        "medium": { "type": "string" },
        "campaign": { "type": "string" },
        "utmSource": { "type": "string" },
        "utmMedium": { "type": "string" },
        "utmCampaign": { "type": "string" },
        "landingPage": { "type": "string" },
        "referrer": { "type": "string" },
        "leadScore": { "type": "integer", "minimum": 0, "maximum": 100 },
        "leadPriority": { "type": "string", "enum": ["high", "medium", "low"] },
        "nextAction": { "type": "string" },
        "qualificationReasons": {
          "type": "string",
          "description": "Semicolon-separated scoring reasons for CRM notes."
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
