{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/semilattice-ai/json-schema/semilattice-ai-create-simulation-body-schema.json",
  "title": "CreateSimulationBody",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/semilattice-ai-openapi.json#/components/schemas/CreateSimulationBody",
  "properties": {
    "mode": {
      "type": "string",
      "title": "Mode",
      "description": "'research' or 'journey'"
    },
    "goal": {
      "type": "string",
      "title": "Goal",
      "description": "Goal id within the mode (from /v1/simulation-schema)"
    },
    "inputs": {
      "additionalProperties": true,
      "type": "object",
      "title": "Inputs",
      "description": "Answers keyed by the goal's input ids (from /v1/simulation-schema)"
    },
    "user_model_ids": {
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "type": "array",
      "title": "User Model Ids",
      "description": "One or more user-model ids to simulate against"
    },
    "title": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Title",
      "description": "A name for the simulation. Leave it out and it is named from what it asks."
    },
    "project_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Project Id",
      "description": "Optional project to add this simulation to; it joins the project's latest round (round 1 is created if none exists)"
    },
    "survey_design": {
      "anyOf": [
        {
          "$ref": "#/$defs/SurveyDesign"
        },
        {
          "type": "null"
        }
      ],
      "description": "Research mode only. Fixes which questions are asked: one per item in each item set plus one per custom question. The question writer only words them. Leave out to let it decide what to ask. A malformed survey_design is a 422 like any other malformed field; a well-formed one that cannot be used (journey mode, nothing to ask, too many questions) is a 400."
    },
    "context_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Context Id",
      "description": "Context to plan against (from /v1/contexts). Defaults to your most recently updated context, else your organisation's. A simulation in a project plans against the project's context, so leave this out when passing project_id unless it names that same context."
    },
    "round_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Round Id",
      "description": "Round of project_id to put this simulation in. Defaults to the project's latest round."
    }
  },
  "type": "object",
  "required": [
    "mode",
    "goal",
    "user_model_ids"
  ],
  "$defs": {
    "DesignCustomQuestion": {
      "properties": {
        "question_text": {
          "type": "string",
          "minLength": 1,
          "title": "Question Text",
          "description": "The question, asked exactly as written. Respondents see only this text, so name what it asks about: 'Would you pay £45 a week for this meal kit?', not 'Would you buy this?'."
        },
        "answer_options": {
          "anyOf": [
            {
              "items": {
                "type": "string",
                "minLength": 1
              },
              "type": "array",
              "maxItems": 10,
              "minItems": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "Answer Options",
          "description": "Answer options, used exactly as given. Leave out to let the question writer supply them."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "question_text"
      ],
      "title": "DesignCustomQuestion"
    },
    "DesignItemSet": {
      "properties": {
        "ask": {
          "type": "string",
          "minLength": 1,
          "title": "Ask",
          "description": "What is asked about every item in the set, e.g. 'How valuable would this feature be to you?'"
        },
        "items": {
          "items": {
            "type": "string",
            "minLength": 1
          },
          "type": "array",
          "minItems": 2,
          "title": "Items",
          "description": "The things being compared. Each one gets its own question."
        },
        "scale": {
          "anyOf": [
            {
              "items": {
                "type": "string",
                "minLength": 1
              },
              "type": "array",
              "maxItems": 7,
              "minItems": 2
            },
            {
              "type": "null"
            }
          ],
          "title": "Scale",
          "description": "Answer labels every question in the set uses, ordered from least to most favourable. Leave out to let the question writer pick one scale for the whole set."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "required": [
        "ask",
        "items"
      ],
      "title": "DesignItemSet"
    },
    "SurveyDesign": {
      "properties": {
        "stimulus": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Stimulus",
          "description": "What is being tested: a concept, a message, a price. The question writer states it in every item set question. Custom questions are used as written and do not get it added."
        },
        "item_sets": {
          "items": {
            "$ref": "#/$defs/DesignItemSet"
          },
          "type": "array",
          "title": "Item Sets",
          "description": "Groups of items that each get their own question on one shared scale, so the items can be compared with each other."
        },
        "custom_questions": {
          "items": {
            "$ref": "#/$defs/DesignCustomQuestion"
          },
          "type": "array",
          "title": "Custom Questions",
          "description": "Individual questions asked as written."
        }
      },
      "additionalProperties": false,
      "type": "object",
      "title": "SurveyDesign"
    }
  }
}