Skip to main content

Upload Employees (Bulk)

Overview​

Bulk uploads employee records from a structured JSON array. The system processes each record and either creates a new employee or updates an existing one based on the staffId field. Each newly created employee is automatically assigned a unique referral code.

A legacy Base64-encoded Excel file path is also supported for backward compatibility.

Command Details​

  • Command: UploadEmployeesCommand
  • Type: Command (write operation)

API Endpoint​

POST /api/bpm/cmd

Request Structure (Preferred)​

FieldTypeRequiredDescription
$typestringYesMust be UploadEmployeesCommand
employeesarrayYes*Array of employee objects (see fields below)

Employee Object Fields​

FieldTypeRequiredDescription
staffIdstringYesUnique staff identifier (used to match existing records)
emailstringYesEmployee email address
titlestringNoTitle (e.g., Mr, Mrs, Dr)
firstNamestringYesEmployee first name
lastNamestringYesEmployee last name
middleNamestringNoEmployee middle name
branchstringNoBranch name or code
rolestringNoEmployee role or position
isAccountOfficerbooleanNoWhether the employee is an account officer (default: false)
canReferCustomerbooleanNoWhether the employee can refer customers (default: true)
info
  • If a staffId already exists in the system, the corresponding employee record will be updated with the new values.
  • If a staffId does not exist, a new employee will be created with an auto-generated referral code.

Try It Out​

POST/api/bpm/cmdUploadEmployeesCommand
Request Body

Response Structure​

Success:

{
"isSuccessful": true,
"message": "Upload complete. Created: 2, Updated: 0, Errors: 0.",
"data": {
"created": 2,
"updated": 0,
"errorCount": 0,
"errors": []
}
}

Partial errors:

{
"isSuccessful": true,
"message": "Upload complete. Created: 15, Updated: 5, Errors: 5.",
"data": {
"created": 15,
"updated": 5,
"errorCount": 5,
"errors": [
"Record 3: StaffId and Email are required.",
"Record 7: Email (john@example.com) already belongs to another employee.",
"Record 10: FirstName and LastName are required."
]
}
}

Legacy: Base64 Excel Upload​

For backward compatibility, you can also send a Base64-encoded Excel file instead of a JSON array.

FieldTypeRequiredDescription
$typestringYesMust be UploadEmployeesCommand
fileBase64stringYes*Base64-encoded Excel file content

*Either employees or fileBase64 must be provided. If both are present, employees takes precedence.

Expected Excel Columns​

ColumnPositionRequiredDescription
StaffId1YesUnique staff identifier
Email2YesEmployee email address
Title3NoTitle (e.g., Mr, Mrs, Dr)
FirstName4YesEmployee first name
LastName5YesEmployee last name
MiddleName6NoEmployee middle name
Branch7NoBranch name or code
Role8NoEmployee role or position