{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.fideliyapass.com/schemas/webhooks/2026-11/referral.completed.json",
  "type": "object",
  "properties": {
    "pass_id": {
      "type": "string",
      "minLength": 1
    },
    "pass_name": {
      "type": "string"
    },
    "referrer_customer_pass_id": {
      "type": "string",
      "minLength": 1
    },
    "referrer_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Null only once the business deleted the referrer (see referrer_deleted)."
    },
    "referred_customer_pass_id": {
      "type": "string",
      "minLength": 1
    },
    "referred_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Null only once the business deleted the friend (see referred_deleted)."
    },
    "referrer_bonus": {
      "type": "number"
    },
    "new_customer_bonus": {
      "type": "number"
    },
    "loyalty_type": {
      "type": "string",
      "enum": [
        "visits",
        "points"
      ]
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "referrer_deleted": {
      "description": "Present, and true, once the business deleted the referrer: their name and contact details are removed from this event (null), and a resend carries none. Show \"Deleted customer\".",
      "type": "boolean",
      "const": true
    },
    "referrer_deleted_at": {
      "description": "When the business deleted the referrer. Present with the flag above.",
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    },
    "referred_deleted": {
      "description": "Present, and true, once the business deleted the friend: their name and contact details are removed from this event (null), and a resend carries none. Show \"Deleted customer\".",
      "type": "boolean",
      "const": true
    },
    "referred_deleted_at": {
      "description": "When the business deleted the friend. Present with the flag above.",
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
    }
  },
  "required": [
    "pass_id",
    "pass_name",
    "referrer_customer_pass_id",
    "referrer_name",
    "referred_customer_pass_id",
    "referred_name",
    "referrer_bonus",
    "new_customer_bonus",
    "loyalty_type",
    "timestamp"
  ],
  "description": "A referred friend made their first visit, so both earned their bonus.",
  "examples": [
    {
      "pass_id": "7f1d5c1e-2b7a-4c1e-9d0e-0c6f3c2a9b10",
      "pass_name": "Café Lumière",
      "referrer_customer_pass_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
      "referrer_name": "Ana",
      "referred_customer_pass_id": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
      "referred_name": "Sam",
      "referrer_bonus": 1,
      "new_customer_bonus": 1,
      "loyalty_type": "visits",
      "timestamp": "2026-11-03T10:15:00.000Z"
    }
  ]
}
