{
  "$defs": {
    "BusinessPriors": {
      "additionalProperties": false,
      "description": "Beliefs in business units, per channel (keys are channel *labels* as in the data),\nand/or about the baseline. At least one belief is stated: a baseline belief alone is\nfine (channels without a belief keep the model's default priors).",
      "examples": [
        {
          "baseline_share": {
            "credibility": 0.8,
            "share": [
              0.5,
              0.8
            ]
          },
          "channels": {
            "search": {
              "credibility": 0.9,
              "roi": [
                2.0,
                6.0
              ]
            },
            "social": {
              "contribution_share": [
                0.02,
                0.1
              ]
            },
            "tv": {
              "credibility": 0.8,
              "roi": [
                1.5,
                4.0
              ]
            }
          },
          "kpi_units": "EUR",
          "spend_units": "EUR"
        }
      ],
      "properties": {
        "baseline_share": {
          "anyOf": [
            {
              "$ref": "#/$defs/ShareBelief"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "channels": {
          "additionalProperties": {
            "$ref": "#/$defs/ChannelBelief"
          },
          "maxProperties": 64,
          "title": "Channels",
          "type": "object"
        },
        "kpi_units": {
          "anyOf": [
            {
              "maxLength": 64,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "examples": [
            "EUR"
          ],
          "title": "Kpi Units"
        },
        "spend_units": {
          "anyOf": [
            {
              "maxLength": 64,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "examples": [
            "EUR"
          ],
          "title": "Spend Units"
        }
      },
      "title": "BusinessPriors",
      "type": "object"
    },
    "ChannelBelief": {
      "additionalProperties": false,
      "description": "What the user believes about one channel: exactly one of ``roi`` or\n``contribution_share``, held with ``credibility``.\n\n* ``roi``: KPI units gained per spend unit over the fit window (``[1.5, 4]`` = \"every\n  euro returns between 1.5 and 4 euros of revenue\");\n* ``contribution_share``: the channel's share of the KPI over the fit window.",
      "properties": {
        "contribution_share": {
          "anyOf": [
            {
              "maxItems": 2,
              "minItems": 2,
              "prefixItems": [
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ],
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "examples": [
            [
              0.05,
              0.15
            ]
          ],
          "title": "Contribution Share"
        },
        "credibility": {
          "default": 0.8,
          "description": "Probability that the true value lies inside the range (0.8 = 'I am 80% sure')",
          "maximum": 0.99,
          "minimum": 0.5,
          "title": "Credibility",
          "type": "number"
        },
        "roi": {
          "anyOf": [
            {
              "maxItems": 2,
              "minItems": 2,
              "prefixItems": [
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ],
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "examples": [
            [
              1.5,
              4.0
            ]
          ],
          "title": "Roi"
        }
      },
      "title": "ChannelBelief",
      "type": "object"
    },
    "ColumnProfile": {
      "additionalProperties": false,
      "description": "What the browser (DuckDB-WASM/papaparse preview) or an ingest profile knows about a\ncolumn. ``name`` and ``sample`` are user data: render them as text only.",
      "examples": [
        {
          "dtype": "number",
          "max": 98312.0,
          "min": 1520.5,
          "n_distinct": 1012,
          "n_rows": 1040,
          "name": "revenue_eur"
        },
        {
          "detected_freq": "W-SUN",
          "dtype": "date",
          "max_date": "2025-12-28",
          "min_date": "2024-01-07",
          "n_distinct": 104,
          "n_rows": 1040,
          "name": "week"
        }
      ],
      "properties": {
        "detected_freq": {
          "anyOf": [
            {
              "maxLength": 16,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "examples": [
            "W-SUN",
            "D",
            "MS"
          ],
          "title": "Detected Freq"
        },
        "dtype": {
          "enum": [
            "number",
            "integer",
            "string",
            "date",
            "boolean"
          ],
          "title": "Dtype",
          "type": "string"
        },
        "max": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Max"
        },
        "max_date": {
          "anyOf": [
            {
              "maxLength": 40,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Max Date"
        },
        "min": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Min"
        },
        "min_date": {
          "anyOf": [
            {
              "maxLength": 40,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Min Date"
        },
        "monotonic": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Values never decrease in file order (dates of a single series, trip numbers); repeated panels of dates are not monotonic",
          "title": "Monotonic"
        },
        "n_distinct": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "N Distinct"
        },
        "n_missing": {
          "default": 0,
          "minimum": 0,
          "title": "N Missing",
          "type": "integer"
        },
        "n_rows": {
          "minimum": 0,
          "title": "N Rows",
          "type": "integer"
        },
        "name": {
          "maxLength": 256,
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "origin": {
          "anyOf": [
            {
              "enum": [
                "column",
                "mff_variable",
                "dim",
                "variable"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Where the profile comes from: a table column, a VariableName of an MFF table, or a dim/variable of a stored dataset",
          "title": "Origin"
        },
        "sample": {
          "items": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ]
          },
          "maxItems": 20,
          "title": "Sample",
          "type": "array"
        }
      },
      "required": [
        "name",
        "dtype",
        "n_rows"
      ],
      "title": "ColumnProfile",
      "type": "object"
    },
    "JsonValue": {},
    "LiftTest": {
      "additionalProperties": false,
      "description": "One experiment: ``spend_delta`` extra spend on ``channel`` (optionally in one ``geo``)\nfrom ``start`` to ``end`` (inclusive) caused ``kpi_delta`` incremental KPI.\n\nGive the measurement's uncertainty as a standard error ``se`` *or* a confidence interval\n``ci`` at ``ci_level``. A holdout (\"turn the channel off\") is a negative ``spend_delta``\nwith (usually) a negative ``kpi_delta``.",
      "examples": [
        {
          "channel": "tv",
          "ci": [
            -380000.0,
            -140000.0
          ],
          "ci_level": 0.9,
          "description": "TV off in Germany for four weeks",
          "end": "2026-05-03",
          "geo": "de",
          "id": "tv-holdout-2026q2",
          "kpi_delta": -260000.0,
          "spend_delta": -120000.0,
          "start": "2026-04-06"
        }
      ],
      "properties": {
        "channel": {
          "maxLength": 128,
          "minLength": 1,
          "title": "Channel",
          "type": "string"
        },
        "ci": {
          "anyOf": [
            {
              "maxItems": 2,
              "minItems": 2,
              "prefixItems": [
                {
                  "type": "number"
                },
                {
                  "type": "number"
                }
              ],
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Confidence interval of kpi_delta",
          "title": "Ci"
        },
        "ci_level": {
          "default": 0.9,
          "maximum": 0.999,
          "minimum": 0.5,
          "title": "Ci Level",
          "type": "number"
        },
        "description": {
          "anyOf": [
            {
              "maxLength": 500,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Description"
        },
        "end": {
          "format": "date",
          "title": "End",
          "type": "string"
        },
        "geo": {
          "anyOf": [
            {
              "maxLength": 128,
              "minLength": 1,
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Geo"
        },
        "id": {
          "anyOf": [
            {
              "pattern": "^[a-z0-9][a-z0-9_-]{0,62}$",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Id"
        },
        "kpi_delta": {
          "description": "Measured incremental KPI (KPI units)",
          "title": "Kpi Delta",
          "type": "number"
        },
        "se": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Standard error of kpi_delta",
          "title": "Se"
        },
        "spend_delta": {
          "description": "Extra spend during the test (spend units)",
          "title": "Spend Delta",
          "type": "number"
        },
        "start": {
          "format": "date",
          "title": "Start",
          "type": "string"
        }
      },
      "required": [
        "channel",
        "start",
        "end",
        "spend_delta",
        "kpi_delta"
      ],
      "title": "LiftTest",
      "type": "object"
    },
    "ShareBelief": {
      "additionalProperties": false,
      "description": "A share range (for example of the baseline: KPI that happens without any media).",
      "properties": {
        "credibility": {
          "default": 0.8,
          "description": "Probability that the true value lies inside the range (0.8 = 'I am 80% sure')",
          "maximum": 0.99,
          "minimum": 0.5,
          "title": "Credibility",
          "type": "number"
        },
        "share": {
          "maxItems": 2,
          "minItems": 2,
          "prefixItems": [
            {
              "type": "number"
            },
            {
              "type": "number"
            }
          ],
          "title": "Share",
          "type": "array"
        }
      },
      "required": [
        "share"
      ],
      "title": "ShareBelief",
      "type": "object"
    }
  },
  "$id": "https://schemas.mapi.dev/v1/api-GuidedAnswers.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "``POST /v1/guided/drafts``: answers to a template's questions.\n\nColumn answers are *column names* of the upload (a list for ``columns`` questions).\n``dataset`` names the dataset the upload will become (``dataset://<project>/<name>``);\n``columns`` (optional) lets the draft use detected types and frequencies.",
  "examples": [
    {
      "answers": {
        "controls": [
          "avg_price"
        ],
        "date": "week",
        "frequency": "weekly",
        "geo": "market",
        "holdout_periods": 8,
        "kpi": "revenue_eur",
        "spend": [
          "tv_spend",
          "search_spend",
          "social_spend"
        ]
      },
      "dataset": "eu_media_weekly",
      "format": "csv",
      "name": "eu-geo-mmm",
      "template_id": "geo_mmm"
    }
  ],
  "properties": {
    "answers": {
      "additionalProperties": {
        "$ref": "#/$defs/JsonValue"
      },
      "maxProperties": 32,
      "title": "Answers",
      "type": "object"
    },
    "business_priors": {
      "anyOf": [
        {
          "$ref": "#/$defs/BusinessPriors"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "columns": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/ColumnProfile"
          },
          "maxItems": 2048,
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Columns"
    },
    "dataset": {
      "description": "Name of the dataset the upload becomes",
      "pattern": "^[a-z0-9](?:[a-z0-9_-]{0,126}[a-z0-9])?$",
      "title": "Dataset",
      "type": "string"
    },
    "format": {
      "default": "csv",
      "description": "The upload's format; for 'mff' (M3) column answers name VariableName values, Period and the MFF key columns",
      "enum": [
        "csv",
        "parquet",
        "mff"
      ],
      "title": "Format",
      "type": "string"
    },
    "lift_tests": {
      "items": {
        "$ref": "#/$defs/LiftTest"
      },
      "maxItems": 500,
      "title": "Lift Tests",
      "type": "array"
    },
    "name": {
      "description": "Name of the spec (and model) to create",
      "pattern": "^[a-z0-9](?:[a-z0-9_-]{0,126}[a-z0-9])?$",
      "title": "Name",
      "type": "string"
    },
    "template_id": {
      "pattern": "^[a-z0-9](?:[a-z0-9_-]{0,126}[a-z0-9])?$",
      "title": "Template Id",
      "type": "string"
    }
  },
  "required": [
    "template_id",
    "name",
    "dataset"
  ],
  "title": "GuidedAnswers",
  "type": "object",
  "x-mapi-contract-version": "0.2"
}
