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

# Create vehicle



## OpenAPI

````yaml /openapi/public/openapi-routing.json post /vehicle
openapi: 3.0.0
info:
  title: MileApp API - Routing
  version: 3.0.0
  description: MileApp 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.
paths:
  /vehicle:
    post:
      tags:
        - Vehicle
      summary: Create vehicle
      operationId: CreateVehicle
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/POSTVehicleRequestCreate'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                title: NetworkCreateResponse
                properties:
                  status:
                    description: Status of response.
                    type: string
                  message:
                    description: Message of API response.
                    type: string
                  data:
                    description: Detail of object vehicle.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  data:
                    name: Mini Van 54
                    assignee: leandro@mile.app
                    speed: 30
                    fixedCost: 15
                    tags:
                      - Ganjil
                      - Depok
                      - B1124CC
                    workingTime:
                      startTime: '08:00'
                      endTime: '17:00'
                      multiday: 0
                    capacity:
                      width:
                        min: 10
                        max: 1000
                      height:
                        min: 10
                        max: 1000
                    organizationId: 621dd813eb3ebf16b94dbde3
                    hubId: 621dd813eb3ebf16b94d6969
                    updatedTime: '2022-07-13T03:16:40+00:00'
                    createdTime: '2022-07-13T03:16:40+00:00'
                    _id: 62ce3918d3f3e1681a3a54b2
        '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.
        '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:
    POSTVehicleRequestCreate:
      title: POSTVehicleRequestCreate
      example:
        name: Mini Van 54
        assignee: leandro@mile.app
        speed: 30
        fixedCost: 15
        tags:
          - Ganjil
          - Depok
          - B1124CC
        workingTime:
          startTime: '08:00'
          endTime: '17:00'
          multiday: 0
        breakTime:
          startTime: '11:00'
          endTime: '11:30'
        hubId: 621dd813eb3ebf16b94d6969
        capacity:
          width:
            min: 10
            max: 1000
          height:
            min: 10
            max: 1000
      type: object
      required:
        - name
        - assignee
        - workingTime
        - hubId
      properties:
        hubId:
          type: string
          description: >-
            The identifier for the hub that generated by system. Use [GET /hubs
            API](#Setting_Hub) to get the list of Hub IDs.

            **Example:** `621dd813eb3ebf16b94d6969`
        name:
          description: >-
            The name of the vehicle, which can be a number plate, vehicle brand,
            or any relevant identifier for the vehicle. This name is used to
            distinguish and label each vehicle in the route optimization
            results.

            **Example**: `Mini Van 54`
          type: string
        assignee:
          description: >-
            Worker's email that is assigned to the vehicle. Each vehicle can
            only be assigned to one worker, and this parameter helps to manage
            the vehicle assignments.

            **Example**: `leandro@mile.app`
          type: string
        workingTime:
          type: array
          description: >-
            Working hours of the vehicle, containing **startTime**, **endTime**,
            and **multiday**. The time is specified in the 24-hour format, and
            it defines the time span during which the vehicle is available for
            routing tasks. In this example, the multiday value is set to 1,
            indicating that the vehicle's working hours span two consecutive
            calendar days. The vehicle starts its shift at 9:00 AM and continues
            until 4:00 PM the next day. 

            **Example**:

            `{`

            `'startTime':'08:00',`

            `'endTime':'17:00',`

            `'multiday':0`

            `}`
          items:
            type: object
            required:
              - startTime
              - endTime
              - multiday
            properties:
              startTime:
                type: string
                description: |-
                  Time of departure of the vehicle from the hub.
                  **Example:** `08:00`
              endTime:
                type: string
                description: |-
                  Maximum working time of vehicle to operate.
                  **Example:** `17:00`
              multiday:
                type: integer
                minimum: 0
                description: >-
                  Additional working days accumulatedbased on the number of
                  days.

                  **Example**: `0`

                  Implementation of **multiday** is used to add **endTime**
                  value,

                  which means **endTime** = **endTime** + (24 hours *
                  **multiday**)
        breakTime:
          type: array
          description: >-
            Indicates that the data inside represents the break time for the
            vehicle. containing: **startTime**, and **endTime**.
          items:
            type: object
            required:
              - startTime
              - endTime
            properties:
              startTime:
                type: string
                description: |-
                  The starting time of the break.
                  **Example:** `08:00`
              endTime:
                type: string
                description: |-
                  The ending time of the break.
                  **Example:** `17:00`
        speed:
          type: string
          description: >-
            The average speed of the vehicle in kilometers per hour (km/h). Must
            not be less than 5 km/h.

            **Example**: `30`

            **Default**: `25`
        fixedCost:
          type: integer
          description: >-
            The Cost Factor value range is set from 0 to 100, with the default
            value being 0. A lower number signifies a higher priority for
            routing optimization purposes. 

            **Example:** `15`

            **Default:** `0`
        tags:
          type: array
          maxItems: 10
          items:
            type: string
          description: >-
            Tags used for route optimization purposes. Visits with matching tags
            will be assigned to vehicles with the same tags.

            **Example**: `['Ganjil','Depok','B1124CC']`
        capacity:
          type: array
          description: >-
            Capacity specifications for route optimization, which are dynamic
            based on user needs. Includes minimum and maximum values for weight
            and volume.

            **Example**:

            `{`

            `'weight':{'min':10,'max':1000},`

            `'volume':{'min':10,'max':1000}`

            `}`
          items:
            type: object
            properties:
              '{constraint-n}':
                type: array
                description: >-
                  Key of capacity constraints, each with a minimum and maximum
                  value. 

                  **Example**:  `{'min':10,'max':1000}`
                items:
                  type: object
                  required:
                    - min
                    - max
                  properties:
                    min:
                      type: integer
                      description: |-
                        Minimum value of capacity constraint. Less than .max
                        **Example:** `10`
                    max:
                      type: integer
                      description: |-
                        Maximum value of capacity constraint. Greater than .min
                        **Example:** `1000`
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````