{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.fideliyapass.com/schemas/webhooks/2026-11/scan.voided.json",
  "type": "object",
  "properties": {
    "receipt_id": {
      "type": "string",
      "minLength": 1,
      "description": "The scan that was undone (its receipt)."
    },
    "kind": {
      "type": "string",
      "enum": [
        "visit",
        "redeem",
        "claim_reward",
        "gift_card_spend"
      ],
      "description": "What was undone: a stamp, a reward given, a points reward claimed, or a gift card spend."
    },
    "pass_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "customer_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "customer_pass_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The customer's card, for a loyalty scan."
    },
    "gift_card_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The gift card, for a spend."
    },
    "new_value": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "The card's visits or points after the undo."
    },
    "rewards_available": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ]
    },
    "balance": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "The gift card's balance after the undo."
    },
    "scanned_at": {
      "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)))$",
      "description": "When the scan that was undone happened."
    },
    "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)))$"
    },
    "customer_deleted": {
      "description": "Present, and true, once the business deleted this customer: their name and contact details are removed from this event (null), and a resend carries none. Show \"Deleted customer\".",
      "type": "boolean",
      "const": true
    },
    "customer_deleted_at": {
      "description": "When the business deleted this customer. 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": [
    "receipt_id",
    "kind",
    "pass_id",
    "customer_id",
    "customer_pass_id",
    "gift_card_id",
    "new_value",
    "rewards_available",
    "balance",
    "scanned_at",
    "timestamp"
  ],
  "description": "A scan was undone at the counter within seconds of it (a mistake): the stamp, reward, claim or gift card spend is taken back, and the card is as it was before.",
  "examples": [
    {
      "receipt_id": "e5f6a7b8-c9d0-4e1f-8a2b-3c4d5e6f7a8b",
      "kind": "visit",
      "pass_id": "7f1d5c1e-2b7a-4c1e-9d0e-0c6f3c2a9b10",
      "customer_id": "c1f0e2d3-4b5a-4c6d-8e7f-9a0b1c2d3e4f",
      "customer_pass_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
      "gift_card_id": null,
      "new_value": 3,
      "rewards_available": 0,
      "balance": null,
      "scanned_at": "2026-11-03T10:15:00.000Z",
      "timestamp": "2026-11-03T10:15:04.000Z"
    }
  ]
}
