---
title: "Upsert shifts"
method: POST
path: "/v1/shifts/upsert"
tags: ["Shifts"]
---

# Upsert shifts

`POST /v1/shifts/upsert`

## Request

- Base URL: `https://api.sandbox.usenash.com`
- URL: `https://api.sandbox.usenash.com/v1/shifts/upsert`
- Auth: none declared

Create or update multiple courier shifts in a single request. Existing shifts are matched by ID for updates; new shifts are created.

## Request body

- CreateShiftsInputSerializer: Input for creating multiple shifts.
  - `shifts` CreateShiftInputSerializer[], required
    - `id` string, nullable: The ID of the shift.
    - `name` string, required: The name of the shift.
    - `plannedStart` string, required: The planned start timestamp of the shift.
    - `plannedEnd` string, required: The planned end timestamp of the shift.
    - `plannedBreakDuration` integer, nullable: The planned break duration of the shift.
    - `shiftMetadata` object, nullable: The metadata of the shift.
    - `optimizationParams` OptimizationParams: Input for creating optimization params.
      - `serviceTimeRelativeEfficiency` number, nullable: The service time relative efficiency of the shift.
      - `plannedBreaks` BreakConfiguration[], nullable: The planned breaks of the shift. (in minutes)
        - `timeWindow` unknown[], nullable: The time window of the break. (in minutes)
          - unknown
        - `breakDuration` integer, required: The break duration of the break. (in minutes)
        - `maxWorkingTime` integer, nullable: The max working time of the break. (in minutes)
      - `breakConfig` BreakConfig
        - `anchor` 'shift_start', nullable
        - `preferOffRoute` boolean: Prefer breaks at the store when anchor is shift_start.
      - `departureDelay` integer, nullable: The departure delay. (in minutes)
      - `shiftEndServiceTimeMinutes` integer, nullable: Buffer between return to depot and shift end (e.g. refueling). (in minutes)
      - `vehicleConfig` VehicleConfig: Response for vehicle config.
        - `weight` integer, nullable: The weight of the vehicle.
        - `height` integer, nullable: The height of the vehicle.
        - `length` integer, nullable: The length of the vehicle.
        - `width` integer, nullable: The width of the vehicle.
        - `axlecount` integer, nullable: The number of axles on the vehicle.
        - `trailercount` integer, nullable: The number of trailers on the vehicle.
        - `weightunit` 'kg' | 'lbs', nullable: Unit for weight: 'kg' or 'lbs'. Defaults to 'kg'.
        - `lengthunit` 'meter' | 'in', nullable: Unit for length, width, and height: 'meter' or 'in'. Defaults to 'meter'.
        - `maxstops` integer, nullable: The max stops of the vehicle.
        - `maxdistance` integer, nullable: The max distance of the vehicle.
        - `maxduration` integer, nullable: The max duration of the vehicle.
        - `speedfactor` number, nullable: The speed factor of the vehicle.
        - `capabilities` string[], nullable: The capabilities of the vehicle.
        - `fixedcost` number, nullable: Fixed cost to assign this vehicle with tasks.
        - `costperunitdistance` number, nullable: Cost per unit distance for this vehicle.
        - `costperunittime` number, nullable: Cost per unit time for this vehicle.
        - `vehicleprofile` string, nullable: The vehicle profile type (car, truck, bicycle, flying_distance).
        - `minordersperroute` integer, nullable: Minimum number of orders per route.
        - `parkingtime` number, nullable: Parking time at order locations (in hours).
    - `status` string, nullable: The status of the shift.
    - `storeLocationId` string, nullable: The store location ID of the shift.
    - `externalStoreLocationId` string, nullable: The external store location ID of the shift.
    - `zoneIds` string[], nullable: The zone IDs of the shift.
    - `externalZoneIds` string[], nullable: The external zone IDs of the shift.

## Response `200`

OK

- ShiftResponse: Response for shift.
  - `id` string, required: The ID of the shift.
  - `name` string, required: The name of the shift.
  - `plannedStart` string, required: The planned start timestamp of the shift.
  - `plannedEnd` string, required: The planned end timestamp of the shift.
  - `plannedBreakDuration` integer, nullable: The planned break duration of the shift.
  - `shiftMetadata` object, nullable: The metadata of the shift.
  - `optimizationParams` OptimizationParams: Input for creating optimization params.
    - `serviceTimeRelativeEfficiency` number, nullable: The service time relative efficiency of the shift.
    - `plannedBreaks` BreakConfiguration[], nullable: The planned breaks of the shift. (in minutes)
      - `timeWindow` unknown[], nullable: The time window of the break. (in minutes)
        - unknown
      - `breakDuration` integer, required: The break duration of the break. (in minutes)
      - `maxWorkingTime` integer, nullable: The max working time of the break. (in minutes)
    - `breakConfig` BreakConfig
      - `anchor` 'shift_start', nullable
      - `preferOffRoute` boolean: Prefer breaks at the store when anchor is shift_start.
    - `departureDelay` integer, nullable: The departure delay. (in minutes)
    - `shiftEndServiceTimeMinutes` integer, nullable: Buffer between return to depot and shift end (e.g. refueling). (in minutes)
    - `vehicleConfig` VehicleConfig: Response for vehicle config.
      - `weight` integer, nullable: The weight of the vehicle.
      - `height` integer, nullable: The height of the vehicle.
      - `length` integer, nullable: The length of the vehicle.
      - `width` integer, nullable: The width of the vehicle.
      - `axlecount` integer, nullable: The number of axles on the vehicle.
      - `trailercount` integer, nullable: The number of trailers on the vehicle.
      - `weightunit` 'kg' | 'lbs', nullable: Unit for weight: 'kg' or 'lbs'. Defaults to 'kg'.
      - `lengthunit` 'meter' | 'in', nullable: Unit for length, width, and height: 'meter' or 'in'. Defaults to 'meter'.
      - `maxstops` integer, nullable: The max stops of the vehicle.
      - `maxdistance` integer, nullable: The max distance of the vehicle.
      - `maxduration` integer, nullable: The max duration of the vehicle.
      - `speedfactor` number, nullable: The speed factor of the vehicle.
      - `capabilities` string[], nullable: The capabilities of the vehicle.
      - `fixedcost` number, nullable: Fixed cost to assign this vehicle with tasks.
      - `costperunitdistance` number, nullable: Cost per unit distance for this vehicle.
      - `costperunittime` number, nullable: Cost per unit time for this vehicle.
      - `vehicleprofile` string, nullable: The vehicle profile type (car, truck, bicycle, flying_distance).
      - `minordersperroute` integer, nullable: Minimum number of orders per route.
      - `parkingtime` number, nullable: Parking time at order locations (in hours).
  - `status` string, required: The status of the shift.
  - `storeLocationId` string, nullable: The store location ID of the shift.
  - `externalStoreLocationId` string, nullable: The external store location ID of the shift.
  - `zoneIds` string[], nullable: The zone IDs of the shift.
  - `externalZoneIds` string[], nullable: The external zone IDs of the shift.
  - `courierId` string, nullable: The courier ID of the shift.
  - `vehicleId` string, nullable: The vehicle ID of the shift.
  - `createdAt` string, required: The creation timestamp of the shift.
  - `updatedAt` string, required: The update timestamp of the shift.

## Other responses

- `422`: Unprocessable Content

---

[API](https://skmtc.dev/nash/apis/nash-api.md) - [All operations](https://skmtc.dev/nash/apis/nash-api/llms.txt) - [OpenAPI document](https://skmtc.dev/nash/apis/nash-api/revisions/e3713837c5c9?raw)
