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

# Create routing configuration

> Creates a routing configuration profile for a hub. The name must be unique within the hub. A new profile is never the default; use `PATCH /configurations/hub/{hubId}` to make it default.
When `autoSpeed` is `false`, `defaultSpeed` is required and must be at least 5 (km/h).
Requires the `add/configuration` permission.



## OpenAPI

````yaml /openapi/public/openapi-routing.json post /configuration
openapi: 3.0.0
info:
  title: API - Routing
  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: Vehicle
    description: >-
      The vehicle represents a car, bike, truck, or other form of transportation
      used in your organization. They are utilized to optimize the route
      planning process, determining the most efficient path for completing
      multiple tasks or visits. The vehicle attributes contain IDs, capacity,
      speed, working hours, tags, and constraints.


      **To see the details of vehicle object, please follow [this
      link](#tag/vehicle_model)**
  - name: Routing
    description: >-
      The **Routing** refers to process of finding the most effective routes for
      vehicles to travel from one visit to another. The optimization process
      will generate a result that could update the respective task data when
      dispatched. With the ability to handle complex constraints and variables
      such as capacity, time windows, and vehicle availability, the API can be
      customized to meet the specific needs of any business or organization.


      **This section is for the v2 of routing api, if you still use the old one,
      please follow [this link](/v1) to see documentation**.


      **Routing results** are collection of route optimization's results that
      already successfully processed and saved in the database. Routing results
      contains list of routed visits and dropped visits.


      1. Routed visits are sequence recommendation of visits/tasks list
      according to most suitable vehicle and best route.

      2. Dropped visits are list of tasks/visits that out of range of the
      calculation.


      **To see the details of routing object, please follow [this
      link](#tag/route_model)**


      ## Why use Route Optimization


      With Route Optimization API, you can establish or refine an automated
      dispatch or route planning process that improves the operational
      efficiency of your transportation needs. With parameters to express your
      unique operational objectives and constraints, and an algorithm built on
      top of the trusted Google Maps data, the service generates the best
      possible route plans to meet those constraints. Some use-case examples
      follow:


      - A **logistics company** uses Route Optimization to optimize the
      assignments of all next-day shipments, providing a route for each shipment
      that optimizes for distance and time efficiency, cost saving, on time
      delivery, and driver and end customer satisfaction.


      - A **field service provider** uses Route Optimization to find the optimal
      route and sequence for technician's service appointments, and re-optimize
      when condition changes occur, such as en route delays.


      - An **on demand food delivery** company uses Route Optimization in their
      real-time dispatch process to choose the best active driver to pick up
      several new orders and insert it in their existing routes.


      - A **medical service provider** uses Route Optimization to map health
      providers to appointments, improving the efficiency of the routes for each
      provider across their day.


      ## How Route Optimization works


      The Route Optimization API uses a number of inputs to return a route plan.
      Inputs include vehicles, visits or shipments, configurations, and
      constraints. A route plan includes tasks assignment to vehicles, the
      multi-stop routes for each vehicle, and the related metrics.
  - name: Routing Schedule
    description: >-
      A Routing Schedule runs route optimization automatically at the times you
      set, without anyone opening the app. Each schedule points at one
      Configuration Profile, which supplies the hub and the vehicles for every
      run. When Auto Dispatch is enabled, the optimized routes are dispatched to
      the field users as soon as the optimization finishes.


      **Related Guide:** [Routing
      Schedule](/pages/route-optimization/schedule/introduction)
  - name: Configuration
    description: >-
      Configuration endpoints for managing routing and optimization settings
      including time windows, constraints, and optimization parameters.
  - name: Capacity Constraint
    description: >-
      Capacity Constraint endpoints for managing vehicle capacity constraints in
      route optimization. Define weight, volume, and other capacity limits for
      vehicles.
  - name: Geotagging
    description: Geotagging endpoints for location tagging and geographic data management.
paths:
  /configuration:
    post:
      tags:
        - Configuration
      summary: Create routing configuration
      description: >-
        Creates a routing configuration profile for a hub. The name must be
        unique within the hub. A new profile is never the default; use `PATCH
        /configurations/hub/{hubId}` to make it default.

        When `autoSpeed` is `false`, `defaultSpeed` is required and must be at
        least 5 (km/h).

        Requires the `add/configuration` permission.
      operationId: createRoutingConfiguration
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RoutingConfigurationRequest'
        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:
                    type: object
                    description: Created configuration profile.
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  data:
                    _id: 6512a0b1c2d3e4f5a6b7c8d1
                    name: Default
                    hubId: 64d9932e2beb9037735ff022
                    organizationId: 64d99303be0ad015c461c932
                    isDefault: true
                    returnToHub: true
                    useAllVehicle: false
                    multitrip: false
                    clustering: normal
                    autoSpeed: false
                    defaultSpeed: 30
                    defaultVisitTime: 10
                    autoSplit: none
                    autoMerge: false
                    avoidToll: false
                    crossDockingType: none
                    subHubs: []
                    constraintId:
                      - 1694662020650253c84b5d2a9
                    dynamicVisitTime: []
                    isDeleted: false
                    createdTime: '2023-09-14T03:27:00.000000Z'
                    updatedTime: '2023-09-14T03:27:00.000000Z'
        '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.
      deprecated: false
      security:
        - bearerAuth: []
components:
  schemas:
    RoutingConfigurationRequest:
      type: object
      required:
        - name
        - hubId
        - useAllVehicle
        - multitrip
        - clustering
        - autoSpeed
        - defaultVisitTime
      properties:
        name:
          type: string
          description: |-
            Profile name, unique within the hub.
            **Example:** `Default`
        hubId:
          type: string
          description: |-
            Hub the profile belongs to.
            **Example:** `64d9932e2beb9037735ff022`
        returnToHub:
          type: boolean
          description: >-
            Vehicles end their route back at the hub. Required unless
            `returnToBase` is sent.
        returnToBase:
          type: boolean
          description: Vehicles end their route back at their own start location.
        useAllVehicle:
          type: boolean
          description: Use every vehicle, even when fewer would do.
        multitrip:
          type: boolean
          description: Allow a vehicle to make more than one trip in its working time.
        clustering:
          type: string
          enum:
            - non-overlap
            - balanced
            - normal
            - none
          description: |-
            How visits are grouped per vehicle.
            **Example:** `normal`
        autoSpeed:
          type: boolean
          description: Use road-network speeds. When `false`, `defaultSpeed` is required.
        defaultSpeed:
          type: integer
          description: |-
            Average speed in km/h when `autoSpeed` is `false`. At least 5.
            **Example:** `30`
        defaultVisitTime:
          type: integer
          description: |-
            Minutes spent at a visit that has no visit time.
            **Example:** `10`
        autoSplit:
          type: string
          enum:
            - none
            - equal
            - maximize
          description: >-
            Split a visit across vehicles when it is larger than one vehicle's
            capacity.
        autoMerge:
          type: boolean
          description: Merge visits at the same location.
        avoidToll:
          type: boolean
          description: Avoid toll roads.
        returnAfterWorkingTime:
          type: boolean
          description: Allow returning to the hub after the working time ends.
        crossDockingType:
          type: string
          enum:
            - none
            - all
            - drop
          description: |-
            Cross-docking through sub hubs.
            **Default:** `none`
        subHubs:
          type: array
          items:
            type: string
          description: >-
            Sub hub ids for cross-docking. Must be in the same country as the
            main hub.
        vehicleSubHubDistanceLimit:
          type: number
          description: >-
            Maximum distance in meters between a vehicle and a sub hub. At least
            1000.
        dynamicVisitTime:
          type: array
          description: Extra visit time per unit of a capacity type.
          items:
            type: object
            properties:
              constraintName:
                type: string
                description: Capacity type name.
              visitTime:
                type: integer
                description: Minutes, at least 0.
        useOddEven:
          type: boolean
          description: Respect odd-even plate restrictions.
        oddEvenTime:
          type: array
          description: Up to 2 restricted periods, `HH:mm`.
          items:
            type: object
            properties:
              startTime:
                type: string
                description: '**Example:** `06:00`'
              endTime:
                type: string
                description: '**Example:** `10:00`'
  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.