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

# Simulate order type

> Runs a test order through the order type's steps without saving anything: no order, task or webhook is created. Requires permission `edit/orderType`.
Uses the stored draft, or the unsaved `draft` you send. Tasks are completed with the `answers` you give per step and webhooks with the `outcome` you give per step; a step without an answer waits.
The response shows the path taken (`path`, `steps`, `log`), where the run stopped (`stoppedAt`), the order after the run (`orderAfter`) and any `warnings`. When the draft has publish errors, `checks` is included too.



## OpenAPI

````yaml /openapi/public/openapi-flow.json post /order-type/{id}/simulate
openapi: 3.0.0
info:
  title: API - Flow
  version: 3.0.0
  description: API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Flow
    description: >-
      Flow is the mobile field application workflow, setting it correctly is
      critical to the success of the field workers in doing their job
      efficiently. Flow attributes consist of IDs, pages, components,
      configurations, and time. The Flow will be used at Task, Automation, or
      Schedule.


      **To see the details of flow object, please follow [this
      link](#tag/flow_model)**
  - name: Automation
    description: >-
      Automation enables you to set up automation based on tasks' events and
      data source's events. It might help you automate creation of tasks, task
      assignment, task placement, task webhook, data source update, datasource
      creation, and data source webhook. Automation attributes consist of IDs,
      automation name, automation type, automation details, and rules.


      **To see the details of automation object, please follow [this
      link](#tag/automation_model)**
  - name: Order Type
    description: >-
      An order type is the blueprint for orders: the list of steps, which task
      type each step uses, and how an order moves from one step to the next.
      Order types are versioned: you edit a draft, validate or simulate it, then
      publish it. These endpoints are served under `/api/v4`.
paths:
  /order-type/{id}/simulate:
    servers:
      - url: https://apiweb.mile.app/api/v4
    post:
      tags:
        - Order Type
      summary: Simulate order type
      description: >-
        Runs a test order through the order type's steps without saving
        anything: no order, task or webhook is created. Requires permission
        `edit/orderType`.

        Uses the stored draft, or the unsaved `draft` you send. Tasks are
        completed with the `answers` you give per step and webhooks with the
        `outcome` you give per step; a step without an answer waits.

        The response shows the path taken (`path`, `steps`, `log`), where the
        run stopped (`stoppedAt`), the order after the run (`orderAfter`) and
        any `warnings`. When the draft has publish errors, `checks` is included
        too.
      operationId: simulateOrderType
      parameters:
        - name: id
          in: path
          required: true
          description: |-
            Unique identifier for the order type that generated by system.
            **Example**: `6710a2f4c1d2e3f4a5b6c7d8`
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OrderTypeSimulateRequest'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  data:
                    description: Result of the simulated run.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  data:
                    finished: true
                    finalStatus: completed
                    path:
                      passed:
                        - start
                        - pickup
                        - done
                      routes: []
                      edges:
                        - start:next:pickup
                        - pickup:next:done
                    steps:
                      - order: 1
                        stepId: start
                        state: done
                        ports:
                          - next
                        edges:
                          - id: pickup
                            from: start:next
                      - order: 3
                        stepId: pickup
                        state: waitingTask
                      - order: 6
                        stepId: pickup
                        state: done
                        ports:
                          - next
                        edges:
                          - id: done
                            from: pickup:next
                      - order: 8
                        stepId: done
                        state: done
                        ports: []
                        edges: []
                    stoppedAt: []
                    log:
                      - seq: 1
                        stepId: start
                        event: run.started
                        detail: {}
                      - seq: 3
                        stepId: pickup
                        event: task.created
                        detail:
                          taskIds:
                            - 6710b9e0a1b2c3d4e5f60718
                          row: 0
                          attempt: 1
                      - seq: 8
                        stepId: done
                        event: order.finished
                        detail: {}
                    orderAfter:
                      status: completed
                      values:
                        orderNo: EXP-0001
                        customerName: Rina
                        weight: 2.5
                    warnings: []
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Bad request - invalid parameters provided.
        '404':
          description: Data not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Data not found
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Internal server error, please contact support@mile.app.
      deprecated: false
      security:
        - bearerAuth: []
components:
  schemas:
    OrderTypeSimulateRequest:
      example:
        order:
          hubId: 64d9932e2beb9037735ff022
          values:
            orderNo: EXP-0001
            customerName: Rina
            weight: 2.5
        answers:
          pickup:
            receiverName: Rina
      type: object
      properties:
        draft:
          type: object
          description: >-
            Optional unsaved draft (`fields`, `statuses`, `configuration`,
            `orderSteps`). When omitted, the stored draft is used (never the
            published version).
          additionalProperties: true
        order:
          type: object
          description: >-
            The test order: `hubId` (optional, must be a hub of your
            organization), `values` (checked against the draft fields) and
            optional `externalRef` (max 200 characters).
          additionalProperties: true
        trigger:
          type: object
          description: >-
            For an `onTaskFinished` trigger: `answers`, the finished task's
            answers the run starts from.
          additionalProperties: true
        answers:
          type: object
          description: >-
            Answers per `createTask` step id, used to complete the simulated
            task. One object for every row, or `{ "rows": [ ... ] }` per row. A
            step with no answer waits.
          additionalProperties: true
        webhooks:
          type: object
          description: >-
            Outcome per `callWebhook` step id: `{ "outcome": "success" |
            "failed", "httpStatus"?, "response"? }`. A step with no outcome
            waits.
          additionalProperties: true
      required:
        - order
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````

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