{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/superflag-sh/json-schema/superflag-sh-experiment-create-request-schema.json",
  "title": "ExperimentCreateRequest",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/superflag-sh-openapi.json#/components/schemas/ExperimentCreateRequest",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "appId",
    "env",
    "key",
    "hypothesis",
    "owner",
    "flagKey",
    "audience",
    "assignmentUnit",
    "primaryMetric",
    "intendedDurationDays",
    "sampleTarget",
    "allocation",
    "idempotencyKey"
  ],
  "properties": {
    "appId": {
      "type": "string"
    },
    "env": {
      "type": "string"
    },
    "key": {
      "type": "string"
    },
    "expectedConfigVersion": {
      "type": "integer",
      "minimum": 0
    },
    "hypothesis": {
      "type": "string"
    },
    "owner": {
      "type": "string"
    },
    "flagKey": {
      "type": "string"
    },
    "audience": {
      "type": "object"
    },
    "assignmentUnit": {
      "type": "object"
    },
    "primaryMetric": {
      "type": "object"
    },
    "intendedDurationDays": {
      "type": "integer",
      "minimum": 1
    },
    "sampleTarget": {
      "type": "integer",
      "minimum": 1
    },
    "analysisDesign": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "method"
      ],
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "fixed_horizon",
            "sequential_obrien_fleming_v1"
          ]
        }
      }
    },
    "allocation": {
      "type": "array",
      "minItems": 2,
      "items": {
        "$ref": "#/$defs/WeightedVariation"
      }
    },
    "layer": {
      "$ref": "#/$defs/ExperimentLayerReference"
    },
    "idempotencyKey": {
      "type": "string",
      "minLength": 16,
      "maxLength": 128
    },
    "dryRun": {
      "type": "boolean"
    }
  },
  "$defs": {
    "AllocationRange": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "start": {
          "type": "integer",
          "minimum": 0,
          "maximum": 99999
        },
        "end": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000
        }
      }
    },
    "ExperimentLayerReference": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "capacity",
        "migration"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        },
        "capacity": {
          "$ref": "#/$defs/AllocationRange"
        },
        "migration": {
          "enum": [
            "frozen",
            "reset"
          ]
        }
      }
    },
    "WeightedVariation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "variation",
        "weight"
      ],
      "properties": {
        "variation": {
          "type": "string",
          "minLength": 1
        },
        "weight": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100000
        }
      }
    }
  }
}