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

# Calculate Payroll (G2N)

> Calculates gross-to-net payroll for an array of employees, including all Mexican taxes (ISR, IMSS, INFONAVIT). Returns detailed breakdown of employee and employer taxes for each employee.

Available earnings can be obtained from the [List Earnings](/api-reference/endpoint/mexico-payroll/get-earnings) endpoint. The response includes taxes and social security contributions — see [List Taxes](/api-reference/endpoint/mexico-payroll/get-taxes) and [List Social Security Contributions](/api-reference/endpoint/mexico-payroll/get-contributions) for details.



## OpenAPI

````yaml POST /api/mexico-payroll/calculate
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/calculate:
    post:
      tags:
        - Mexico Payroll
      summary: Calculate payroll (G2N)
      description: >-
        Calculates gross-to-net payroll for an array of employees, including all
        Mexican taxes (ISR, IMSS, INFONAVIT). Returns detailed breakdown of
        employee and employer taxes for each employee.


        Available earnings can be obtained from the [List
        Earnings](/api-reference/endpoint/mexico-payroll/get-earnings) endpoint.
        The response includes taxes and social security contributions — see
        [List Taxes](/api-reference/endpoint/mexico-payroll/get-taxes) and [List
        Social Security
        Contributions](/api-reference/endpoint/mexico-payroll/get-contributions)
        for details.
      operationId: calculateMexicoPayroll
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CalculatePayrollRequest'
            example:
              payrollConfig:
                startDate: '2026-01-01'
                endDate: '2026-01-31'
                period: MONTHLY
              employees:
                - employeeId: emp-001
                  employeeStartDate: '2020-01-01'
                  dailyWage: 3000
                  earnings:
                    - earningCode: SALARY
                      amount: 91200
                    - earningCode: VACATION_PREMIUM
                      amount: 3750
                  workAddress:
                    state: AGU
                  workerRiskClass: I
      responses:
        '200':
          description: Successful payroll calculation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CalculatePayrollResponse'
              example:
                results:
                  - employeeId: emp-001
                    grossPay: '94950.00'
                    employeeTaxes:
                      MX_IMSS_DISEASE_MATERNITY_PENSIONERS_EE:
                        wageBase: '83440.75'
                        taxAmount: '312.90'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_DISEASE_MATERNITY_KIND_EE:
                        wageBase: '83440.75'
                        taxAmount: '293.71'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_DISEASE_MATERNITY_MONEY_EE:
                        wageBase: '83440.75'
                        taxAmount: '208.60'
                        taxType: CONTRIBUTIONS
                      MX_SAT_ISR:
                        wageBase: '91200.00'
                        taxAmount: '21096.08'
                        taxType: TAX
                        wageBaseContributions:
                          SALARY:
                            earningKey: SALARY
                            grossAmount: '91200.00'
                            exemptionAmount: '0.00'
                            taxableAmount: '91200.00'
                          SOCIAL_WELFARE_BENEFITS:
                            earningKey: SOCIAL_WELFARE_BENEFITS
                            grossAmount: '0.00'
                            exemptionAmount: '0.00'
                            taxableAmount: '0.00'
                      MX_IMSS_DISABILITY_LIFE_EE:
                        wageBase: '83440.75'
                        taxAmount: '521.50'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_RETIREMENT_ADVANCED_AGE_EE:
                        wageBase: '83440.75'
                        taxAmount: '938.71'
                        taxType: CONTRIBUTIONS
                    employerTaxes:
                      MX_IMSS_DISEASE_MATERNITY_KIND_ER:
                        wageBase: '83440.75'
                        taxAmount: '1488.59'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_WORK_RISK:
                        wageBase: '83440.75'
                        taxAmount: '453.54'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_RETIREMENT_OLD_AGE_ER:
                        wageBase: '83440.75'
                        taxAmount: '1668.82'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_RETIREMENT_ADVANCED_AGE_ER:
                        wageBase: '83440.75'
                        taxAmount: '5358.56'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_DISEASE_MATERNITY_PENSIONERS_ER:
                        wageBase: '83440.75'
                        taxAmount: '876.13'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_DISEASE_MATERNITY_MONEY_ER:
                        wageBase: '83440.75'
                        taxAmount: '584.09'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_DISABILITY_LIFE_ER:
                        wageBase: '83440.75'
                        taxAmount: '1460.21'
                        taxType: CONTRIBUTIONS
                      MX_INFONAVIT_HOUSING:
                        wageBase: '83440.75'
                        taxAmount: '4172.04'
                        taxType: CONTRIBUTIONS
                      MX_IMSS_NURSERY_SOCIAL_BENEFITS:
                        wageBase: '83440.75'
                        taxAmount: '834.41'
                        taxType: CONTRIBUTIONS
                      MX_AGU_PAYROLL:
                        wageBase: '91200.00'
                        taxAmount: '2280.00'
                        taxType: TAX
                        wageBaseContributions:
                          SALARY:
                            earningKey: SALARY
                            grossAmount: '91200.00'
                            exemptionAmount: '0.00'
                            taxableAmount: '91200.00'
                          TERMINATION_COMPENSATION:
                            earningKey: TERMINATION_COMPENSATION
                            grossAmount: '0.00'
                            exemptionAmount: '0.00'
                            taxableAmount: '0.00'
                    totalEmployerTaxes: '19176.39'
                    totalEmployeeTaxes: '23371.50'
                    netPay: '71578.50'
                    dailySbc: '2828.50'
                    totalEmployeeTax: '21096.08'
                    totalEmployeeContributions: '2275.42'
                    totalEmployerTax: '2280.00'
                    totalEmployerContributions: '16896.39'
        '400':
          description: Invalid input data
          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 calculation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CalculatePayrollRequest:
      type: object
      required:
        - employees
        - payrollConfig
      additionalProperties: false
      properties:
        employees:
          type: array
          items:
            $ref: '#/components/schemas/EmployeeInput'
          minItems: 1
          description: Array of employees to process
        payrollConfig:
          $ref: '#/components/schemas/PayrollConfig'
    CalculatePayrollResponse:
      type: object
      required:
        - results
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/PayrollResult'
          description: Array of payroll results, one 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
    EmployeeInput:
      type: object
      required:
        - employeeId
        - employeeStartDate
        - dailyWage
        - earnings
        - previousBimesterEarnigs
        - workAddress
      additionalProperties: false
      properties:
        employeeId:
          type: string
          description: Unique employee identifier
          example: emp-basic-salary-001
        employeeStartDate:
          type: string
          format: date
          description: Employee hire date in ISO 8601 format
          example: '2020-01-01'
        dailyWage:
          type: number
          minimum: 0
          description: Daily wage in MXN
          example: 500
        earnings:
          type: array
          items:
            $ref: '#/components/schemas/EarningInput'
          default: []
          description: Array of earnings for the payroll period
        previousBimesterEarnigs:
          type: array
          items:
            $ref: '#/components/schemas/EarningInput'
          default: []
          description: >-
            Previous 2 months of earnings used for SBC (Salary Base for
            Contributions) calculation
        workerRiskClass:
          type: string
          enum:
            - I
            - II
            - III
            - IV
            - V
          default: I
          description: IMSS worker risk class. Defaults to 'I' if not specified.
        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
    PayrollResult:
      type: object
      required:
        - employeeId
        - grossPay
        - employeeTaxes
        - employerTaxes
        - netPay
        - totalEmployerTax
        - totalEmployerContributions
        - totalEmployeeTax
        - totalEmployeeContributions
        - dailySbc
      properties:
        employeeId:
          type: string
          description: Employee identifier
          example: emp-basic-salary-001
        grossPay:
          type: string
          description: Total gross earnings for the period
          example: '15000.00'
        employeeTaxes:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/TaxResult'
          description: Breakdown of employee taxes (ISR, IMSS components, etc.)
        employerTaxes:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/TaxResult'
          description: Breakdown of employer taxes and contributions
        netPay:
          type: string
          description: Net pay after all employee taxes and deductions
          example: '13250.45'
        totalEmployerTax:
          type: string
          description: Total employer taxes (taxType = TAX)
          example: '450.00'
        totalEmployerContributions:
          type: string
          description: Total employer contributions (taxType = CONTRIBUTIONS)
          example: '2100.50'
        totalEmployeeTax:
          type: string
          description: Total employee taxes
          example: '1749.55'
        totalEmployeeContributions:
          type: string
          description: Total employee contributions
          example: '350.00'
        dailySbc:
          type: string
          description: >-
            Daily SBC (Salary Base for Contributions) utilized for IMSS
            calculations
          example: '520.55'
    EarningInput:
      type: object
      required:
        - earningCode
        - amount
      additionalProperties: false
      properties:
        earningCode:
          type: string
          description: >-
            Earning type code (e.g., SALARY, DOUBLE_OVERTIME, XMAS,
            VACATION_PREMIUM)
          example: SUNDAY_PREMIUM
        amount:
          type: number
          minimum: 0
          description: Earning amount in MXN
          example: 15000
    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
    TaxResult:
      type: object
      required:
        - wageBase
        - taxAmount
      properties:
        wageBase:
          type: string
          description: Taxable income base for this tax
          example: '15000.00'
        taxAmount:
          type: string
          description: Calculated tax amount
          example: '1200.50'
        subsidy:
          type: string
          description: Tax subsidy amount, if applicable (e.g., employment subsidy for ISR)
          example: '0.00'
  securitySchemes:
    apiKey:
      type: apiKey
      name: x-api-key
      in: header

````