> ## Documentation Index
> Fetch the complete documentation index at: https://docs.semilattice.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a simulation

> Create a simulation from mode + goal + inputs + user_model_ids.

Returns immediately in status `planning`; the plan is generated in the
background. Poll `GET /v1/simulations/{id}` until status is `planned` or
`failed`.

With project_id it joins round_id, or the project's latest round. Refused
with 409 while the agent in the app is replying on that project.



## OpenAPI

````yaml https://api.semilattice.ai/openapi.json post /v1/simulations
openapi: 3.1.0
info:
  title: Semilattice API
  description: >-
    Plan and run simulations of how your users will react to your work, and read
    the results. Everything you create is saved in your Semilattice account, so
    it also appears in the app.


    Authenticate with an API key from **Settings → API Keys** in the app, sent
    as `Authorization: Bearer <key>`.
  contact:
    name: Semilattice API
    url: https://semilattice.ai/
    email: support@semilattice.ai
  version: v1.0.0
servers:
  - url: https://api.semilattice.ai
security:
  - BearerAuth: []
tags:
  - name: Simulations
    description: >-
      A simulation asks one or more user models questions (User Research) or
      sends their simulated users through a page or a flow (User Journey). It is
      planned first, then run once you have checked the plan.
  - name: Projects
    description: >-
      A project groups the simulations about one piece of work, split into
      rounds.
  - name: Rounds
    description: >-
      A round is one version of what you are testing: the document, page or file
      it tests, its simulations, and one synthesis across them.
  - name: Context
    description: >-
      Your context is the background on your company or product that every
      simulation is planned against.
  - name: User Models
    description: >-
      A user model is a simulated version of a specific group of people, built
      from real human data. Every simulation runs against one or more. A segment
      is a user model cut from another by its simulated users' attributes.
  - name: Simulation Schema
    description: >-
      The goals each kind of simulation offers, and what each goal needs from
      you.
paths:
  /v1/simulations:
    post:
      tags:
        - Simulations
      summary: Create a simulation
      description: >-
        Create a simulation from mode + goal + inputs + user_model_ids.


        Returns immediately in status `planning`; the plan is generated in the

        background. Poll `GET /v1/simulations/{id}` until status is `planned` or

        `failed`.


        With project_id it joins round_id, or the project's latest round.
        Refused

        with 409 while the agent in the app is replying on that project.
      operationId: create_simulation_route_v1_simulations_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            type: string
            title: Authorization
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSimulationBody'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
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: '#/components/schemas/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
      title: CreateSimulationBody
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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: '#/components/schemas/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: '#/components/schemas/DesignCustomQuestion'
          type: array
          title: Custom Questions
          description: Individual questions asked as written.
      additionalProperties: false
      type: object
      title: SurveyDesign
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    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
    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
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.