Import via JSON (Direct Import)

Direct JSON Import is the agile method within the LAW API for data synchronization. Unlike the file workflow (which requires CSV uploads and asynchronous processing), this method allows you to send records directly to the processing endpoints.

Why use this method?

  • Real-Time: Ideal for synchronizing employee changes as soon as they occur in your system (e.g., new hires, terminations).
  • No File Management: Eliminates the need to create, store, and manage the lifecycle of temporary .csv files on your servers.
  • Immediate Feedback: Structural JSON validation happens instantly, returning format errors immediately.

Recommendation: Use this method for smaller batches (up to 5MB) or single calls. For massive historical data loads, prefer the Import via URL Workflow.


Technical Requirements

Scope: Global (Applies to all endpoints)

  • Protocol: All data transmission MUST occur over HTTPS using TLS 1.2 or higher.
  • Authentication Method: Bearer Token (JWT).
  • Header Requirement: Every HTTP request to the API MUST include the Authorization header.
    • Format: Authorization: Bearer <access_token>
  • Token Validation: The API Gateway SHALL validate the token signature and expiration before processing the payload.
    • Failure: If validation fails, the API MUST return status code 401 Unauthorized.

Interface Standards

Scope: Global

  • Content-Type: All requests MUST utilize application/json as the Content-Type.
  • Character Encoding: UTF-8.
  • Date Format: All date fields SHALL adhere to ISO 8601 format (e.g., YYYY-MM-DD).

Authentication and Headers

This API is secured by Bearer Token authentication. To access protected resources, the client must provide a valid access token in the HTTP Authorization header of every request (Bearer ).

Header Value Description
Content-Type application/json Request body format.
Authorization Bearer {your token} Authentication bearer token.

⚠️ Ensure your token is valid and hasn't expired. Requests without a valid Bearer token will return a 401 Unauthorized error.


1. Census Import

The Census endpoint is used to update the employee database. Keep demographic, contact, and employment data up to date to ensure correct loan eligibility.

  • Endpoint: POST /api/v1/census

Request Example:

Node.js

const axios = require('axios');

const token = '1fdfab23-123f-4567-abef-1c2ef3b4da5d';
const url = 'https://sandbox.bmgmoney.com/api/v1/census';
const payload = [
  {
    lastName: "Doe",
    firstName: "John",
    employeeRegistration: "EMP12345",
    hireDate: "2024-01-15",
    employeeStatus: "Active",
    eligibleForBenefits: true,
    payCycle: "Bi-Weekly",
    periodsPerYear: 26,
    grossAnnualSalary: 65000.00,
    salaryPerPeriod: 2500.00,
    standardHours: 40,
    hourlyRate: 31.25,
    timeType: "Full-Time",
    payrollGroup: "Group A",
    payrollArea: "North",
    personnelSubArea: "Admin"
  }
];

const response = await axios.post(url, payload, {
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    }
});

C#

using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
var token = "1fdfab23-123f-4567-abef-1c2ef3b4da5d";

var payload = new[]
{
    new
    {
        lastName = "Doe",
        firstName = "John",
        employeeRegistration = "EMP12345",
        hireDate = "2024-01-15",
        employeeStatus = "Active",
        eligibleForBenefits = true,
        payCycle = "Bi-Weekly",
        periodsPerYear = 26,
        grossAnnualSalary = 65000.00,
        salaryPerPeriod = 2500.00,
        standardHours = 40,
        hourlyRate = 31.25,
        timeType = "Full-Time",
        payrollGroup = "Group A",
        payrollArea = "North",
        personnelSubArea = "Admin"
    }
};

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

var content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://sandbox.bmgmoney.com/api/v1/census", content);

Python

import requests

def sync_census_data():
    url = "https://sandbox.bmgmoney.com/api/v1/census"
    token = "1fdfab23-123f-4567-abef-1c2ef3b4da5d"
    
    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json"
    }
    
    payload = [
        {
            "lastName": "Doe",
            "firstName": "John",
            "employeeRegistration": "EMP12345",
            "hireDate": "2024-01-15",
            "employeeStatus": "Active",
            "eligibleForBenefits": True,
            "payCycle": "Bi-Weekly",
            "periodsPerYear": 26,
            "grossAnnualSalary": 65000.00,
            "salaryPerPeriod": 2500.00,
            "standardHours": 40,
            "hourlyRate": 31.25,
            "timeType": "Full-Time",
            "payrollGroup": "Group A",
            "payrollArea": "North",
            "personnelSubArea": "Admin"
        }
    ]

    try:
        response = requests.post(url, json=payload, headers=headers)
        response.raise_for_status()
        print("Success:", response.json())
    except requests.exceptions.RequestException as e:
        print(f"Sync failed: {e}")

if __name__ == "__main__":
    sync_census_data()

Common Responses

  • 201 Created: The batch was accepted and queued for processing.
  • 400 Bad Request: Validation error in the submitted data (e.g., invalid date format).
  • 401 Unauthorized: Bearer token is missing or invalid.
  • 422 Unprocessable Entity: The JSON is well-formed but violates a business rule.

2. Receipt Import

The Receipt endpoint should be used to report payments and deductions made in the payroll. This data is crucial for paying off active loan installments.

  • Endpoint: POST /api/v1/receipt

Request Example:

Node.js

const axios = require('axios');

const token = '1fdfab23-123f-4567-abef-1c2ef3b4da5d';
const url = 'https://sandbox.bmgmoney.com/api/v1/receipt';

const payload = [
  {
    lastName: "Smith",
    firstName: "Jane",
    ssn: "000-00-0000",
    employeeRegistration: "EMP98765",
    paymentDate: "2026-01-20",
    amount: 1250.50
  }
];

const response = await axios.post(url, payload, {
    headers: {
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    }
});

C#

using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
var token = "1fdfab23-123f-4567-abef-1c2ef3b4da5d";

var payload = new[]
{
    new
    {
        lastName = "Smith",
        firstName = "Jane",
        ssn = "000-00-0000",
        employeeRegistration = "EMP98765",
        paymentDate = "2026-01-20",
        amount = 1250.50
    }
};

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

var content = new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://sandbox.bmgmoney.com/api/v1/receipt", content);

Python

import requests

def sync_receipt_data():
    url = "https://sandbox.bmgmoney.com/api/v1/receipt"
    token = "1fdfab23-123f-4567-abef-1c2ef3b4da5d"
    
    headers = {
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json"
    }
    
    payload = [
        {
            "lastName": "Smith",
            "firstName": "Jane",
            "ssn": "000-00-0000",
            "employeeRegistration": "EMP98765",
            "paymentDate": "2026-01-20",
            "amount": 1250.50
        }
    ]

    try:
        response = requests.post(url, json=payload, headers=headers)
        response.raise_for_status()
        print("Success:", response.json())
    except requests.exceptions.RequestException as e:
        print(f"Failed to sync receipts: {e}")

if __name__ == "__main__":
    sync_receipt_data()

Error Handling

The API returns standard HTTP status codes to indicate the success or failure of the request. In case of an error, the response body will contain useful details.

{
  "title": null,
  "statusCode": false,
  "timestamp": "",
  "errors": [
      ""
  ]
}