{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "title": "Tracking link",
  "required": [
    "destinationUrl",
    "slug",
    "metadata"
  ],
  "properties": {
    "destinationUrl": {
      "title": "Destination URL",
      "type": "string",
      "format": "url",
      "maxLength": 1000
    },
    "slug": {
      "title": "Slug",
      "type": "string",
      "pattern": "^([0-9a-zA-Z-_]*)$",
      "maxLength": 256
    },
    "status": {
      "title": "Status",
      "type": "string",
      "default": "draft",
      "description": "draft / published / hidden",
      "enum": [
        "draft",
        "published",
        "hidden"
      ]
    },
    "metadata": {
      "type": "object",
      "title": "Attribution Information",
      "required": [
        "channel",
      ],
      "properties": {
        "channel": {
          "$ref": "#/definitions/channel"
        },
        "subchannel": {
          "$ref": "#/definitions/subchannel"
        },
        "audience": {
          "$ref": "#/definitions/audience"
        },
        "placementType": {
          "$ref": "#/definitions/placementType"
        },
        "campaign": {
          "$ref": "#/definitions/campaign"
        },
        "subcampaign": {
          "$ref": "#/definitions/subcampaign"
        },
        "source": {
          "$ref": "#/definitions/source"
        },
        "content": {
          "$ref": "#/definitions/content"
        },
        "medium": {
          "$ref": "#/definitions/medium"
        }
      }
    },
    "additionalQueryParams": {
      "type": "object",
      "required": [
      ],
      "properties": {
        "plan_id": {
          "$ref": "#/definitions/schoolPlanId"
        },
        "coupon_code": {
          "$ref": "#/definitions/schoolCouponCode"
        }
      }
    },
    "description": {
      "title": "Description",
      "type": "string",
      "description": "What's this URL for"
    },
    "forwardAllQueryParams": {
      "title": "Forward all query parameters",
      "type": "boolean"
    },
    "forwardQueryParamsWhitelist": {
      "title": "Whitelist of query parameters to forward",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "definitions": {
    "channel": {
      "$id": "#/definitions/channel",
      "title": "Channel",
      "type": "string",
      "description": "top-level category",
      "anyOf": [
        {
          "title": "paid search non-brand",
          "enum": [
            "pnb"
          ],
          "type": "string"
        },
        {
          "title": "paid search brand",
          "enum": [
            "psb"
          ],
          "type": "string"
        },
        {
          "title": "paid social",
          "enum": [
            "ps"
          ],
          "type": "string"
        },
        {
          "title": "mixed media",
          "enum": [
            "mm"
          ],
          "type": "string"
        },
        {
          "title": "podcast",
          "enum": [
            "pod"
          ],
          "type": "string"
        },
        {
          "title": "online radio",
          "enum": [
            "ord"
          ],
          "type": "string"
        },
        {
          "title": "radio",
          "enum": [
            "rd"
          ],
          "type": "string"
        },
        {
          "title": "tv",
          "enum": [
            "tv"
          ],
          "type": "string"
        },
        {
          "title": "online video",
          "enum": [
            "ov"
          ],
          "type": "string"
        },
        {
          "title": "out of home",
          "enum": [
            "ooh"
          ],
          "type": "string"
        },
        {
          "title": "paid bd partners",
          "enum": [
            "pbp"
          ],
          "type": "string"
        },
        {
          "title": "unpaid bd partners",
          "enum": [
            "ubp"
          ],
          "type": "string"
        },
        {
          "title": "affiliate",
          "enum": [
            "aff"
          ],
          "type": "string"
        },
        {
          "title": "press",
          "enum": [
            "pr"
          ],
          "type": "string"
        },
        {
          "title": "events",
          "enum": [
            "evt"
          ],
          "type": "string"
        },
        {
          "title": "social media",
          "enum": [
            "sm"
          ],
          "type": "string"
        },
        {
          "title": "word of mouth",
          "enum": [
            "wm"
          ],
          "type": "string"
        },
        {
          "title": "organic search",
          "enum": [
            "os"
          ],
          "type": "string"
        },
        {
          "title": "unknown referer",
          "enum": [
            "ur"
          ],
          "type": "string"
        },
        {
          "title": "no attribution (direct)",
          "enum": [
            "na"
          ],
          "type": "string"
        },
        {
          "title": "email",
          "enum": [
            "em"
          ],
          "type": "string"
        },
        {
          "title": "webinar",
          "enum": [
            "wbr"
          ],
          "type": "string"
        },
        {
          "title": "referral",
          "enum": [
            "ref"
          ],
          "type": "string"
        },
        {
          "title": "retargeting",
          "enum": [
            "rtg"
          ],
          "type": "string"
        }
      ]
    },
    "subchannel": {
      "title": "Subchannel",
      "type": "string",
      "description": "network with many sources (e.g. The Ringer)"
    },
    "source": {
      "title": "Source",
      "type": "string",
      "description": "traffic source (e.g. bill-simmons-podcast)",
      "pattern": "^([0-9a-zA-Z-_]*)$"
    },
    "campaign": {
      "title": "Campaign",
      "type": "string",
      "description": "campaign name (e.g. creator-challenge-2019)",
      "pattern": "^([0-9a-zA-Z-_]*)$"
    },
    "subcampaign": {
      "title": "Subcampaign",
      "type": "string",
      "description": "campaign detail, e.g. us-daypart-preroll-insert",
      "pattern": "^([0-9a-zA-Z-_]*)$"
    },
    "content": {
      "title": "Content",
      "type": "string",
      "description": "creative or offer (creator-challenge-offer-v1)",
      "pattern": "^([0-9a-zA-Z-_]*)$"
    },
    "medium": {
      "type": "string",
      "title": "Medium",
      "description": "promo type (e.g. blog, newsletter, social post)"
    },
    "audience": {
      "type": "string",
      "title": "Audience*",
      "description": "e.g. general, fitness, coaching, artists",
      "enum": [
        "general",
        "fitness",
        "coaching",
        "artists",
        "teachers",
        "general",
        "personal-development",
        "business-marketing",
        "finance-Investing",
        "software-technology",
        "health-wellness",
        "fitness-nutrition",
        "family-parenting",
        "fashion-beauty",
        "arts-crafting",
        "design-ux",
        "music-instruments",
        "photo-video",
        "food-drink",
        "acting-entertainment",
        "academics-languages",
        "spirituality-worship",
        "teachable-properties",
        "paid-social",
        "paid-search-non-brand",
        "paid-search-brand",
        "paid-partners",
        "display-programmatic",
        "mixed-media",
        "podcast",
        "affiliate",
        "streaming-audio",
        "streaming-video",
        "radio",
        "direct-mail",
        "out-of-home",
        "events",
        "tv",
        "referral",
        "press",
        "unpaid-social",
        "unpaid-partners",
        "email",
        "messaging-service"
      ]
    },
    "placementType": {
      "type": "string",
      "title": "Paid or unpaid placement",
      "enum": [
        "paid",
        "unpaid"
      ]
    },
    "schoolCouponCode": {
      "type": "string",
      "title": "Teachable coupon"
    },
    "schoolPlanId": {
      "type": "number",
      "title": "School Plan",
      "anyOf": [
        {
          "title": "free - month - $0",
          "enum": [
            4
          ],
          "type": "number"
        },
        {
          "title": "basic - month - $39",
          "enum": [
            10
          ],
          "type": "number"
        },
        {
          "title": "basic - year - $348",
          "enum": [
            54
          ],
          "type": "number"
        },
        {
          "title": "professional - month - $99",
          "enum": [
            3
          ],
          "type": "number"
        },
        {
          "title": "professional - year - $948",
          "enum": [
            53
          ],
          "type": "number"
        },
        {
          "title": "high_volume - month - $499",
          "enum": [
            24
          ],
          "type": "number"
        },
        {
          "title": "high_volume - year - $4788",
          "enum": [
            25
          ],
          "type": "number"
        }
      ]
    }
  }
}
