{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/layers-com/json-schema/layers-com-partner-experiment-create-request-schema-schema.json",
  "title": "PartnerExperimentCreateRequestSchema",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/layers-com-openapi.json#/components/schemas/PartnerExperimentCreateRequestSchema",
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]{0,79}$",
      "description": "Your stable handle for the experiment, unique per project. A second create with the same key returns 409 CONFLICT with the existing id in details.experimentId."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Short name shown in MMA."
    },
    "hypothesis": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 4000
        },
        {
          "type": "null"
        }
      ]
    },
    "primaryMetric": {
      "description": "The metric the decision rule reads, e.g. \"d7_roas\".",
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "decisionRule": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    },
    "decisionRuleDetail": {
      "description": "The full decision rule and its dated amendments, up to 10,000 characters. decisionRule holds the short rule.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 10000
        },
        {
          "type": "null"
        }
      ]
    },
    "baselineValue": {
      "description": "The primary metric's value before the test, in its own unit (a rate as a proportion, 0.18 for 18%).",
      "type": [
        "number",
        "null"
      ]
    },
    "baselineQuery": {
      "description": "The query or report that produced baselineValue, up to 4,000 characters.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 4000
        },
        {
          "type": "null"
        }
      ]
    },
    "baselineDate": {
      "description": "The day baselineValue was read, YYYY-MM-DD.",
      "anyOf": [
        {
          "type": "string",
          "format": "date",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))$"
        },
        {
          "type": "null"
        }
      ]
    },
    "mde": {
      "description": "The minimum detectable effect, absolute, in the primary metric's unit (0.03 is 3 points on a rate).",
      "anyOf": [
        {
          "type": "number",
          "exclusiveMinimum": 0
        },
        {
          "type": "null"
        }
      ]
    },
    "alpha": {
      "description": "The two-sided significance level, between 0 and 1 (for example 0.05).",
      "anyOf": [
        {
          "type": "number",
          "exclusiveMinimum": 0,
          "exclusiveMaximum": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "power": {
      "description": "The planned statistical power, between 0 and 1 (for example 0.8).",
      "anyOf": [
        {
          "type": "number",
          "exclusiveMinimum": 0,
          "exclusiveMaximum": 1
        },
        {
          "type": "null"
        }
      ]
    },
    "nPerArm": {
      "description": "The planned units per arm, a positive integer.",
      "anyOf": [
        {
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 2000000000
        },
        {
          "type": "null"
        }
      ]
    },
    "primarySource": {
      "description": "Where the primary metric is read, for example MMA or PostHog.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "analysisMethod": {
      "description": "The test, and the multiplicity control across arms or metrics.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    },
    "sequentialPlan": {
      "description": "A pre-declared sequential plan with its looks and boundaries. Null means one read at the planned n.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 4000
        },
        {
          "type": "null"
        }
      ]
    },
    "recheckMethod": {
      "description": "The independent re-check planned before a decision.",
      "anyOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ]
    },
    "guardrails": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "metric": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "rule": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          }
        },
        "required": [
          "metric",
          "rule"
        ],
        "additionalProperties": false
      }
    },
    "arms": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "allocation": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "match": {
            "maxItems": 3,
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "property": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9_$][A-Za-z0-9_$-]{0,99}(?:\\.[A-Za-z0-9_$-]{1,100}){0,3}$"
                },
                "value": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 200,
                  "pattern": "^[^\\r\\n]*$"
                }
              },
              "required": [
                "property",
                "value"
              ],
              "additionalProperties": false
            }
          },
          "exposureEvent": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "pattern": "^[^\\s\\p{Cc}][^\\p{Cc}]*$"
          },
          "landingUrls": {
            "maxItems": 5,
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 500,
              "format": "uri"
            }
          },
          "campaignIds": {
            "maxItems": 20,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{1,40}$"
            }
          },
          "adSetIds": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.:-]{1,40}$"
            }
          },
          "installNetworks": {
            "maxItems": 7,
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "meta",
                "google",
                "tiktok",
                "apple",
                "unity",
                "organic",
                "other"
              ]
            }
          },
          "excludeCountries": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            }
          },
          "includeCountries": {
            "maxItems": 50,
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Z]{2}$"
            }
          },
          "windowStart": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
          },
          "windowEnd": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
          }
        },
        "required": [
          "name",
          "allocation"
        ],
        "additionalProperties": false
      }
    },
    "status": {
      "$ref": "#/$defs/PartnerExperimentStatusSchema"
    },
    "startedAt": {
      "description": "Defaults to now when status first becomes running.",
      "anyOf": [
        {
          "$ref": "#/$defs/IsoTimestampSchema"
        },
        {
          "type": "null"
        }
      ]
    },
    "readAt": {
      "description": "The planned read date.",
      "anyOf": [
        {
          "$ref": "#/$defs/IsoTimestampSchema"
        },
        {
          "type": "null"
        }
      ]
    },
    "decidedAt": {
      "description": "Defaults to now when status first becomes decided.",
      "anyOf": [
        {
          "$ref": "#/$defs/IsoTimestampSchema"
        },
        {
          "type": "null"
        }
      ]
    },
    "result": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "winner": {
              "default": null,
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 100
                },
                {
                  "type": "null"
                }
              ]
            },
            "effect": {
              "default": null,
              "type": [
                "number",
                "null"
              ]
            },
            "ciLow": {
              "default": null,
              "type": [
                "number",
                "null"
              ]
            },
            "ciHigh": {
              "default": null,
              "type": [
                "number",
                "null"
              ]
            },
            "nPerArm": {
              "default": null,
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                {
                  "type": "null"
                }
              ]
            },
            "note": {
              "default": null,
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 4000
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "ownerLabel": {
      "description": "Who runs it, e.g. the agent or session name.",
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "sourceUrl": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000,
          "format": "uri"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "key",
    "title"
  ],
  "additionalProperties": false,
  "$defs": {
    "IsoTimestampSchema": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
        },
        {
          "type": "string",
          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?:Z))$"
        }
      ],
      "description": "ISO-8601 UTC timestamp with the 'Z' suffix (e.g. `2026-04-18T12:04:11Z`). Offset forms like `+00:00` are rejected with 422 VALIDATION — convert to UTC before sending. Outputs always emit `Z` so input shape matches output shape."
    },
    "PartnerExperimentStatusSchema": {
      "type": "string",
      "enum": [
        "planned",
        "running",
        "paused",
        "reading",
        "decided",
        "stopped"
      ],
      "description": "planned: designed, not started. running: collecting data. paused: enrollment is halted for now and the experiment will resume. reading: collection ended, the result is being read. decided: a result is recorded. stopped: ended without a decision."
    }
  }
}