{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mailinapp-com/json-schema/mailinapp-com-experiment-schema.json",
  "title": "Experiment",
  "description": "An A/B experiment. A send experiment mails its arms; a journey experiment's arms are a journey split's paths, and contacts are assigned as they reach the split. The same object is the `experiment` in the experiment.decided and experiment.completed webhook events.",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mailinapp-com-openapi.json#/components/schemas/Experiment",
  "type": "object",
  "required": [
    "id",
    "name",
    "kind",
    "status",
    "projectId",
    "journey",
    "hypothesis",
    "primaryMetric",
    "secondaryMetrics",
    "guardrailMetrics",
    "analysis",
    "arms",
    "createdAt",
    "lockedAt",
    "sendAt",
    "observationEndsAt",
    "closedAt",
    "result",
    "decision",
    "deployment",
    "resultsUrl"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "send",
        "journey"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "draft",
        "scheduled",
        "sending",
        "observing",
        "analyzing",
        "decided",
        "inconclusive",
        "closed",
        "cancelled"
      ]
    },
    "projectId": {
      "type": "string",
      "description": "The email the experiment is stored on: the one it sends, or for a journey experiment the first email its split reaches."
    },
    "journey": {
      "type": [
        "object",
        "null"
      ],
      "required": [
        "journeyId",
        "nodeId",
        "windowHours"
      ],
      "properties": {
        "journeyId": {
          "type": "string"
        },
        "nodeId": {
          "type": "string",
          "description": "The split step."
        },
        "windowHours": {
          "type": "integer",
          "description": "How long each contact is measured from reaching the split."
        }
      },
      "description": "Null for a send experiment."
    },
    "hypothesis": {
      "type": "string"
    },
    "primaryMetric": {
      "$ref": "#/$defs/ExperimentMetric"
    },
    "secondaryMetrics": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ExperimentMetric"
      }
    },
    "guardrailMetrics": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ExperimentMetric"
      }
    },
    "analysis": {
      "type": "string",
      "enum": [
        "fixed",
        "sequential"
      ]
    },
    "arms": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ExperimentArm"
      }
    },
    "createdAt": {
      "type": "integer",
      "description": "Epoch milliseconds, like every time below."
    },
    "lockedAt": {
      "type": [
        "integer",
        "null"
      ]
    },
    "sendAt": {
      "type": "integer"
    },
    "observationEndsAt": {
      "type": [
        "integer",
        "null"
      ]
    },
    "closedAt": {
      "type": [
        "integer",
        "null"
      ]
    },
    "result": {
      "type": [
        "object",
        "null"
      ],
      "description": "What the statistics engine said in the latest analysis; null before the first.",
      "required": [
        "outcome",
        "armKey",
        "final",
        "computedAt"
      ],
      "properties": {
        "outcome": {
          "type": "string",
          "enum": [
            "invalid",
            "winner",
            "no_difference",
            "inconclusive"
          ]
        },
        "armKey": {
          "type": [
            "string",
            "null"
          ],
          "description": "The winning arm, for a winner."
        },
        "final": {
          "type": "boolean",
          "description": "The analysis covers the whole observation window."
        },
        "computedAt": {
          "type": "integer"
        }
      }
    },
    "decision": {
      "type": [
        "object",
        "null"
      ],
      "description": "What a person recorded; null until then.",
      "required": [
        "outcome",
        "armKey",
        "pathIndex",
        "evidence",
        "rationale",
        "decidedAt"
      ],
      "properties": {
        "outcome": {
          "type": "string",
          "enum": [
            "winner",
            "inconclusive",
            "no_difference"
          ]
        },
        "armKey": {
          "type": [
            "string",
            "null"
          ]
        },
        "pathIndex": {
          "type": [
            "integer",
            "null"
          ],
          "description": "For a journey experiment's winner, the path everyone can be sent down. Sending them is done by a person in the journey editor, never automatically."
        },
        "evidence": {
          "type": "string",
          "enum": [
            "significant",
            "not_significant",
            "invalid"
          ],
          "description": "What the statistics said when the decision was recorded."
        },
        "rationale": {
          "type": "string"
        },
        "decidedAt": {
          "type": "integer"
        }
      }
    },
    "deployment": {
      "description": "How the winner was put to use; null until then. A path deployment has no email.",
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "required": [
            "kind",
            "projectId",
            "armKey",
            "deployedAt"
          ],
          "properties": {
            "kind": {
              "const": "email"
            },
            "projectId": {
              "type": "string",
              "description": "The email made from the winning arm."
            },
            "armKey": {
              "type": "string"
            },
            "deployedAt": {
              "type": "integer"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "kind",
            "pathIndex",
            "armKey",
            "deployedAt"
          ],
          "properties": {
            "kind": {
              "const": "path"
            },
            "pathIndex": {
              "type": "integer"
            },
            "armKey": {
              "type": "string"
            },
            "deployedAt": {
              "type": "integer"
            }
          }
        }
      ]
    },
    "resultsUrl": {
      "type": "string",
      "format": "uri",
      "description": "The results page in the dashboard."
    }
  },
  "$defs": {
    "ExperimentArm": {
      "type": "object",
      "required": [
        "key",
        "label",
        "isControl",
        "isHoldout",
        "allocation",
        "pathIndex"
      ],
      "properties": {
        "key": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "isControl": {
          "type": "boolean"
        },
        "isHoldout": {
          "type": "boolean",
          "description": "A holdout is mailed nothing."
        },
        "allocation": {
          "type": "number",
          "description": "The arm's share of the sample, 0–1."
        },
        "pathIndex": {
          "type": [
            "integer",
            "null"
          ],
          "description": "The split path this arm is (0-based), for a journey experiment; null for a send experiment."
        }
      }
    },
    "ExperimentMetric": {
      "type": "string",
      "enum": [
        "purchase_conversion",
        "revenue_per_delivered",
        "unique_click_rate",
        "response_rate",
        "reveal_rate",
        "post_reveal_click_rate",
        "open_rate",
        "goal_rate",
        "unsubscribe_rate",
        "complaint_rate"
      ],
      "description": "`goal_rate` is for journey experiments only."
    }
  }
}