{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "retention": {
      "type": "object",
      "properties": {
        "enabled": {
          "type": "boolean"
        },
        "dailyLookupLimit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000
        },
        "ttlHours": {
          "type": "integer",
          "minimum": 1,
          "maximum": 168
        }
      },
      "required": [
        "enabled",
        "dailyLookupLimit",
        "ttlHours"
      ],
      "additionalProperties": false
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "expectedVersion": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "experiment": {
      "type": "object",
      "properties": {
        "personalizedPercent": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "paused": {
          "type": "boolean"
        },
        "restart": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "goals": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "kind": {
            "type": "string",
            "enum": [
              "click",
              "page",
              "submit",
              "event"
            ]
          },
          "selector": {
            "type": "string",
            "minLength": 1,
            "maxLength": 300
          },
          "path": {
            "type": "string",
            "maxLength": 300,
            "pattern": "^\\/.*"
          },
          "event": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,79}$"
          },
          "value": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000
          },
          "primary": {
            "type": "boolean"
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "primary"
        ],
        "additionalProperties": false
      }
    },
    "connectors": {
      "maxItems": 5,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "kind": {
            "type": "string",
            "const": "http"
          },
          "url": {
            "type": "string",
            "maxLength": 500,
            "format": "uri"
          },
          "enabled": {
            "type": "boolean"
          },
          "timeoutMs": {
            "type": "integer",
            "minimum": 200,
            "maximum": 4000
          },
          "ttlHours": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2160
          },
          "send": {
            "type": "object",
            "properties": {
              "ip": {
                "type": "boolean"
              },
              "userAgent": {
                "type": "boolean"
              },
              "page": {
                "type": "boolean"
              },
              "referrer": {
                "type": "boolean"
              },
              "language": {
                "type": "boolean"
              }
            },
            "required": [
              "ip",
              "userAgent",
              "page",
              "referrer",
              "language"
            ],
            "additionalProperties": false
          },
          "headers": {
            "maxItems": 8,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9-]{1,64}$"
                },
                "secret": {
                  "type": "boolean"
                },
                "value": {
                  "type": "string",
                  "maxLength": 2000
                },
                "configured": {
                  "type": "boolean"
                }
              },
              "required": [
                "name",
                "secret"
              ],
              "additionalProperties": false
            }
          },
          "fields": {
            "maxItems": 30,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-zA-Z0-9_.-]{1,64}$"
            }
          }
        },
        "required": [
          "id",
          "name",
          "kind",
          "url",
          "enabled",
          "timeoutMs",
          "ttlHours",
          "send",
          "headers",
          "fields"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "id",
    "expectedVersion"
  ],
  "additionalProperties": false
}
