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

# Generate Earnings

> Generates earnings (SALARY, DOUBLE_OVERTIME, TRIPLE_OVERTIME, SUNDAY_PREMIUM, VACATION_PREMIUM) from time entries and compensation data. This endpoint does NOT calculate taxes — it only returns the generated earnings and calculated daily wage for each employee. Useful for previewing earnings before running full payroll calculations.

Available earnings can be obtained from the [List Earnings](/api-reference/endpoint/mexico-payroll/get-earnings) endpoint.



## OpenAPI

````yaml POST /api/mexico-payroll/generate-earnings
openapi: 3.0.3
info:
  title: FluxPayroll API
  description: >-
    API for calculating gross-to-net payroll calculations across different
    countries. Currently supports Mexico with ISR, IMSS, INFONAVIT, and
    state-level payroll tax calculations.
  version: 2.0.0
  contact:
    name: FluxPayroll
    url: https://fluxpayroll.ai
servers:
  - url: https://api.staging.fluxpayroll.ai
    description: Staging
security:
  - apiKey: []
paths:
  /api/mexico-payroll/generate-earnings:
    post:
      tags:
        - Mexico Payroll
      summary: Generate earnings from time entries and compensation
      description: >-
        Generates earnings (SALARY, DOUBLE_OVERTIME, TRIPLE_OVERTIME,
        SUNDAY_PREMIUM, VACATION_PREMIUM) from time entries and compensation
        data. This endpoint does NOT calculate taxes — it only returns the
        generated earnings and calculated daily wage for each employee. Useful
        for previewing earnings before running full payroll calculations.


        Available earnings can be obtained from the [List
        Earnings](/api-reference/endpoint/mexico-payroll/get-earnings) endpoint.
      operationId: generateMexicoEarnings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateEarningsRequest'
            example:
              fillDefaultSchedule: true
              employees:
                - employeeId: emp-001
                  employeeStartDate: '2020-01-01'
                  compensation:
                    type: monthly
                    amount: 91200
                  workAddress:
                    state: BCN
              payrollConfig:
                startDate: '2026-01-01'
                endDate: '2026-01-31'
                period: MONTHLY
      responses:
        '200':
          description: Successfully generated earnings
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateEarningsResponse'
              example:
                results:
                  - employeeId: emp-001
                    dailyWage: 3000
                    earnings:
                      - earningCode: SALARY
                        amount: 91200
        '400':
          description: >-
            Invalid input data (e.g., time entries outside payroll period,
            invalid time format)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid or missing authentication token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error during generation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    GenerateEarningsRequest:
      type: object
      required:
        - employees
        - payrollConfig
      additionalProperties: false
      properties:
        employees:
          type: array
          items:
            $ref: '#/components/schemas/GenerateEarningsEmployeeInput'
          minItems: 1
          description: Array of employees with time entries and compensation
        payrollConfig:
          $ref: '#/components/schemas/PayrollConfig'
        fillDefaultSchedule:
          type: boolean
          default: false
          description: >-
            When true, auto-fills default time entries (standard work hours) for
            work days missing from employee timeEntries
    GenerateEarningsResponse:
      type: object
      required:
        - results
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/EmployeeEarningsOutput'
          description: Array of generated earnings per employee
    ErrorResponse:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Error code
          example: VALIDATION_ERROR
        message:
          type: string
          description: Human-readable error message
          example: Invalid input data provided
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                description: Field that caused the error
              message:
                type: string
                description: Specific error message for the field
    GenerateEarningsEmployeeInput:
      type: object
      required:
        - employeeId
        - employeeStartDate
        - compensation
        - timeEntries
        - workAddress
      additionalProperties: false
      properties:
        employeeId:
          type: string
          description: Unique employee identifier
          example: emp-001
        employeeStartDate:
          type: string
          format: date
          description: Employee hire date in ISO 8601 format
          example: '2020-01-01'
        compensation:
          $ref: '#/components/schemas/CompensationInput'
        timeEntries:
          type: array
          items:
            $ref: '#/components/schemas/TimeEntry'
          default: []
          description: Work shifts for the payroll period
        workAddress:
          $ref: '#/components/schemas/WorkAddress'
    PayrollConfig:
      type: object
      required:
        - startDate
        - endDate
        - period
      additionalProperties: false
      properties:
        startDate:
          type: string
          format: date
          description: Payroll period start date in ISO 8601 format
          example: '2025-09-01'
        endDate:
          type: string
          format: date
          description: Payroll period end date in ISO 8601 format
          example: '2025-09-30'
        period:
          type: string
          enum:
            - DAILY
            - WEEKLY
            - MONTHLY
            - QUARTERLY
            - SEMI_ANNUAL
            - ANNUAL
          description: Payroll frequency
          example: MONTHLY
    EmployeeEarningsOutput:
      type: object
      required:
        - employeeId
        - dailyWage
        - earnings
      properties:
        employeeId:
          type: string
          description: Employee identifier
          example: emp-001
        dailyWage:
          type: number
          description: Calculated daily wage in MXN
          example: 500
        earnings:
          type: array
          items:
            $ref: '#/components/schemas/EarningOutput'
          description: Generated earnings for the payroll period
    CompensationInput:
      type: object
      required:
        - type
        - amount
      additionalProperties: false
      properties:
        type:
          type: string
          enum:
            - daily
            - weekly
            - monthly
            - annual
          description: Compensation frequency type
          example: monthly
        amount:
          type: number
          minimum: 0
          description: Salary amount in MXN
          example: 15000
    TimeEntry:
      type: object
      required:
        - date
        - startTime
        - endTime
      additionalProperties: false
      properties:
        date:
          type: string
          format: date
          description: Work date in ISO 8601 format
          example: '2025-09-01'
        startTime:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          description: Shift start time in HH:mm 24-hour format
          example: '09:00'
        endTime:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d$
          description: Shift end time in HH:mm 24-hour format
          example: '17:00'
        dayOffType:
          type: string
          enum:
            - sick
            - vacation
            - absent
            - work_illness
          description: Type of day off, if applicable
      example:
        date: '2025-09-01'
        startTime: '09:00'
        endTime: '17:00'
    WorkAddress:
      type: object
      required:
        - state
      additionalProperties: false
      properties:
        state:
          type: string
          enum:
            - AGU
            - BCN
            - BCS
            - CAM
            - CHH
            - CHP
            - COA
            - COL
            - DIF
            - DUR
            - GRO
            - GUA
            - HID
            - JAL
            - MEX
            - MIC
            - MOR
            - NAY
            - NLE
            - OAX
            - PUE
            - QUE
            - ROO
            - SIN
            - SLP
            - SON
            - TAB
            - TAM
            - TLA
            - VER
            - YUC
            - ZAC
          description: Mexican state code
          example: AGU
    EarningOutput:
      type: object
      required:
        - earningCode
        - amount
      properties:
        earningCode:
          type: string
          description: Earning type code
          example: SALARY
        amount:
          type: number
          description: Earning amount in MXN
          example: 15000
  securitySchemes:
    apiKey:
      type: apiKey
      name: x-api-key
      in: header

````