> ## 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.

# Calculate the salary lines for a pay period

> Runs the pro-rata calculation for one employee and pay period with no side effects, using the employee's salary history and working pattern exactly as a pay run does. Supply `year` and `period` to get the line item ids the pay run would receive. Supply `statutoryLines` to preview the salary adjustment and any top-up the employee's statutory leave policy produces for them; each result line carries its `kind`.



## OpenAPI

````yaml /api-reference/specs/salary.json post /employees/{employeeId}/calculate
openapi: 3.0.1
info:
  title: Salary Service
  description: >-
    Salary module API for FlowPayroll: organisation and employee
    calculation-method configuration, statutory leave policies, and a
    side-effect-free pro-rata calculation. Enums may gain values and objects may
    gain properties without a new version, so a client should ignore properties
    it does not know and treat an enum value it does not recognise as
    unsupported.
  version: v1
servers:
  - url: https://api.sandbox.flowpayroll.ai/v1/salary
security:
  - X-Auth-Token: []
    X-Org-Id: []
paths:
  /employees/{employeeId}/calculate:
    post:
      tags:
        - Salary lines
      summary: Calculate the salary lines for a pay period
      description: >-
        Runs the pro-rata calculation for one employee and pay period with no
        side effects, using the employee's salary history and working pattern
        exactly as a pay run does. Supply `year` and `period` to get the line
        item ids the pay run would receive. Supply `statutoryLines` to preview
        the salary adjustment and any top-up the employee's statutory leave
        policy produces for them; each result line carries its `kind`.
      operationId: CalculateSalary
      parameters:
        - name: employeeId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CalculateSalaryRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SalaryCalculationResponseResponseBody'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectResponseBody'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectResponseBody'
