{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "archivedAt": {
        "anyOf": [
          {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          {
            "type": "null"
          }
        ]
      },
      "version": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100,
        "pattern": "^[a-zA-Z0-9_-]+$"
      },
      "definition": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "key": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "enabled": {
            "default": true,
            "type": "boolean"
          },
          "qualification": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "signup"
                  }
                },
                "required": ["kind"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "quest"
                  },
                  "quest": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-zA-Z0-9_-]+$"
                  }
                },
                "required": ["kind", "quest"],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "const": "external"
                  }
                },
                "required": ["kind"],
                "additionalProperties": false
              }
            ]
          },
          "inviterGroup": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[a-zA-Z0-9_-]+$"
          },
          "rewards": {
            "default": {
              "inviter": [],
              "invitee": []
            },
            "type": "object",
            "properties": {
              "inviter": {
                "default": [],
                "maxItems": 10,
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "default": "points",
                          "type": "string",
                          "const": "points"
                        },
                        "balance": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100,
                          "pattern": "^[a-zA-Z0-9_-]+$"
                        },
                        "amount": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 2147483647
                        }
                      },
                      "required": ["kind", "balance", "amount"]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "tier"
                        },
                        "reward": {
                          "type": "object",
                          "properties": {
                            "badge": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100,
                              "pattern": "^[a-zA-Z0-9_-]+$"
                            },
                            "group": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100,
                              "pattern": "^[a-zA-Z0-9_-]+$"
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100,
                              "pattern": "^[a-zA-Z0-9_-]+$"
                            },
                            "title": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 120
                            },
                            "tiers": {
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 100,
                                    "pattern": "^[a-zA-Z0-9_-]+$"
                                  },
                                  "title": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 120
                                  }
                                },
                                "required": ["id", "title"]
                              }
                            },
                            "inventory": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "const": "untracked"
                                }
                              },
                              "required": ["kind"]
                            },
                            "fulfillment": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "staff-handover"
                                    }
                                  },
                                  "required": ["kind"],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "automatic"
                                    }
                                  },
                                  "required": ["kind"],
                                  "additionalProperties": false
                                }
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "tiers",
                            "inventory",
                            "fulfillment"
                          ]
                        },
                        "tier": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100,
                          "pattern": "^[a-zA-Z0-9_-]+$"
                        }
                      },
                      "required": ["kind", "reward", "tier"]
                    }
                  ]
                }
              },
              "invitee": {
                "default": [],
                "maxItems": 10,
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "default": "points",
                          "type": "string",
                          "const": "points"
                        },
                        "balance": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100,
                          "pattern": "^[a-zA-Z0-9_-]+$"
                        },
                        "amount": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 2147483647
                        }
                      },
                      "required": ["kind", "balance", "amount"]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "type": "string",
                          "const": "tier"
                        },
                        "reward": {
                          "type": "object",
                          "properties": {
                            "badge": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100,
                              "pattern": "^[a-zA-Z0-9_-]+$"
                            },
                            "group": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100,
                              "pattern": "^[a-zA-Z0-9_-]+$"
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100,
                              "pattern": "^[a-zA-Z0-9_-]+$"
                            },
                            "title": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 120
                            },
                            "tiers": {
                              "minItems": 1,
                              "maxItems": 20,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 100,
                                    "pattern": "^[a-zA-Z0-9_-]+$"
                                  },
                                  "title": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 120
                                  }
                                },
                                "required": ["id", "title"]
                              }
                            },
                            "inventory": {
                              "type": "object",
                              "properties": {
                                "kind": {
                                  "type": "string",
                                  "const": "untracked"
                                }
                              },
                              "required": ["kind"]
                            },
                            "fulfillment": {
                              "oneOf": [
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "staff-handover"
                                    }
                                  },
                                  "required": ["kind"],
                                  "additionalProperties": false
                                },
                                {
                                  "type": "object",
                                  "properties": {
                                    "kind": {
                                      "type": "string",
                                      "const": "automatic"
                                    }
                                  },
                                  "required": ["kind"],
                                  "additionalProperties": false
                                }
                              ]
                            }
                          },
                          "required": [
                            "id",
                            "title",
                            "tiers",
                            "inventory",
                            "fulfillment"
                          ]
                        },
                        "tier": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100,
                          "pattern": "^[a-zA-Z0-9_-]+$"
                        }
                      },
                      "required": ["kind", "reward", "tier"]
                    }
                  ]
                }
              }
            },
            "required": ["inviter", "invitee"]
          },
          "milestones": {
            "default": [],
            "maxItems": 30,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "count": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "rewards": {
                  "minItems": 1,
                  "maxItems": 10,
                  "type": "array",
                  "items": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "default": "points",
                            "type": "string",
                            "const": "points"
                          },
                          "balance": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100,
                            "pattern": "^[a-zA-Z0-9_-]+$"
                          },
                          "amount": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 2147483647
                          }
                        },
                        "required": ["kind", "balance", "amount"]
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "tier"
                          },
                          "reward": {
                            "type": "object",
                            "properties": {
                              "badge": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 100,
                                "pattern": "^[a-zA-Z0-9_-]+$"
                              },
                              "group": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 100,
                                "pattern": "^[a-zA-Z0-9_-]+$"
                              },
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 100,
                                "pattern": "^[a-zA-Z0-9_-]+$"
                              },
                              "title": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 120
                              },
                              "tiers": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 100,
                                      "pattern": "^[a-zA-Z0-9_-]+$"
                                    },
                                    "title": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 120
                                    }
                                  },
                                  "required": ["id", "title"]
                                }
                              },
                              "inventory": {
                                "type": "object",
                                "properties": {
                                  "kind": {
                                    "type": "string",
                                    "const": "untracked"
                                  }
                                },
                                "required": ["kind"]
                              },
                              "fulfillment": {
                                "oneOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "staff-handover"
                                      }
                                    },
                                    "required": ["kind"],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "kind": {
                                        "type": "string",
                                        "const": "automatic"
                                      }
                                    },
                                    "required": ["kind"],
                                    "additionalProperties": false
                                  }
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "title",
                              "tiers",
                              "inventory",
                              "fulfillment"
                            ]
                          },
                          "tier": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100,
                            "pattern": "^[a-zA-Z0-9_-]+$"
                          }
                        },
                        "required": ["kind", "reward", "tier"]
                      }
                    ]
                  }
                }
              },
              "required": ["id", "count", "rewards"]
            }
          },
          "bonuses": {
            "default": [],
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "balance": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 100,
                  "pattern": "^[a-zA-Z0-9_-]+$"
                },
                "basisPoints": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 10000
                },
                "quests": {
                  "minItems": 1,
                  "maxItems": 100,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "pattern": "^[a-zA-Z0-9_-]+$"
                  }
                },
                "external": {
                  "default": false,
                  "type": "boolean"
                },
                "durationDays": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 36500
                },
                "maxPoints": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                }
              },
              "required": ["id", "balance", "basisPoints", "external"]
            }
          }
        },
        "required": [
          "id",
          "title",
          "enabled",
          "qualification",
          "rewards",
          "milestones",
          "bonuses"
        ]
      },
      "publishedAt": {
        "type": "integer",
        "minimum": 0,
        "maximum": 9007199254740991
      },
      "actor": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "required": ["version", "definition", "publishedAt", "actor"]
  }
}
