---
title: "Create/Update tours."
method: POST
path: "/tour/upsert"
tags: ["Disposition|Tour"]
---

# Create/Update tours.

`POST /tour/upsert`

This method can be used to create and update tours. To modify or add stops within tours use the
`/tour/upsert_stop` endpoint.

An attempt is made to find an existing tour based on the selected primary key.
If one is found, it will be adjusted. Otherwise, a new tour is created.

## Request body

- StandardDispoTourUpsertRequest
  - `records` object[] — The records.
    - `keyField` string — This parameter specifies the name of the unique key used to distinctly assign each dataset in the API. | Value | Description | |----------------|-----------------------------| | id | The internal tour ID | | reference | The reference |
    - `data` DispoTourUpsertRequestRecordData
      - `id` integer — The internal id of the tour.
      - `reference` integer — The internal reference of the tour.
      - `startDate` string — Represents a date. (ISO 8601) ICU-Format: yyyy-MM-dd
      - `team` integer — The id of the team.
      - `teamExternalReference` string — The external reference for the team (Used if team not provided).
      - `district` integer — The id of the district.
      - `districtReference` string — The reference of the district (Used if district not provided).
      - `status` string — The status of the tour.
      - `orders` integer[] — The order ids to be added to the tour.
      - `orderExternalReferences` string[] — The order references to be added to the tour (Used if orders not provided).
  - `deleteMissing` boolean — Do you want to delete all tours missing from this request?
  - `dryRun` boolean — Simulate the operation. (No records will be created or changed) This Parameter is optional.

## Response `200`

Success Response:

