### Successful Payrun Response Example Source: https://microkeeper.com.au/guides.php?guide=api-payroll-add-get-process An example of a successful API response for a payrun, including detailed payslip information and leave accrual. ```APIDOC ## Successful Payrun Response Example ### Description This is a sample of a successful API response for a payrun, detailing run data, payslip information, and leave accrual for employees. ### Method GET (Assumed, as it's a response example) ### Endpoint `/api/payruns/{id}` (Assumed) ### Response #### Success Response (200) - **success** (string) - Indicates if the operation was successful ('1' for success). - **authenticated** (string) - Indicates if the user is authenticated ('1' for authenticated). - **message** (string) - A message describing the response. - **data** (object) - Contains the main payrun and payslip data. - **runs** (array) - An array of payrun runs. - **run_data** (object) - Details about the payrun run. - **payslips** (array) - An array of payslips for the run. - **leave_accrual** (object) - Leave accrual details for the employee. - **al** (object) - Annual Leave details. - **accrual_amount** (string) - Amount accrued in this payrun. - **accrual_bal** (string) - Running balance of accrued leave. - **sick** (object) - Sick Leave details. - **accrual_amount** (string) - Amount accrued in this payrun. - **accrual_bal** (string) - Running balance of accrued leave. - **rdo** (object) - RDO (Rostered Day Off) details. - **accrual_amount** (string) - Amount accrued in this payrun. - **accrual_bal** (string) - Running balance of accrued leave. ### Response Example ```json { "success": "1", "authenticated": "1", "message": "Payrun data", "data": { "runs": [ { "run_data": { "pay_cycle_title": "Casuals", "abn": "95149280320", "abn_name": "ABN Engineering PTY LTD", "abn_trading": "ABN Engineering", "PCID": "0", "year": "2018", "run_id": "5", "payment_date": "2018-12-20", "wip": "2", "period": "fortnightly", "day": "wednesday", "unlocked": "1", "period_start": "2018-07-18", "period_end": "2018-07-31" }, "payslips": [ { "eusername": "john_smith", "payment": "234.88", "expense": "170.38", "taxable": "64.50", "deduction": "10.00", "tax": "13.00", "net": "41.50", "hours": 12, "annual": "134.458", "sick": "205.867", "rdo": 0, "lsl": "151.88", "annual_gross": "3000.00", "annual_net": "2216.08", "annual_tax": "2.00", "EID": "3", "EmployeeID": "ABC123", "super_fund": "482", "super_no": "987654321", "pay_list": [ { "ESBDID": "100001", "note": "Basic Job A", "date": "2021-12-20", "LID": "856", "ROID": "521", "JID": "907", "rate": "20.5", "hours": "9", "mult": "1", "value": "184.50", "class": "FALSE", "STP": "" }, { "ESBDID": "100002", "note": "Fixed extra", "date": "2021-12-20", "LID": "856", "ROID": "521", "JID": "909", "rate": "10", "hours": "3", "mult": "1", "value": "30.00", "class": "TRUE", "STP": "" }, { "ESBDID": "100003", "note": "Super Exclusive-Job C", "date": "2021-12-20", "LID": "856", "ROID": "521", "JID": "909", "rate": "9.5", "hours": "0", "mult": "0", "value": "20.38", "class": "SUPER", "STP": "" } ], "exp_list": [ { "ESNTDID": "1001", "note": "Salary Sac", "rate": "75.000", "mult": "2.00", "value": "150.00", "class": "SUPER" }, { "ESNTDID": "1002", "note": "Super-Job C", "rate": "9.500", "mult": "1.00", "value": "20.38", "class": "SUPER3" } ], "ded_list": [ { "ESDID": "101", "note": "Test", "rate": "10.000", "mult": "1.00", "value": "10.00", "class": "FEES" } ], "leave_accrual": { "al": { "accrual_amount": "2.932", "accrual_bal": "25" }, "sick": { "accrual_amount": "1.556", "accrual_bal": "10" }, "rdo": { "accrual_amount": "0", "accrual_bal": "40" } } } ] } ] }, "super_fund_detail": { "482": { "name": "REST", "ABN": "62653671394", "USI": "RES0103AU", "open": "1" } } } ``` ``` -------------------------------- ### Upsert Employees via API (PHP Example) Source: https://microkeeper.com.au/guides.php?guide=api-add-employee-payroll This snippet demonstrates how to prepare and send data to the Microkeeper API to upsert employee information. It involves setting the action and data variables, with the data formatted as a JSON string. The example assumes a PHP environment and requires prior completion of the 'Hello World' tutorial for API authentication. ```php [ [ "EmployeeID" => "emp_001", "firstname" => "John", "lastname" => "Smith", "email" => "john@example.com", "phoneno" => "0400123456", "super_fund" => "RES0103AU", "welcome" => "email" ] ] ]); // In a real scenario, you would then make an API request using these variables. // For example, using cURL or a similar HTTP client: /* $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'YOUR_API_ENDPOINT'); // Replace with your actual API endpoint curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(['mk_action' => $mk_action, 'mk_data' => $mk_data])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $server_output = curl_exec($ch); curl_close($ch); // Process $server_output */ echo "mk_action: " . $mk_action . "\n"; echo "mk_data: " . $mk_data . "\n"; ?> ``` -------------------------------- ### Successful Payrun Response Example Source: https://microkeeper.com.au/guides.php?guide=api-payroll-add-get-process A sample JSON response for a successful payrun query. It includes run metadata, detailed payslip information for employees, and associated superannuation fund details. ```json { "success": "1", "authenticated": "1", "message": "Payrun data", "data": { "runs": [ { "run_data": { "pay_cycle_title": "Casuals", "abn": "95149280320", "abn_name": "ABN Engineering PTY LTD", "abn_trading": "ABN Engineering", "PCID": "0", "year": "2018", "run_id": "5", "payment_date": "2018-12-20", "wip": "2", "period": "fortnightly", "day": "wednesday", "unlocked": "1", "period_start": "2018-07-18", "period_end": "2018-07-31" }, "payslips": [ { "eusername": "john_smith", "payment": "234.88", "expense": "170.38", "taxable": "64.50", "deduction": "10.00", "tax": "13.00", "net": "41.50", "hours": 12, "annual": "134.458", "sick": "205.867", "rdo": 0, "lsl": "151.88", "annual_gross": "3000.00", "annual_net": "2216.08", "annual_tax": "2.00", "EID": "3", "EmployeeID": "ABC123", "super_fund": "482", "super_no": "987654321", "pay_list": [ { "ESBDID": "100001", "note": "Basic Job A", "date": "2021-12-20", "LID": "856", "ROID": "521", "JID": "907", "rate": "20.5", "hours": "9", "mult": "1", "value": "184.50", "class": "FALSE", "STP": "" } ], "leave_accrual": { "al": { "accrual_amount": "2.932", "accrual_bal": "25" } } } ] } ] } } ``` -------------------------------- ### API Payroll Processing Source: https://microkeeper.com.au/guides.php?guide=api-payroll-add-get-process This guide explains how to process payroll via API, including adding payments, expenses, and deductions. ```APIDOC ## POST /api/payroll ### Description Processes payroll, allowing for the addition of payments, expenses, and deductions. ### Method POST ### Endpoint /api/payroll ### Parameters #### Request Body - **employee_id** (integer) - Required - The ID of the employee for whom payroll is being processed. - **payments** (array) - Optional - A list of payments to be added. - **type** (string) - Required - The type of payment (e.g., 'salary', 'bonus'). - **amount** (float) - Required - The amount of the payment. - **expenses** (array) - Optional - A list of expenses to be added. - **type** (string) - Required - The type of expense (e.g., 'travel', 'uniform'). - **amount** (float) - Required - The amount of the expense. - **deductions** (array) - Optional - A list of deductions to be made. - **type** (string) - Required - The type of deduction (e.g., 'tax', 'loan'). - **amount** (float) - Required - The amount of the deduction. ### Request Example ```json { "employee_id": 123, "payments": [ { "type": "salary", "amount": 5000.00 } ], "expenses": [ { "type": "travel", "amount": 50.00 } ], "deductions": [ { "type": "tax", "amount": 1000.00 } ] } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the payroll processing. - **message** (string) - A message detailing the outcome of the process. #### Response Example ```json { "status": "success", "message": "Payroll processed successfully for employee ID 123." } ``` ``` -------------------------------- ### API Successful Response Format Source: https://microkeeper.com.au/guides.php?guide=api-payroll-add-get-process Example of a successful JSON response returned after processing a payrun, including calculation duration and totals for payments, expenses, and deductions. ```json { "success":"1", "authenticated":"1", "message":"Payrun processed", "data": {"calculation_duration":0.31,"total":{"payment":718.37,"expense":20,"deduction":5}} } ``` -------------------------------- ### Define Super Fund Detail Object Source: https://microkeeper.com.au/guides.php?guide=api-payroll-add-get-process Example structure of a super_fund_detail object returned by the API, showing key-value mapping for fund identification and metadata. ```json { "482": { "name": "REST", "ABN": "62653671394", "USI": "RES0103AU", "open": "1" } } ``` -------------------------------- ### Retrieve Specific Jobs by JobID API Call (JSON) Source: https://microkeeper.com.au/guides.php?guide=api-get-update-job Example of how to retrieve specific jobs by their third-party IDs (JobIDs) using the 'get_jobs' action. The 'status' is set to 'JobID' and a list of JobIDs is provided. ```json { "status":"JobID", "JobID":["ABC5","ABC3"] } ``` -------------------------------- ### Payroll Data Retrieval Request Parameters Source: https://microkeeper.com.au/guides.php?guide=api-payroll-add-get-process Examples of how to structure the mk_data variable for different payroll retrieval scenarios, including date ranges, specific payrun IDs, and employee filtering. ```json {"start_date":"2018-05-21", "end_date":"2018-05-21"} ``` ```json {"payrun_id":[{"year":2018,"run_id":48},{"year":2018,"run_id":49}],"EmployeeID":[111]} ``` ```json {"start_date":"2018-07-01","end_date":"2019-06-30", "eusername":["john_smith"],"EmployeeID":[111,222,333],"EID":[3,4,6]} ``` -------------------------------- ### Retrieve Specific Jobs by JID API Call (JSON) Source: https://microkeeper.com.au/guides.php?guide=api-get-update-job Example of how to retrieve specific jobs by their Microkeeper IDs (JIDs) using the 'get_jobs' action. The 'status' is set to 'JID' and a list of JIDs is provided. ```json { "status":"JID", "JID":["8557","8556"] } ``` -------------------------------- ### POST /api_post.php - Hello World Example Source: https://microkeeper.com.au/guides.php?guide=api-integration This snippet demonstrates how to make a 'Hello World' request to the Microkeeper API using PHP. It includes setting up the necessary variables like business key, developer key, action, and data, then sending the POST request via cURL. ```APIDOC ## POST /api_post.php ### Description This endpoint is used to post data to the Microkeeper API for various actions, including a 'hello_world' example. ### Method POST ### Endpoint https://microkeeper.com.au/api_post.php ### Parameters #### Request Body - **mk_biz_key** (string) - Required - Used to identify which Microkeeper account to access. Each business has a unique key. - **mk_dev_key** (string) - Required - Identifies the software provider. Stored server side and never displayed to the user. - **mk_action** (string) - Required - Specifies the action to be performed (e.g., 'hello_world'). - **mk_data** (JSON string) - Required - The data payload for the action. Requirements vary based on `mk_action`. ### Request Example ```json { "mk_biz_key": "1o7ayfmp092rmkrds7et7s3e3cnq3wqr", "mk_dev_key": "YOUR_DEVELOPER_KEY", "mk_action": "hello_world", "mk_data": "{\"hello\":\"world\"}" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the transaction was successful. - **authenticated** (boolean) - Indicates if the user passed authentication. - **message** (string) - Message from Microkeeper (success or error). - **data** (JSON) - Optional - Send data back to your API. #### Response Example ```json { "success": "1", "authenticated": "1", "message": "Hello World! Accessed: frogga" } ``` ``` -------------------------------- ### GET /jobs Source: https://microkeeper.com.au/guides.php?guide=api-get-update-job Retrieves a list of jobs currently recorded in the Microkeeper system. ```APIDOC ## GET /jobs ### Description Retrieves a list of all jobs stored in Microkeeper, including their unique identifiers, client associations, titles, date ranges, access permissions, and status. ### Method GET ### Endpoint /jobs ### Parameters None ### Response #### Success Response (200) - **success** (string) - Indicates if the request was successful (1). - **authenticated** (string) - Indicates if the session is authenticated (1). - **message** (string) - Status message. - **data** (object) - Contains the list of jobs. #### Response Example { "success": "1", "authenticated": "1", "message": "Job data", "data": { "jobs": [ { "JID": "2588", "CID": "0", "title": "Job 1", "startdate": "2018-10-25", "enddate": "2018-11-25", "job_access": "0", "status": "Active" } ] } } ``` -------------------------------- ### PHP Hello World API Call to Microkeeper Source: https://microkeeper.com.au/guides.php?guide=api-integration This PHP script demonstrates how to make a 'Hello World' request to the Microkeeper API. It sets up the necessary API keys and data, then uses cURL to send the POST request and receive the JSON response. Ensure your $mk_dev_key is set correctly and stored securely server-side. ```PHP //////////////////////////////// //CONFIG /////////////////////////////// $mk_dev_key='';//Set this value once to identify your software $post_data['mk_biz_key']='1o7ayfmp092rmkrds7et7s3e3cnq3wqr';//Dynamically set this depending on which user you want to access $post_data['mk_dev_key']=$mk_dev_key; $post_data['mk_action']='hello_world';//Set this depending on what data you want to access $post_data['mk_data']='{"hello":"world"}';//JSON data being sent //Traverse array and prepare data for posting (key1=value1) foreach($post_data as $key => $value) { $post_items[]=$key.'='.$value; } //Create the final string to be posted using implode() $post_string=implode('&', $post_items); //URL to hit server with NOTE HTTPS! $curl_connection=curl_init('https://microkeeper.com.au/api_post.php'); //Setup CURL curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT,30); curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER,true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER,false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION,1); curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);//set data to be posted $result=json_decode(curl_exec($curl_connection),true);//perform our request curl_close($curl_connection);//close the connection //output the response ?>