---
title: "Batch create or update shifts"
method: POST
path: "/agent/schedule/v2/shifts:upsert"
tags: ["Schedule Agent"]
---

# Batch create or update shifts

`POST /agent/schedule/v2/shifts:upsert`

## Request

- Base URL: `https://your-subdomain.deputy.deputy.com/api`
- URL: `https://your-subdomain.deputy.deputy.com/api/agent/schedule/v2/shifts:upsert`
- Auth: API key in header `OAuth`

Creates or updates multiple shifts in a single request. Maximum 500 items per request. Each item is processed independently - partial failures are allowed. Use id=0 or omit id for creates, provide id for updates. Set async=true to process asynchronously and poll via /api/operations/v2/operations/{id}.

## Query parameters

- `async` boolean

## Request body

- ScheduleAgentUpsertShiftsRequestUpsertData
  - `items` ScheduleAgentUpsertShiftsRequestUpsertItem[]: Array of shifts to create or update. Maximum 500 items.
    - `id` integer: Shift ID for updates. Omit or use 0 for create operations.
    - `areaId` integer
    - `date` string
    - `start` string
    - `end` string
    - `employeeId` integer
    - `note` string
    - `isOpen` boolean
    - `isApprovalRequired` boolean
    - `breaks` ScheduleAgentUpsertShiftBreak[]
      - `start` string
      - `end` string
      - `type` 'UNKNOWN_BREAK_TYPE' | 'MEAL' | 'REST'
      - `typeLabel` string
    - `customFields` Tenantsharedv2modelCustomField[]
      - `id` string, int64
      - `booleanField` ModelBooleanField
        - `value` boolean
      - `stringField` ModelStringField
        - `value` string
      - `listField` ModelListField
        - `value` string
      - `multiListField` ModelMultiListField
        - `value` string[]
      - `fileField` ModelFileField
        - `value` integer
      - `employeeVisible` boolean
    - `children` UpsertShiftsRequestChildItem[]
      - `areaId` integer
      - `start` string
      - `end` string
    - `updateFields` string[]: REQUIRED for update operations (id > 0). Specifies which fields to modify; fields not listed retain their existing values. Omitting this field on an update returns a 400 validation error. Ignored for create operations (id = 0). Valid values: "areaId", "date", "start", "end", "employeeId", "note", "isOpen", "isApprovalRequired", "breaks", "customFields", "children", "breakDuration", "publish".
    - `breakDuration` integer: Meal break duration in minutes. Cannot be used together with breaks. 0 = clear/remove meal break, >0 = set meal break to N minutes.
    - `publish` boolean
  - `override` boolean: When true, bypasses soft validation warnings (untrained, on leave, unavailable). Hard validation errors (overlapping shifts, permission denied) are NOT overridable.

## Response `200`

A successful response.

- ScheduleAgentUpsertShiftsResponse: Response from upsert shifts. Synchronous and asynchronous modes.
  - `success` boolean
  - `data` UpsertShiftsResponseUpsertResult[]
    - `id` integer
    - `success` boolean
    - `errorCode` string
    - `errorMessage` string
    - `index` integer
    - `created` boolean
  - `metadata` ScheduleAgentUpsertShiftsResponseMetadata
    - `summary` MetadataSummary
      - `total` integer
      - `succeeded` integer
      - `failed` integer
      - `pending` integer
    - `operationId` string: Operation ID for async requests. Use /api/operations/v2/operations/{id} to poll for results. Empty for synchronous requests.

---

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