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

# Set leaver details for many employees in one call

> Marks each listed employee as a leaver in one request. The `defaults` block applies to every entry; any entry may override any field (`leavingDate`, `reason`, `issuedBy`) for that employee. Each successful entry fires its own per-employee leaver-update SNS event so downstream consumers (P45 module, payslip pipeline) need no awareness of bulk operations. The response always returns 200 with a structured envelope of succeeded and failed identifiers.




## OpenAPI

````yaml /api-reference/specs/pay-api.yaml put /employees/leaver/bulk
openapi: 3.0.3
info:
  title: FlowPayroll API
  description: >-
    API for payroll management, including payroll upload, lock, HMRC submission,
    employee management
  version: 0.1.0
servers:
  - url: https://api.sandbox.flowpayroll.ai/v1
security:
  - XAuthToken: []
    XOrgId: []
tags:
  - name: Employees
    description: >-
      Create, retrieve, update, and delete employee records, and look them up by
      NI number or payroll ID.
  - name: Starters & leavers
    description: Set and clear starter and leaver details, individually or in bulk.
  - name: Tax codes
    description: >-
      Manage employee tax codes and query the effective tax code and NI category
      on a given date.
  - name: NI & identifiers
    description: Manage NI categories, National Insurance numbers, and payroll IDs.
  - name: Student loans
    description: Start and end student and postgraduate loans.
  - name: Payroll setup
    description: Assign an employee's payroll config and set opening balances.
  - name: Payroll
  - name: Payroll lines
  - name: PayrollConfig
  - name: Pay Elements
  - name: Calculator
  - name: Payslip
  - name: RTI
  - name: YearEnd
  - name: Organisation
paths:
  /employees/leaver/bulk:
    put:
      tags:
        - Starters & leavers
      summary: Set leaver details for many employees in one call
      description: >
        Marks each listed employee as a leaver in one request. The `defaults`
        block applies to every entry; any entry may override any field
        (`leavingDate`, `reason`, `issuedBy`) for that employee. Each successful
        entry fires its own per-employee leaver-update SNS event so downstream
        consumers (P45 module, payslip pipeline) need no awareness of bulk
        operations. The response always returns 200 with a structured envelope
        of succeeded and failed identifiers.
      operationId: SetLeaverDetailsBulk
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BulkSetLeaverDetailsDto'
      responses:
        '200':
          description: Bulk set completed; inspect succeeded/failed
          content:
            application/json:
              schema:
                type: object
                allOf:
                  - $ref: '#/components/schemas/ResponseBody'
                  - properties:
                      content:
                        type: object
                        properties:
                          data:
                            $ref: '#/components/schemas/BulkSetLeaverDetailsResultDto'
        '400':
          description: >-
            Invalid request body, missing defaults.leavingDate, or empty entries
            list
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseBody'
        '500':
          description: An internal server error occurred
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseBody'
components:
  schemas:
    BulkSetLeaverDetailsDto:
      type: object
      required:
        - defaults
        - entries
      properties:
        defaults:
          $ref: '#/components/schemas/BulkSetLeaverDefaultsDto'
        entries:
          type: array
          items:
            $ref: '#/components/schemas/BulkSetLeaverEntryDto'
    ResponseBody:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/MessageWithTokenResponse'
        content:
          type: object
          properties:
            data:
              type: object
              nullable: true
            metadata:
              type: object
              nullable: true
              properties:
                dateFormat:
                  type: string
                  default: yyyy-MM-dd
                dateTimeFormat:
                  type: string
                  default: yyyy-MM-ddTHH:mm:ss.fffZ
                paginationToken:
                  type: string
                  nullable: true
        validationIssues:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssue'
        messageToken:
          type: string
    BulkSetLeaverDetailsResultDto:
      type: object
      required:
        - succeeded
        - failed
      properties:
        succeeded:
          type: array
          items:
            type: string
        failed:
          type: array
          items:
            $ref: '#/components/schemas/BulkLeaverFailureDto'
    BulkSetLeaverDefaultsDto:
      type: object
      required:
        - leavingDate
      properties:
        leavingDate:
          type: string
          format: date
          description: Default leaving date applied to every entry unless overridden.
          example: '2026-05-30'
        reason:
          type: string
          nullable: true
          description: Default reason applied to every entry unless overridden.
          example: Resignation
    BulkSetLeaverEntryDto:
      type: object
      required:
        - employeeId
      properties:
        employeeId:
          type: string
          example: emp_12345
        leavingDate:
          type: string
          format: date
          nullable: true
          description: Overrides the request `defaults.leavingDate` for this employee.
          example: '2026-06-15'
        reason:
          type: string
          nullable: true
          description: Overrides the request `defaults.reason` for this employee.
          example: Retirement
    MessageWithTokenResponse:
      type: object
      properties:
        text:
          type: string
        token:
          type: string
        tokenArguments:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssueArgument'
    ValidationIssue:
      type: object
      description: >
        Field validation item. `reasonToken` is a stable snake_case key for i18n
        or custom client messages; `reason` is the default English text from the
        API.
      properties:
        field:
          type: string
          description: Dot-path of the field (e.g. name.firstName, address.line1).
        reason:
          type: string
          description: Default human-readable message.
        reasonToken:
          type: string
          description: Machine-readable error identifier (snake_case).
        reasonTokenArguments:
          type: array
          nullable: true
          items:
            $ref: '#/components/schemas/ValidationIssueArgument'
    BulkLeaverFailureDto:
      type: object
      required:
        - employeeId
        - reason
      properties:
        employeeId:
          type: string
          example: emp_67890
        reason:
          type: string
          description: >-
            Stable snake_case token identifying the failure mode. Frontends can
            branch on this value.
          example: leaver_reported_to_hmrc
    ValidationIssueArgument:
      type: object
      properties:
        name:
          type: string
        value:
          type: string
  securitySchemes:
    XAuthToken:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: Access token obtained from OAuth2 client credentials flow
    XOrgId:
      type: apiKey
      in: header
      name: X-Org-Id
      description: >-
        Organisation to scope the request to. Required when the principal can
        access more than one organisation; optional for single-organisation
        principals (the authorizer resolves it automatically).

````