{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/thebridge-dev/json-schema/thebridge-dev-store-attribution-dto-schema.json",
  "title": "StoreAttributionDto",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/thebridge-dev-openapi.json#/components/schemas/StoreAttributionDto",
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "format": "email"
    },
    "capture": {
      "type": "string",
      "description": "TBP-474 — how the client obtained this record.\n\n`direct` and `unknown` are NOT interchangeable. `direct` means capture ran\nand found no channel, which is a real answer. `unknown` means capture\ncould not run at all, which is a measurement failure. Collapsing them\nmakes `direct` absorb every failure and then look like the strongest\nchannel at exactly the moment a budget decision rests on it.",
      "enum": [
        "utm",
        "referrer",
        "direct",
        "unknown"
      ]
    },
    "marketing_consent": {
      "type": "boolean",
      "description": "Whether the visitor granted marketing consent.\n\nGates the Reddit CAPI fire only — that sends a hashed email to a third\nparty for advertising. Writing the tenant's own attribution record is\nfirst-party processing and happens regardless, which is what keeps the\nmeasurement honest for people who refuse cookies."
    },
    "rdt_cid": {
      "type": "string"
    },
    "utm_source": {
      "type": "string"
    },
    "utm_medium": {
      "type": "string"
    },
    "utm_campaign": {
      "type": "string"
    },
    "utm_content": {
      "type": "string"
    },
    "utm_term": {
      "type": "string"
    },
    "gclid": {
      "type": "string"
    },
    "fbclid": {
      "type": "string"
    },
    "li_fat_id": {
      "type": "string"
    },
    "ref": {
      "type": "string",
      "description": "TBP-891 — the content code from a short link (`ref=CODE7`, TBP-894). Never `code`: that is OAuth's.",
      "maxLength": 64
    },
    "landing_path": {
      "type": "string",
      "description": "TBP-746 — first page of the visit on the marketing site (path only).",
      "maxLength": 512
    },
    "referrer_host": {
      "type": "string",
      "description": "TBP-746 — host of the external referrer, never the full URL.",
      "maxLength": 255
    },
    "last_touch": {
      "description": "TBP-746 — the latest touch, when the client saw a different one from the\nearliest (top-level fields). Stored in `metadata.attribution_last`, which\nis overwritten on every write; absent means \"same as the top level\".",
      "allOf": [
        {
          "$ref": "#/$defs/AttributionTouchDto"
        }
      ]
    }
  },
  "required": [
    "email"
  ],
  "$defs": {
    "AttributionTouchDto": {
      "type": "object",
      "properties": {
        "capture": {
          "type": "string",
          "enum": [
            "utm",
            "referrer",
            "direct",
            "unknown"
          ]
        },
        "rdt_cid": {
          "type": "string",
          "maxLength": 512
        },
        "utm_source": {
          "type": "string",
          "maxLength": 512
        },
        "utm_medium": {
          "type": "string",
          "maxLength": 512
        },
        "utm_campaign": {
          "type": "string",
          "maxLength": 512
        },
        "utm_content": {
          "type": "string",
          "maxLength": 512
        },
        "utm_term": {
          "type": "string",
          "maxLength": 512
        },
        "gclid": {
          "type": "string",
          "maxLength": 512
        },
        "fbclid": {
          "type": "string",
          "maxLength": 512
        },
        "li_fat_id": {
          "type": "string",
          "maxLength": 512
        },
        "ref": {
          "type": "string",
          "description": "TBP-891 — the content code from a short link (`ref=CODE7`, TBP-894).",
          "maxLength": 64
        },
        "landing_path": {
          "type": "string",
          "description": "TBP-746 — first page of the visit on the marketing site (path only).",
          "maxLength": 512
        },
        "referrer_host": {
          "type": "string",
          "description": "TBP-746 — host of the external referrer, never the full URL.",
          "maxLength": 255
        }
      }
    }
  }
}