components:
  schemas:
    CalculateSalaryRequest:
      required:
        - frequency
        - payrollConfigId
        - periodEndDate
        - periodStartDate
      type: object
      properties:
        payrollConfigId:
          minLength: 1
          type: string
          description: The payroll configuration the pay period belongs to.
        periodStartDate:
          minLength: 1
          type: string
          description: First day of the pay period, YYYY-MM-DD.
        periodEndDate:
          minLength: 1
          type: string
          description: Last day of the pay period, YYYY-MM-DD.
        frequency:
          minLength: 1
          type: string
          description: >-
            Pay frequency: Weekly, Fortnightly, FourWeekly, Monthly, Quarterly,
            BiAnnually or Annual.
        year:
          type: integer
          description: >-
            Tax year of the pay run. Optional; with `period` it makes the
            returned line item ids match the ones the pay run receives.
          format: int32
          nullable: true
        period:
          type: integer
          description: Period number of the pay run. Optional; see `year`.
          format: int32
          nullable: true
        statutoryLines:
          type: array
          items:
            $ref: '#/components/schemas/CalculateStatutoryLineRequest'
          description: >-
            Statutory pay lines to treat as if they were on the payslip, so the
            salary adjustment and any top-up can be previewed. Optional.
          nullable: true
      additionalProperties: false
      description: >-
        Runs the salary calculation for one employee and one pay period without
        side effects.
    SalaryCalculationResponseResponseBody:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/MessageWithTokenResponse'
        content:
          $ref: '#/components/schemas/SalaryCalculationResponseContentResponse'
        validationIssues:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssue'
          nullable: true
      additionalProperties: false
    ObjectResponseBody:
      type: object
      properties:
        message:
          $ref: '#/components/schemas/MessageWithTokenResponse'
        content:
          $ref: '#/components/schemas/ObjectContentResponse'
        validationIssues:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssue'
          nullable: true
      additionalProperties: false
    CalculateStatutoryLineRequest:
      type: object
      properties:
        statutoryType:
          type: string
          description: The statutory type name, e.g. `StatutoryMaternityPay`.
          nullable: true
        units:
          type: number
          description: Days paid (qualifying days for sick pay, calendar days otherwise).
          format: double
        unitName:
          type: string
          description: '`Day` or `Fixed`.'
          nullable: true
        amount:
          type: number
          description: The line's amount.
          format: double
        id:
          type: string
          description: The line's id; seeds the adjustment and top-up ids. Optional here.
          nullable: true
        from:
          type: string
          description: First day the line pays for inside the period, YYYY-MM-DD.
          nullable: true
        to:
          type: string
          description: Last day the line pays for, YYYY-MM-DD.
          nullable: true
        leaveStart:
          type: string
          description: >-
            First day of the statutory payment, YYYY-MM-DD; top-up tiers count
            from it.
          nullable: true
        periodAmount:
          type: number
          description: >-
            Statutory pay for this period's days, when the line also covers
            earlier periods.
          format: double
          nullable: true
      additionalProperties: false
      description: >-
        A statutory pay line in the shape the statutory service posts it: its
        type, units and amount, and, when known, the days it pays for inside the
        period, the statutory payment's start date and the amount that pays for
        this period's days.
    MessageWithTokenResponse:
      type: object
      properties:
        text:
          type: string
        token:
          type: string
        tokenArguments:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssueArgument'
          nullable: true
      additionalProperties: false
    SalaryCalculationResponseContentResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/SalaryCalculationResponse'
        metadata:
          $ref: '#/components/schemas/ContentMetadataResponse'
      additionalProperties: false
    ValidationIssue:
      type: object
      properties:
        field:
          type: string
        reason:
          type: string
        reasonToken:
          type: string
        reasonTokenArguments:
          type: array
          items:
            $ref: '#/components/schemas/ValidationIssueArgument'
          nullable: true
      additionalProperties: false
    ObjectContentResponse:
      type: object
      properties:
        data:
          nullable: true
        metadata:
          $ref: '#/components/schemas/ContentMetadataResponse'
      additionalProperties: false
    ValidationIssueArgument:
      type: object
      properties:
        name:
          type: string
        value:
          nullable: true
      additionalProperties: false
    SalaryCalculationResponse:
      type: object
      properties:
        calculationMethod:
          enum:
            - CalendarDays
            - WorkingDays
          type: string
          description: The method the calculation used.
        source:
          enum:
            - Default
            - Organisation
            - Employee
          type: string
          description: >-
            Where that method came from: `Employee`, `Organisation` or
            `Default`.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/SalaryCalculationLine'
          description: >-
            The salary lines, then for each statutory payment its adjustments
            and top-up.
      additionalProperties: false
    ContentMetadataResponse:
      type: object
      properties:
        dateFormat:
          type: string
        dateTimeFormat:
          type: string
        paginationToken:
          type: string
          nullable: true
      additionalProperties: false
    SalaryCalculationLine:
      type: object
      properties:
        lineItemId:
          type: string
          description: >-
            The id the line would be posted under, derived from the employee,
            pay run, period and segment; null when the request carried no `year`
            and `period`.
          nullable: true
        description:
          type: string
          description: The line's description as it appears on the payslip.
        unitName:
          type: string
          description: >-
            What `units` counts: `Month`, `Week` or `Year` for a full period,
            `Day` for a part period or an adjustment, `Fixed` for a top-up.
        units:
          type: number
          description: How many of `unitName`.
          format: double
        payRate:
          type: number
          description: The rate per unit, to 4 decimal places.
          format: double
        amount:
          type: number
          description: >-
            The line's amount: units × payRate, rounded to the penny. Always
            positive; an adjustment is a deduction because of its pay element.
          format: double
        annualSalary:
          type: number
          description: The annual salary in force for the segment.
          format: double
        effectiveFrom:
          type: string
          description: The date that salary version took effect, YYYY-MM-DD.
        segmentStart:
          type: string
          description: >-
            First day the line pays for (or, for an adjustment, takes back),
            YYYY-MM-DD.
        segmentEnd:
          type: string
          description: Last day the line covers, YYYY-MM-DD.
        calculationMethod:
          enum:
            - CalendarDays
            - WorkingDays
          type: string
          description: How the days were counted.
        divisor:
          type: integer
          description: >-
            Qualifying days in the tax year containing the segment's first day,
            for a part period; null for a full period.
          format: int32
          nullable: true
        kind:
          enum:
            - Salary
            - StatutoryAbsenceAdjustment
            - StatutoryTopUp
          type: string
          description: >-
            `Salary`, `StatutoryAbsenceAdjustment` (the salary for days on
            statutory leave, taken back) or `StatutoryTopUp` (contractual pay on
            top of statutory pay).
        payElementId:
          type: string
          description: The pay element the line is posted against, e.g. `internal_salary`.
          nullable: true
        statutoryType:
          enum:
            - StatutorySickPay
            - StatutoryMaternityPay
            - StatutoryPaternityPay
            - StatutoryAdoptionPay
            - StatutorySharedParentalPay
            - StatutoryParentalBereavementPay
            - StatutoryNeoNatalCarePay
          type: string
          description: On an adjustment or top-up, the statutory payment it responds to.
          nullable: true
      additionalProperties: false
      description: One pay-run line the calculation would produce.
  securitySchemes:
    X-Auth-Token:
      type: apiKey
      description: FlowPayroll JWT (raw token, no Bearer prefix)
      name: X-Auth-Token
      in: header
    X-Org-Id:
      type: apiKey
      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).
      name: X-Org-Id
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.