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

# initiatePayroll

> Starts payroll calculation and processing for a specific pay period.

### Pre-Execution Checklist
✅ All payroll data successfully imported, including hours, deductions, additional compensations etc.

✅ Bank account verified.

✅ The funding source has the required funds.

✅ All employee information (addresses, tax details) up to date.

### Process Flow:
1. **Validation:** Checks all requirements
2. **Recalculation:** Computes wages, taxes, deductions to ensure up to date numbers before payroll runs
3. **Processing:** Executes payments, payroll is `inProcess`
4. **Confirmation:** Sends notifications

### Notes:
- If payroll is initated before the `deadlineToRunPayroll` the payPeriod becomes `submitted` and will automatically process on the deadline.
- If `runNow: true` is included in the request, or the date is past the `deadlineToRunPayroll` the payroll processes immediately, skipping the `submitted` status, and the payDate is brought forward. 
- If the company bank account is linked with plaid (includes balance checks) and does not have the required funds to cover payroll, the submission will be unsuccessful.
- For more information regarding the payroll process please refer to the [Payroll Processing](https://developer.rollfi.xyz/docs/PayrollProcessing) guide.



## OpenAPI

````yaml post /payroll/initiatePayroll
openapi: 3.0.1
info:
  title: Default module
  description: ''
  version: 1.0.0
servers: []
security:
  - basic: []
tags: []
paths:
  /payroll/initiatePayroll:
    post:
      tags: []
      summary: initiatePayroll
      description: >-
        Starts payroll calculation and processing for a specific pay period.


        ### Pre-Execution Checklist

        ✅ All payroll data successfully imported, including hours, deductions,
        additional compensations etc.


        ✅ Bank account verified.


        ✅ The funding source has the required funds.


        ✅ All employee information (addresses, tax details) up to date.


        ### Process Flow:

        1. **Validation:** Checks all requirements

        2. **Recalculation:** Computes wages, taxes, deductions to ensure up to
        date numbers before payroll runs

        3. **Processing:** Executes payments, payroll is `inProcess`

        4. **Confirmation:** Sends notifications


        ### Notes:

        - If payroll is initated before the `deadlineToRunPayroll` the payPeriod
        becomes `submitted` and will automatically process on the deadline.

        - If `runNow: true` is included in the request, or the date is past the
        `deadlineToRunPayroll` the payroll processes immediately, skipping the
        `submitted` status, and the payDate is brought forward. 

        - If the company bank account is linked with plaid (includes balance
        checks) and does not have the required funds to cover payroll, the
        submission will be unsuccessful.

        - For more information regarding the payroll process please refer to the
        [Payroll
        Processing](https://developer.rollfi.xyz/docs/PayrollProcessing) guide.
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                method:
                  type: string
                companyId:
                  type: string
                  format: uuid
                payPeriodId:
                  type: string
                  format: uuid
                runNow:
                  type: boolean
              required:
                - method
                - companyId
                - payPeriodId
            example:
              method: initiatePayroll
              companyId: 8D728FCE-2993-42E0-8797-832C930506E1
              payPeriodId: F4C96CCA-24D4-4DF4-B624-1544989F7D21
              runNow: false
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  payPeriod:
                    type: object
                    properties:
                      payPeriodId:
                        type: string
                      status:
                        type: string
                      message:
                        type: string
                    required:
                      - payPeriodId
                      - status
                    x--orders:
                      - PayPeriodId
                      - Status
                      - Message
                required:
                  - payPeriod
                x--orders:
                  - PayPeriod
              examples:
                '1':
                  summary: Success
                  value:
                    payPeriod:
                      payPeriodId: 3b51b98b-2915-4854-b87c-f7952ef086ec
                      status: inProcess
                      message: The PayPeriod has been initiated successfully.
                '2':
                  summary: Exception
                  value:
                    error:
                      code: 400
                      message: payPeriodId is mandatory and cannot be empty.
          headers: {}
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: array
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                        message:
                          type: string
                      required:
                        - code
                required:
                  - error
          headers: {}
      deprecated: false
      security:
        - basic: []
components:
  securitySchemes:
    basic:
      type: http
      scheme: basic

````