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

# Create routing schedule

> Creates a schedule that runs route optimization for a hub automatically at the times you set.

The hub and the vehicles are **not** sent here — both come from the Configuration Profile named by `configurationId`, which is read again on every run. Editing the profile therefore changes what the next run does, with no change to the schedule.

Requires the `add/routing-schedule` permission.



## OpenAPI

````yaml /openapi/public/openapi-routing.json post /routing/schedule
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.
  - 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)
paths:
  /routing/schedule:
    post:
      tags:
        - Routing Schedule
      summary: Create routing schedule
      description: >-
        Creates a schedule that runs route optimization for a hub automatically
        at the times you set.


        The hub and the vehicles are **not** sent here — both come from the
        Configuration Profile named by `configurationId`, which is read again on
        every run. Editing the profile therefore changes what the next run does,
        with no change to the schedule.


        Requires the `add/routing-schedule` permission.
      operationId: createRoutingSchedule
      requestBody:
        required: true
        description: >-
          `startTime` and `endTime` are required for every `periode` except
          `byDate`. `frequency` and `interval` are required when `periode` is
          `custom`.
        content:
          application/json:
            schema:
              type: object
              properties:
                configurationId:
                  type: string
                  description: >-
                    The Configuration Profile every run of this schedule uses.
                    The hub and the vehicles of the run are taken from this
                    profile, so neither is sent here. Editing the profile
                    changes the next run without editing the schedule.

                    **Example:** `65c3a1b2c3d4e5f600000009`
                name:
                  type: string
                  description: >-
                    Name of the schedule. It is also the prefix of the name
                    given to every routing result the schedule produces.

                    **Example:** `Morning Routing Jakarta`
                autoDispatch:
                  type: boolean
                  default: false
                  description: >-
                    When `true`, every vehicle on the optimized result is
                    dispatched to its field user as soon as the optimization
                    finishes. When `false`, the result waits in Routing → Result
                    for a manual dispatch.
                periode:
                  type: string
                  description: How often the schedule repeats. **Example:** `daily`
                  enum:
                    - daily
                    - weekly
                    - monthly
                    - byDate
                    - custom
                frequency:
                  type: string
                  description: >-
                    Unit the interval counts, required when `periode` is
                    `custom` and ignored otherwise. **Example:** `monthly`
                  enum:
                    - daily
                    - weekly
                    - monthly
                interval:
                  type: integer
                  minimum: 1
                  maximum: 99
                  description: >-
                    How many `frequency` units pass between two runs, required
                    when `periode` is `custom` and ignored otherwise. `2` with a
                    `monthly` frequency means every second month. **Example:**
                    `2`
                startTime:
                  type: string
                  description: >-
                    Start of the active window, in `Y-m-d H:i` format. The
                    schedule does not run before it. Not used when `periode` is
                    `byDate`, because those entries already carry absolute
                    dates.

                    **Example:** `2026-09-10 00:00`
                endTime:
                  type: string
                  description: >-
                    End of the active window, in `Y-m-d H:i` format. The
                    schedule stops running after it. Not used when `periode` is
                    `byDate`.

                    **Example:** `2026-12-31 23:59`
                schedules:
                  type: array
                  description: >-
                    Repetition entries for this schedule. Every entry carries at
                    least one `time` value in `H:i` format.
                  items:
                    type: object
                    description: >-
                      One repetition entry. Which keys are used depends on
                      `periode`:

                      - `daily` — `time` only. **Example:** `{ "time": ["08:00",
                      "15:00"] }`

                      - `weekly` — `day` + `time`. `day` is an English weekday
                      name, `sunday` through `saturday`. **Example:** `{ "day":
                      "monday", "time": ["08:00"] }`

                      - `monthly` — `date` + `time`. `date` is the day of the
                      month as two digits, leading zero included. **Example:**
                      `{ "date": "01", "time": ["08:00"] }`

                      - `byDate` — `date` + `time`. `date` is an absolute date
                      in `Y-m-d` format. **Example:** `{ "date": "2026-09-15",
                      "time": ["08:00"] }`

                      - `custom` — follows the entry shape of the `frequency` it
                      repeats on.
                    properties:
                      time:
                        type: array
                        description: >-
                          One or more times of day, in `H:i` format, at which
                          the schedule runs. **Example:** `["08:00", "15:00"]`
                        items:
                          type: string
                      day:
                        type: string
                        description: >-
                          Weekday name in English, used when `periode` is
                          `weekly`. **Example:** `monday`
                        enum:
                          - sunday
                          - monday
                          - tuesday
                          - wednesday
                          - thursday
                          - friday
                          - saturday
                      date:
                        type: string
                        description: >-
                          Day of the month as two digits when `periode` is
                          `monthly` (**Example:** `01`), or an absolute `Y-m-d`
                          date when `periode` is `byDate` (**Example:**
                          `2026-09-15`)
              required:
                - configurationId
                - name
                - periode
                - schedules
              example:
                configurationId: 65c3a1b2c3d4e5f600000009
                name: Morning Routing Jakarta
                autoDispatch: true
                periode: daily
                startTime: 2026-09-10 00:00
                endTime: 2026-12-31 23:59
                schedules:
                  - time:
                      - '08:00'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    description: Message of API response.
                    type: string
                  data:
                    type: object
                    description: The routing schedule document.
                example:
                  status: true
                  message: Routing schedule created.
                  data:
                    _id: 66f0a1b2c3d4e5f600000001
                    organizationId: 65a1b2c3d4e5f60000000001
                    hubId: 65b2c3d4e5f6000000000002
                    configurationId: 65c3a1b2c3d4e5f600000009
                    name: Morning Routing Jakarta
                    autoDispatch: true
                    periode: daily
                    frequency: null
                    interval: null
                    startTime: 2026-09-10 00:00
                    endTime: 2026-12-31 23:59
                    schedules:
                      - time:
                          - '08:00'
                    timeSchedules:
                      - '08:00'
                    isDeleted: false
                    createdBy: ops@acme.com
                    createdTime: '2026-09-09T10:00:00+00:00'
                    updatedTime: '2026-09-09T10:00:00+00:00'
        '400':
          description: Configuration profile 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.
                  failedCode:
                    type: string
                    description: Internal error code, useful when contacting support.
                example:
                  status: false
                  message: Configuration not found
                  failedCode: sched-033
        '403':
          description: Forbidden
          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.
                  failedCode:
                    type: string
                    description: Internal error code, useful when contacting support.
                example:
                  status: false
                  message: >-
                    Access denied. You do not have permission for add routing
                    schedule. Please contact your admin to request access.
                  failedCode: sys-035
        '422':
          description: Validation 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.
                  errors:
                    type: object
                    description: Validation messages, keyed by field name.
                  failedCode:
                    type: string
                    description: Internal error code, useful when contacting support.
                example:
                  status: false
                  message: The configuration id field is required.
                  errors:
                    configurationId:
                      - The configuration id field is required.
                    name:
                      - The name field is required.
                    periode:
                      - The periode field is required.
                  failedCode: sched-001
        '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:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````