> ## 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.

# Update order type

> Saves the full draft of an order type. Requires permission `edit/orderType`.
Send the whole editable document with the `draftRevision` you read; the response returns the new `draftRevision`. Saving never publishes.
A draft whose structure is valid is stored even if it still has problems; those come back in `checks` (each with `code`, `severity` `error` or `warning`, and the step it concerns). Refused with 409 when the revision is stale, the name or code is taken, or the code changes while orders exist.



## OpenAPI

````yaml /openapi/public/openapi-flow.json put /order-type/{id}
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}:
    servers:
      - url: https://apiweb.mile.app/api/v4
    put:
      tags:
        - Order Type
      summary: Update order type
      description: >-
        Saves the full draft of an order type. Requires permission
        `edit/orderType`.

        Send the whole editable document with the `draftRevision` you read; the
        response returns the new `draftRevision`. Saving never publishes.

        A draft whose structure is valid is stored even if it still has
        problems; those come back in `checks` (each with `code`, `severity`
        `error` or `warning`, and the step it concerns). Refused with 409 when
        the revision is stale, the name or code is taken, or the code changes
        while orders exist.
      operationId: updateOrderType
      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/OrderTypeUpdateRequest'
        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: New revision and the check report.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Order Type saved
                  data:
                    _id: 6710a2f4c1d2e3f4a5b6c7d8
                    draftRevision: 5
                    hasUnpublishedChanges: true
                    checks: []
        '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
        '409':
          description: Conflict
          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.
        '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:
    OrderTypeUpdateRequest:
      example:
        name: Express Delivery
        code: EXP
        description: Same-day parcel delivery
        draftRevision: 4
        fields:
          - id: orderNo
            title: Order number
            type: string
            required: true
            unique: true
            show: true
          - id: customerName
            title: Customer name
            type: string
            required: false
            show: true
          - id: weight
            title: Weight (kg)
            type: number
            required: false
            show: true
            min: 0
        statuses:
          - id: new
            label: New
            category: new
            order: 1
            color: '#6C757D'
          - id: onDelivery
            label: On delivery
            category: inProgress
            order: 2
          - id: completed
            label: Completed
            category: completed
            order: 3
          - id: cancelled
            label: Cancelled
            category: completed
            order: 4
        configuration:
          uniqueBy:
            - orderNo
          cancelStatusId: cancelled
        orderSteps:
          - id: start
            type: string
            title: Order created
            position:
              x: 0
              'y': 0
            event: onOrderCreated
            next:
              next:
                - pickup
          - id: pickup
            type: string
            title: Pickup
            position:
              x: 240
              'y': 0
            taskTypeId: 66f1b2c3d4e5f6a7b8c9d0e1
            assignee:
              mode: unassigned
            hub:
              mode: order
            quantity:
              mode: perOrder
            taskData:
              - target: title
                source:
                  ref: $order.values.orderNo
            saveToOrder: []
            next:
              next:
                - done
          - id: done
            type: string
            title: Finish
            position:
              x: 480
              'y': 0
            statusId: completed
        canvas:
          viewport:
            x: 0
            'y': 0
            zoom: 1
      type: object
      properties:
        name:
          type: string
          description: >-
            Name of the order type, unique in the organization. Max 100
            characters.

            **Example**: `Express Delivery`
        code:
          type: string
          description: >-
            Short code, 1-10 uppercase letters or digits, unique in the
            organization. Cannot change once the order type has orders.

            **Example**: `EXP`
        description:
          type: string
        draftRevision:
          type: integer
          description: >-
            The `draftRevision` you last read. A stale value is refused with
            409.

            **Example**: `3`
        fields:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            List of order fields. The **first field is the order number**: it
            must be type `text` or `number`, and it is always required and
            unique within the order type.

            Each field: `id` (letters, digits, `_`, `-`), `title`, `type`, and
            optional `description`, `required`, `show`, `unique`, `default`,
            `archived`.

            `type` is one of `text`, `number`, `option`, `date`, `dateTime`,
            `time`, `phoneNumber`, `geolocation`, `reference`, `lineItems`,
            `user`, `boolean`. Type-specific keys: `maxLength` (text,
            phoneNumber), `min`/`max` (number, date, dateTime, time), `options`
            (option, list of unique strings), `reference` (reference), `columns`
            (lineItems).
        statuses:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            List of order statuses. Each status: `id`, `label`, `category`,
            `order` (integer), and optional `color`, `publicLabel`, `viewAccess`
            (`{ "roles": [roleId] }`, empty means every role).

            `category` is one of `new`, `inProgress`, `completed`. Exactly one
            status must be `new` and at least one must be `completed` before the
            order type can be published.
        configuration:
          type: object
          description: >-
            Order type configuration: `cancelStatusId` (a status of category
            `completed` used by **Cancel order**; null when cancelling is not
            allowed) and `uniqueBy` (derived from the first field on save).
          additionalProperties: true
        orderSteps:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            The order steps graph, at most 200 steps. Every step has `id`
            (lowercase letters, digits and `-`, max 40 characters), `type`,
            `title` (max 80 characters), `position` (`{ x, y }`) and `next`
            (port name to list of step ids; not used on `finishOrder`).

            Step `type`:

            - `trigger`: `event` is `onOrderCreated` or `onTaskFinished`. For
            `onTaskFinished` also `taskTypeId` (the task type, flowId, whose
            finished tasks create orders), `onlyIf`, `quantity` (`mode`
            `perTask` or `perRow`) and `mapping`.

            - `createTask`: `taskTypeId` (task type, flowId), `assignee` (`mode`
            `unassigned`, `user` or `field`), `hub` (`mode` `order` or `fixed`),
            `quantity` (`mode` `perOrder` or `perRow`), `taskData`,
            `saveToOrder`, `retry` (`maxAttempts` 1-10).

            - `condition`: `rules` (max 20 rules, max 20 conditions each;
            operators `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains`,
            `isEmpty`). Each rule is a port `rule:`.

            - `updateOrder`: `set` (mapping rows) and `status` (`mode` `fixed`
            or `map`).

            - `finishOrder`: `statusId`.

            - `callWebhook`: `request` (`url`, `method` `POST` or `PUT`,
            `headers`, `timeoutSec` 1-30, `body` with `mode` `order` or
            `template`) and `saveResponse`. Ports `success` and `failed`. Secret
            header values are never returned (`value: null`, `hasValue: true`).

            Mapping rows (max 50) are `{ target, source }`; a source is `{
            "value": ... }` or `{ "ref": "$..." }`.
        canvas:
          type: object
          description: >-
            Optional editor layout: `viewport` (`{ x, y, zoom }`) and
            `listOrder` (list of step ids).
          additionalProperties: true
      required:
        - name
        - code
        - draftRevision
        - fields
        - statuses
        - configuration
        - orderSteps
  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.