- StandardDispoTourUpsertResponse
  - `createdTours` object[] — The created tours.
    - `id` integer — The internal id of the tour.
    - `startDate` string — Represents a date. (ISO 8601) ICU-Format: yyyy-MM-dd
    - `team` string — The name of the team.
    - `teamId` integer — The internal id of the team.
    - `district` string — The name of the district.
    - `districtId` integer — The internal id of the district.
    - `numStops` integer — The amount of stops of the tour.
    - `numOrders` integer — The amount of orders of the tour.
    - `duration` integer — The total duration of the tour.
    - `distance` integer — The total distance of the tour.
    - `status` string — The status of the tour.
    - `reference` integer — The reference of the tour.
    - `dispoType` string — The name of the dispo type.
    - `dispoTypeId` integer — The internal id of the dispoType.
    - `stops` object[] — The stops of the tour.
      - `id` integer — The internal id of the stop.
      - `sequence` integer — The sequence of the stop.
      - `type` string — The stop type. | Value | Description | |--------------------------|--------------------------------------| | HOME | Home Stop used to identify the start and end of the tour | | ORDER | Use this type for a normal stop with orders | | SUB | Used for sub stops | | TBREAK | Break Stop | | HOTEL | Used for overnight stays | | FUEL | Used for fueling | | LOAD | Used for pickup and delivery orders. | | UNLOAD | Used for pickup and delivery orders. |
      - `name` string — The name address addition.
      - `name2` string — The name2 address addition.
      - `name3` string — The name3 address addition.
      - `street` string — The street.
      - `zipCode` string — The zip code.
      - `city` string — The city.
      - `countryCode` string — The two-digit ISO 3166 country code.
      - `provinceCode` string — The province code.
      - `latLng` number[] — Represents a geo coordinate. An array of two double values, representing the latitude and longitude.
      - `contactPersonName` string — The contact person name.
      - `contactPersonEmail` string — The contact person e-mail.
      - `contactPersonPhoneNumber` string — The contact person phone number.
      - `contactPersonMobileNumber` string — The contact person mobile number.
      - `noteDriver` string — A note for the driver. This info is shown to the driver in his app.
      - `notePlanner` string — A note for the planner.
      - `estimatedDrivingDuration` integer — The estimated driving duration in seconds between the previos and this stop.
      - `estimatedDrivingDistance` integer — The estimated driving distance in meters between the previos and this stop.
      - `estimatedTollCosts` number — The estimated toll costs between the previos and this stop.
      - `eta` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `etd` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `ata` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `atd` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `etc` integer — The estimated time in seconds to completion of the stop.
      - `totalSubEtc` integer — The estimated time in seconds to completion of all sub stops.
      - `atc` integer — The actual time in seconds to completion of the stop.
      - `orders` object[] — The orders of the stop.
        - `id` integer — The internal id of the order.
        - `reference` string — The customer order number.
        - `externalReference` string — The internal reference for the order.
        - `subject` string — The order subject.
        - `createdAt` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
        - `project` integer — The id of the project.
        - `projectReferenceSign` string — The reference sign of the project.
      - `subStops` object[] — The sub stops of the stop.
        - `id` integer — The internal id of the sub stop.
        - `tourId` integer — The internal id of the tour from the sub stop.
        - `etc` integer — The estimated time in seconds to completion of the sub stop.
      - `masterStopId` integer — The internal id of the master stop.
      - `masterTourId` integer — The internal id of the tour from the master stop.
      - `masterEtc` integer — The internal id of the tour from the master stop.
    - `startTime` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
    - `endTime` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
  - `updatedTours` object[] — The changed tours.
    - `id` integer — The internal id of the tour.
    - `startDate` string — Represents a date. (ISO 8601) ICU-Format: yyyy-MM-dd
    - `team` string — The name of the team.
    - `teamId` integer — The internal id of the team.
    - `district` string — The name of the district.
    - `districtId` integer — The internal id of the district.
    - `numStops` integer — The amount of stops of the tour.
    - `numOrders` integer — The amount of orders of the tour.
    - `duration` integer — The total duration of the tour.
    - `distance` integer — The total distance of the tour.
    - `status` string — The status of the tour.
    - `reference` integer — The reference of the tour.
    - `dispoType` string — The name of the dispo type.
    - `dispoTypeId` integer — The internal id of the dispoType.
    - `stops` object[] — The stops of the tour.
      - `id` integer — The internal id of the stop.
      - `sequence` integer — The sequence of the stop.
      - `type` string — The stop type. | Value | Description | |--------------------------|--------------------------------------| | HOME | Home Stop used to identify the start and end of the tour | | ORDER | Use this type for a normal stop with orders | | SUB | Used for sub stops | | TBREAK | Break Stop | | HOTEL | Used for overnight stays | | FUEL | Used for fueling | | LOAD | Used for pickup and delivery orders. | | UNLOAD | Used for pickup and delivery orders. |
      - `name` string — The name address addition.
      - `name2` string — The name2 address addition.
      - `name3` string — The name3 address addition.
      - `street` string — The street.
      - `zipCode` string — The zip code.
      - `city` string — The city.
      - `countryCode` string — The two-digit ISO 3166 country code.
      - `provinceCode` string — The province code.
      - `latLng` number[] — Represents a geo coordinate. An array of two double values, representing the latitude and longitude.
      - `contactPersonName` string — The contact person name.
      - `contactPersonEmail` string — The contact person e-mail.
      - `contactPersonPhoneNumber` string — The contact person phone number.
      - `contactPersonMobileNumber` string — The contact person mobile number.
      - `noteDriver` string — A note for the driver. This info is shown to the driver in his app.
      - `notePlanner` string — A note for the planner.
      - `estimatedDrivingDuration` integer — The estimated driving duration in seconds between the previos and this stop.
      - `estimatedDrivingDistance` integer — The estimated driving distance in meters between the previos and this stop.
      - `estimatedTollCosts` number — The estimated toll costs between the previos and this stop.
      - `eta` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `etd` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `ata` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `atd` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `etc` integer — The estimated time in seconds to completion of the stop.
      - `totalSubEtc` integer — The estimated time in seconds to completion of all sub stops.
      - `atc` integer — The actual time in seconds to completion of the stop.
      - `orders` object[] — The orders of the stop.
        - `id` integer — The internal id of the order.
        - `reference` string — The customer order number.
        - `externalReference` string — The internal reference for the order.
        - `subject` string — The order subject.
        - `createdAt` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
        - `project` integer — The id of the project.
        - `projectReferenceSign` string — The reference sign of the project.
      - `subStops` object[] — The sub stops of the stop.
        - `id` integer — The internal id of the sub stop.
        - `tourId` integer — The internal id of the tour from the sub stop.
        - `etc` integer — The estimated time in seconds to completion of the sub stop.
      - `masterStopId` integer — The internal id of the master stop.
      - `masterTourId` integer — The internal id of the tour from the master stop.
      - `masterEtc` integer — The internal id of the tour from the master stop.
    - `startTime` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
    - `endTime` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
  - `deletedTours` object[] — The deleted tours.
    - `id` integer — The internal id of the tour.
    - `startDate` string — Represents a date. (ISO 8601) ICU-Format: yyyy-MM-dd
    - `team` string — The name of the team.
    - `teamId` integer — The internal id of the team.
    - `district` string — The name of the district.
    - `districtId` integer — The internal id of the district.
    - `numStops` integer — The amount of stops of the tour.
    - `numOrders` integer — The amount of orders of the tour.
    - `duration` integer — The total duration of the tour.
    - `distance` integer — The total distance of the tour.
    - `status` string — The status of the tour.
    - `reference` integer — The reference of the tour.
    - `dispoType` string — The name of the dispo type.
    - `dispoTypeId` integer — The internal id of the dispoType.
    - `stops` object[] — The stops of the tour.
      - `id` integer — The internal id of the stop.
      - `sequence` integer — The sequence of the stop.
      - `type` string — The stop type. | Value | Description | |--------------------------|--------------------------------------| | HOME | Home Stop used to identify the start and end of the tour | | ORDER | Use this type for a normal stop with orders | | SUB | Used for sub stops | | TBREAK | Break Stop | | HOTEL | Used for overnight stays | | FUEL | Used for fueling | | LOAD | Used for pickup and delivery orders. | | UNLOAD | Used for pickup and delivery orders. |
      - `name` string — The name address addition.
      - `name2` string — The name2 address addition.
      - `name3` string — The name3 address addition.
      - `street` string — The street.
      - `zipCode` string — The zip code.
      - `city` string — The city.
      - `countryCode` string — The two-digit ISO 3166 country code.
      - `provinceCode` string — The province code.
      - `latLng` number[] — Represents a geo coordinate. An array of two double values, representing the latitude and longitude.
      - `contactPersonName` string — The contact person name.
      - `contactPersonEmail` string — The contact person e-mail.
      - `contactPersonPhoneNumber` string — The contact person phone number.
      - `contactPersonMobileNumber` string — The contact person mobile number.
      - `noteDriver` string — A note for the driver. This info is shown to the driver in his app.
      - `notePlanner` string — A note for the planner.
      - `estimatedDrivingDuration` integer — The estimated driving duration in seconds between the previos and this stop.
      - `estimatedDrivingDistance` integer — The estimated driving distance in meters between the previos and this stop.
      - `estimatedTollCosts` number — The estimated toll costs between the previos and this stop.
      - `eta` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `etd` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `ata` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `atd` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
      - `etc` integer — The estimated time in seconds to completion of the stop.
      - `totalSubEtc` integer — The estimated time in seconds to completion of all sub stops.
      - `atc` integer — The actual time in seconds to completion of the stop.
      - `orders` object[] — The orders of the stop.
        - `id` integer — The internal id of the order.
        - `reference` string — The customer order number.
        - `externalReference` string — The internal reference for the order.
        - `subject` string — The order subject.
        - `createdAt` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
        - `project` integer — The id of the project.
        - `projectReferenceSign` string — The reference sign of the project.
      - `subStops` object[] — The sub stops of the stop.
        - `id` integer — The internal id of the sub stop.
        - `tourId` integer — The internal id of the tour from the sub stop.
        - `etc` integer — The estimated time in seconds to completion of the sub stop.
      - `masterStopId` integer — The internal id of the master stop.
      - `masterTourId` integer — The internal id of the tour from the master stop.
      - `masterEtc` integer — The internal id of the tour from the master stop.
    - `startTime` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx
    - `endTime` string — Represents a date and a time. (ISO 8601) ICU-Format: yyyy-MM-dd'T'HH:mm:ssxxx

---

[API](https://skmtc.net/geocapture/apis/geocapture-api.md) · [All operations](https://skmtc.net/geocapture/apis/geocapture-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/geocapture/geocapture-api/versions/15839b24c497/schema)
