Calculate Payroll (G2N) - Flux Payroll API

Calculate payroll (G2N)

cURL

curl --request POST \
  --url https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "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"
    }
  ]
}
'

Python

import requests

url = "https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate"

payload = {
    "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"
        }
    ]
}
headers = {
    "x-api-key": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

JavaScript

const options = {
  method: 'POST',
  headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    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'
      }
    ]
  })
};

fetch('https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    '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'
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "x-api-key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Go

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate"

payload := strings.NewReader("{\n  \"payrollConfig\": {\n    \"startDate\": \"2026-01-01\",\n    \"endDate\": \"2026-01-31\",\n    \"period\": \"MONTHLY\"\n  },\n  \"employees\": [\n    {\n      \"employeeId\": \"emp-001\",\n      \"employeeStartDate\": \"2020-01-01\",\n      \"dailyWage\": 3000,\n      \"earnings\": [\n        {\n          \"earningCode\": \"SALARY\",\n          \"amount\": 91200\n        },\n        {\n          \"earningCode\": \"VACATION_PREMIUM\",\n          \"amount\": 3750\n        }\n      ],\n      \"workAddress\": {\n        \"state\": \"AGU\"\n      },\n      \"workerRiskClass\": \"I\"\n    }\n  ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
    req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}

Java

HttpResponse<String> response = Unirest.post("https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate")
  .header("x-api-key", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"payrollConfig\": {\n    \"startDate\": \"2026-01-01\",\n    \"endDate\": \"2026-01-31\",\n    \"period\": \"MONTHLY\"\n  },\n  \"employees\": [\n    {\n      \"employeeId\": \"emp-001\",\n      \"employeeStartDate\": \"2020-01-01\",\n      \"dailyWage\": 3000,\n      \"earnings\": [\n        {\n          \"earningCode\": \"SALARY\",\n          \"amount\": 91200\n        },\n        {\n          \"earningCode\": \"VACATION_PREMIUM\",\n          \"amount\": 3750\n        }\n      ],\n      \"workAddress\": {\n        \"state\": \"AGU\"\n      },\n      \"workerRiskClass\": \"I\"\n    }\n  ]\n}")
  .asString();

Ruby

require 'uri'
require 'net/http'

url = URI("https://api.staging.fluxpayroll.ai/api/mexico-payroll/calculate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"payrollConfig\": {\n    \"startDate\": \"2026-01-01\",\n    \"endDate\": \"2026-01-31\",\n    \"period\": \"MONTHLY\"\n  },\n  \"employees\": [\n    {\n      \"employeeId\": \"emp-001\",\n      \"employeeStartDate\": \"2020-01-01\",\n      \"dailyWage\": 3000,\n      \"earnings\": [\n        {\n          \"earningCode\": \"SALARY\",\n          \"amount\": 91200\n        },\n        {\n          \"earningCode\": \"VACATION_PREMIUM\",\n          \"amount\": 3750\n        }\n      ],\n      \"workAddress\": {\n        \"state\": \"AGU\"\n      },\n      \"workerRiskClass\": \"I\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body

Response

200

{
  "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"
    }
  ]
}

Validation Error Examples

{
  "error": "VALIDATION_ERROR",
  "message": "Invalid input data provided",
  "details": [
    {
      "field": "<string>",
      "message": "<string>"
    }
  ]
}