MENU navbar-image

Introduction

Megacess Workforce Management System API - Manage staff, attendance, tasks, and locations.

This documentation aims to provide all the information you need to work with our API.

<aside>As you scroll, you'll see code examples for working with the API in different programming languages in the dark area to the right (or as part of the content on mobile).
You can switch the language used with the tabs at the top right (or from the nav menu at the top left on mobile).</aside>

Authenticating requests

To authenticate requests, include an Authorization header with the value "Bearer {YOUR_TOKEN}".

All authenticated endpoints are marked with a requires authentication badge in the documentation below.

You can retrieve your token by calling the POST /api/v1/auth/login endpoint with your credentials. Use the returned token in the Authorization header as Bearer {token}.

Advance Management

Display a listing of users/staff who have advance loans.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/advances?type=staff&search=john&role=manager&per_page=15&page=1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances"
);

const params = {
    "type": "staff",
    "search": "john",
    "role": "manager",
    "per_page": "15",
    "page": "1",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'type' => 'staff',
            'search' => 'john',
            'role' => 'manager',
            'per_page' => '15',
            'page' => '1',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances'
params = {
  'type': 'staff',
  'search': 'john',
  'role': 'manager',
  'per_page': '15',
  'page': '1',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Users/staff with advance loans retrieved successfully",
    "data": [
        {
            "type": "staff",
            "id": 1,
            "name": "Ethan Muller",
            "phone": "+1234567890",
            "img": null,
            "total_outstanding_balance": 1250.5,
            "total_loan_amount": 2000,
            "total_paid_amount": 749.5,
            "loan_count": 3
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/advances

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

type   string  optional    

Filter by type (staff/user). Example: staff

search   string  optional    

Search by staff/user name. Example: john

role   string  optional    

Filter by role (for users only: manager/checker/admin). Example: manager

per_page   integer  optional    

Number of items per page. Example: 15

page   integer  optional    

Page number. Example: 1

Store a newly created advance record.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/advances" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"type\": \"staff\",
    \"staff_id\": 1,
    \"user_id\": 1,
    \"loan_date\": \"2025-10-27\",
    \"loan_amount\": 250,
    \"loan_remarks\": \"Essentials equipment\",
    \"loan_status\": \"not_paid\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "type": "staff",
    "staff_id": 1,
    "user_id": 1,
    "loan_date": "2025-10-27",
    "loan_amount": 250,
    "loan_remarks": "Essentials equipment",
    "loan_status": "not_paid"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'type' => 'staff',
            'staff_id' => 1,
            'user_id' => 1,
            'loan_date' => '2025-10-27',
            'loan_amount' => 250.0,
            'loan_remarks' => 'Essentials equipment',
            'loan_status' => 'not_paid',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances'
payload = {
    "type": "staff",
    "staff_id": 1,
    "user_id": 1,
    "loan_date": "2025-10-27",
    "loan_amount": 250,
    "loan_remarks": "Essentials equipment",
    "loan_status": "not_paid"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Advance record created successfully",
    "data": {
        "loan_id": 1,
        "staff_id": 1,
        "loan_date": "2025-10-27",
        "loan_amount": "250.00",
        "loan_remarks": "Essentials equipment: boots, scythe and machete",
        "loan_status": "not_paid",
        "created_by": 1,
        "created_at": "2025-10-27T00:00:00.000000Z",
        "updated_at": "2025-10-27T00:00:00.000000Z",
        "staff": {
            "id": 1,
            "staff_fullname": "Ethan Muller"
        },
        "creator": {
            "id": 1,
            "user_fullname": "Admin1"
        }
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "type": [
            "The type field is required."
        ],
        "loan_date": [
            "The loan date field is required."
        ]
    }
}
 

Request      

POST api/v1/advances

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

type   string     

The type of record (staff/user). Example: staff

staff_id   integer  optional    

required_if:type,staff The ID of the staff member. Example: 1

user_id   integer  optional    

required_if:type,user The ID of the user. Example: 1

loan_date   string     

The date of the loan (YYYY-MM-DD). Example: 2025-10-27

loan_amount   number     

The loan amount. Example: 250

loan_remarks   string  optional    

nullable Remarks about the loan. Example: Essentials equipment

loan_status   string  optional    

nullable Payment status (not_paid/partially_paid/paid). Defaults to not_paid. Example: not_paid

Get list of staff members for advance selection.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/advances/staff/list?search=ethan" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances/staff/list"
);

const params = {
    "search": "ethan",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/list';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'ethan',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/list'
params = {
  'search': 'ethan',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff list retrieved successfully",
    "data": [
        {
            "id": 1,
            "staff_fullname": "Ethan Muller",
            "staff_phone": "+1234567890",
            "staff_img": null
        }
    ]
}
 

Request      

GET api/v1/advances/staff/list

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

Search staff by name. Example: ethan

Get list of users for advance selection.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/advances/users/list?search=oikawa&role=manager" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances/users/list"
);

const params = {
    "search": "oikawa",
    "role": "manager",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances/users/list';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'oikawa',
            'role' => 'manager',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances/users/list'
params = {
  'search': 'oikawa',
  'role': 'manager',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Users list retrieved successfully",
    "data": [
        {
            "id": 1,
            "user_fullname": "Oikawa Yamaguchi",
            "user_nickname": "oikawa",
            "user_role": "manager",
            "user_img": null
        }
    ]
}
 

Request      

GET api/v1/advances/users/list

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

Search users by name. Example: oikawa

role   string  optional    

Filter by role (mandor/manager/checker/admin). Example: manager

Display a specific advance record detail.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/advances/staff/record/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances/staff/record/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/record/1';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/record/1'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Advance record retrieved successfully",
    "data": {
        "loan_id": 1,
        "staff_id": 1,
        "loan_date": "2025-10-27",
        "loan_amount": "250.00",
        "loan_paid_amount": "0.00",
        "loan_remarks": "Essentials equipment: boots, scythe and machete",
        "loan_status": "not_paid",
        "remaining_amount": 250,
        "created_by": 1,
        "created_at": "2025-10-27T00:00:00.000000Z",
        "updated_at": "2025-10-27T00:00:00.000000Z",
        "staff": {
            "id": 1,
            "staff_fullname": "Ethan Muller",
            "staff_phone": "+1234567890",
            "staff_img": null
        },
        "creator": {
            "id": 1,
            "user_fullname": "Admin1",
            "user_nickname": "admin1"
        }
    }
}
 

Example response (400, Invalid type):


{
    "success": false,
    "message": "Invalid type. Must be either \"staff\" or \"user\""
}
 

Example response (404, Record not found):


{
    "success": false,
    "message": "Advance record not found"
}
 

Request      

GET api/v1/advances/{type}/record/{loan_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

type   string     

The type of record (staff/user). Example: staff

loan_id   integer     

The ID of the loan record. Example: 1

Get the cumulative/total outstanding balance for a staff member or user.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/advances/staff/1/outstanding-balance" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances/staff/1/outstanding-balance"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/1/outstanding-balance';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/1/outstanding-balance'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Outstanding balance retrieved successfully",
    "data": {
        "type": "staff",
        "id": 1,
        "name": "Ethan Muller",
        "total_outstanding_balance": 1250.5,
        "total_loan_amount": 2000,
        "total_paid_amount": 749.5,
        "loan_count": 3
    }
}
 

Example response (400, Invalid type):


{
    "success": false,
    "message": "Invalid type. Must be either \"staff\" or \"user\""
}
 

Example response (404, Staff/User not found):


{
    "success": false,
    "message": "Staff member not found"
}
 

Request      

GET api/v1/advances/{type}/{id}/outstanding-balance

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

type   string     

The type of record (staff/user). Example: staff

id   integer     

The ID of the staff member or user. Example: 1

Update the payment status of an advance record.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/advances/staff/1/status" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"loan_status\": \"paid\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances/staff/1/status"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "loan_status": "paid"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/1/status';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'loan_status' => 'paid',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/1/status'
payload = {
    "loan_status": "paid"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Advance payment status updated successfully",
    "data": {
        "loan_id": 1,
        "staff_id": 1,
        "loan_date": "2025-10-27",
        "loan_amount": "250.00",
        "loan_remarks": "Essentials equipment",
        "loan_status": "paid",
        "created_by": 1,
        "created_at": "2025-10-27T00:00:00.000000Z",
        "updated_at": "2025-10-27T00:00:00.000000Z",
        "staff": {
            "id": 1,
            "staff_fullname": "Ethan Muller"
        },
        "creator": {
            "id": 1,
            "user_fullname": "Admin1"
        }
    }
}
 

Example response (404, Record not found):


{
    "success": false,
    "message": "Advance record not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "loan_status": [
            "The loan status field is required."
        ]
    }
}
 

Request      

PUT api/v1/advances/{type}/{id}/status

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

type   string     

The type of record (staff/user). Example: staff

id   integer     

The ID of the loan record. Example: 1

Body Parameters

loan_status   string     

Payment status (not_paid/partially_paid/paid). Example: paid

Display all advance records for a specific staff member or user.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/advances/staff/1?status=not_paid" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/advances/staff/1"
);

const params = {
    "status": "not_paid",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/1';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'status' => 'not_paid',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/advances/staff/1'
params = {
  'status': 'not_paid',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Advance records retrieved successfully",
    "data": {
        "type": "staff",
        "id": 1,
        "name": "Ethan Muller",
        "total_outstanding_balance": 1250.5,
        "total_loan_amount": 2000,
        "total_paid_amount": 749.5,
        "loan_count": 3,
        "advances": [
            {
                "loan_id": 1,
                "staff_id": 1,
                "loan_date": "2025-10-27",
                "loan_amount": "250.00",
                "loan_paid_amount": "0.00",
                "loan_remarks": "Essentials equipment: boots, scythe and machete",
                "loan_status": "not_paid",
                "remaining_amount": 250,
                "created_by": 1,
                "created_at": "2025-10-27T00:00:00.000000Z",
                "updated_at": "2025-10-27T00:00:00.000000Z",
                "creator": {
                    "id": 1,
                    "user_fullname": "Admin1",
                    "user_nickname": "admin1"
                }
            }
        ]
    }
}
 

Example response (400, Invalid type):


{
    "success": false,
    "message": "Invalid type. Must be either \"staff\" or \"user\""
}
 

Example response (404, Staff/User not found):


{
    "success": false,
    "message": "Staff member not found"
}
 

Request      

GET api/v1/advances/{type}/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

type   string     

The type of record (staff/user). Example: staff

id   integer     

The ID of the staff member or user. Example: 1

Query Parameters

status   string  optional    

Filter by payment status (not_paid/partially_paid/paid). Example: not_paid

Analytics

Get dashboard data including pending leave, absence, payroll, yield, and equipment usage.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/dashboard?month=10&year=2025" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/dashboard"
);

const params = {
    "month": "10",
    "year": "2025",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/dashboard';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '10',
            'year' => '2025',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/dashboard'
params = {
  'month': '10',
  'year': '2025',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "pending_leave": 1,
        "number_of_absence": 1,
        "pending_payroll": 1,
        "total_yield_harvested": {
            "total": 5.17999999999999971578290569595992565155029296875,
            "unit": "ton",
            "recent_harvested_area": {
                "location_id": 2,
                "location_name": "B01",
                "total": 0.2399999999999999911182158029987476766109466552734375
            }
        },
        "total_equipment_used": {
            "bags": 32,
            "liters": 61
        }
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/analytics/dashboard

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

month   integer  optional    

Filter by month (1-12). If not provided, uses current month. Example: 10

year   integer  optional    

Filter by year. If not provided, uses current year. Example: 2025

Get manager analytics dashboard data.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/manager?location_id=1&start_date=2025-01-01&end_date=2025-01-31&task_type=manuring&fertilizer_type=NPK&sanitation_type=spraying" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/manager"
);

const params = {
    "location_id": "1",
    "start_date": "2025-01-01",
    "end_date": "2025-01-31",
    "task_type": "manuring",
    "fertilizer_type": "NPK",
    "sanitation_type": "spraying",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/manager';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'location_id' => '1',
            'start_date' => '2025-01-01',
            'end_date' => '2025-01-31',
            'task_type' => 'manuring',
            'fertilizer_type' => 'NPK',
            'sanitation_type' => 'spraying',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/manager'
params = {
  'location_id': '1',
  'start_date': '2025-01-01',
  'end_date': '2025-01-31',
  'task_type': 'manuring',
  'fertilizer_type': 'NPK',
  'sanitation_type': 'spraying',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "usage_analytics": {
            "fertilizer_usage": {
                "total_amount": 150.5,
                "unit": "kg",
                "task_count": 5
            },
            "herbicide_usage": {
                "total_amount": 75,
                "unit": "L",
                "task_count": 3
            },
            "fuel_usage": {
                "total_amount": 45,
                "unit": "L",
                "task_count": 2
            }
        },
        "task_analytics": {
            "total_tasks": 25,
            "in_progress": 8,
            "pending": 5,
            "rejected": 2,
            "completed": 10
        }
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/analytics/manager

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

location_id   integer  optional    

Filter analytics by location ID. Example: 1

start_date   string  optional    

date Filter analytics from this date. Example: 2025-01-01

end_date   string  optional    

date Filter analytics to this date. Example: 2025-01-31

task_type   string  optional    

Filter by task type (manuring/sanitation/pruning/harvesting/planting). Example: manuring

fertilizer_type   string  optional    

Filter by fertilizer type (NPK/MOP/BORATE/OTHER). Only applies when task_type=manuring. Example: NPK

sanitation_type   string  optional    

Filter by sanitation type (spraying/slashing). Only applies when task_type=sanitation. Example: spraying

Get detailed usage analytics with breakdown by location.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/usage-breakdown?start_date=2025-01-01&end_date=2025-01-31&task_type=manuring&fertilizer_type=NPK&sanitation_type=spraying" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/usage-breakdown"
);

const params = {
    "start_date": "2025-01-01",
    "end_date": "2025-01-31",
    "task_type": "manuring",
    "fertilizer_type": "NPK",
    "sanitation_type": "spraying",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/usage-breakdown';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'start_date' => '2025-01-01',
            'end_date' => '2025-01-31',
            'task_type' => 'manuring',
            'fertilizer_type' => 'NPK',
            'sanitation_type' => 'spraying',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/usage-breakdown'
params = {
  'start_date': '2025-01-01',
  'end_date': '2025-01-31',
  'task_type': 'manuring',
  'fertilizer_type': 'NPK',
  'sanitation_type': 'spraying',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "fertilizer_breakdown": [
            {
                "location_id": 1,
                "location_name": "A01",
                "total_amount": 50,
                "task_count": 2
            }
        ],
        "herbicide_breakdown": []
    }
}
 

Request      

GET api/v1/analytics/usage-breakdown

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

start_date   string  optional    

date Filter analytics from this date. Example: 2025-01-01

end_date   string  optional    

date Filter analytics to this date. Example: 2025-01-31

task_type   string  optional    

Filter by task type (manuring/sanitation). Example: manuring

fertilizer_type   string  optional    

Filter by fertilizer type (NPK/MOP/BORATE/OTHER). Only applies to fertilizer breakdown. Example: NPK

sanitation_type   string  optional    

Filter by sanitation type (spraying/slashing). Only applies to herbicide breakdown. Example: spraying

Get task completion analytics with monthly and yearly breakdowns.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/task-completion?year=2025&location_id=1&task_type=manuring" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/task-completion"
);

const params = {
    "year": "2025",
    "location_id": "1",
    "task_type": "manuring",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/task-completion';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'year' => '2025',
            'location_id' => '1',
            'task_type' => 'manuring',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/task-completion'
params = {
  'year': '2025',
  'location_id': '1',
  'task_type': 'manuring',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Monthly breakdown (year specified)):


{
    "success": true,
    "data": {
        "grouping": "monthly",
        "year": 2025,
        "total_completed": 750,
        "data": [
            {
                "month": 1,
                "month_name": "Jan",
                "count": 67
            },
            {
                "month": 2,
                "month_name": "Feb",
                "count": 59
            },
            {
                "month": 3,
                "month_name": "Mar",
                "count": 67
            },
            {
                "month": 4,
                "month_name": "Apr",
                "count": 56
            },
            {
                "month": 5,
                "month_name": "May",
                "count": 59
            },
            {
                "month": 6,
                "month_name": "Jun",
                "count": 69
            },
            {
                "month": 7,
                "month_name": "Jul",
                "count": 69
            },
            {
                "month": 8,
                "month_name": "Aug",
                "count": 65
            },
            {
                "month": 9,
                "month_name": "Sep",
                "count": 60
            },
            {
                "month": 10,
                "month_name": "Oct",
                "count": 65
            },
            {
                "month": 11,
                "month_name": "Nov",
                "count": 60
            },
            {
                "month": 12,
                "month_name": "Dec",
                "count": 60
            }
        ]
    }
}
 

Example response (200, Yearly breakdown (no year specified)):


{
    "success": true,
    "data": {
        "grouping": "yearly",
        "total_completed": 1500,
        "data": [
            {
                "year": 2023,
                "count": 450
            },
            {
                "year": 2024,
                "count": 550
            },
            {
                "year": 2025,
                "count": 500
            }
        ]
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/analytics/task-completion

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

year   integer  optional    

Filter by specific year. If not provided or "all", returns yearly breakdown. Example: 2025

location_id   integer  optional    

Filter analytics by location ID. Example: 1

task_type   string  optional    

Filter analytics by task type (manuring/sanitation/pruning/harvesting/planting). Example: manuring

Get task completion analytics by blocks (locations).

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-blocks?year=2025&month=3&week=15" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-blocks"
);

const params = {
    "year": "2025",
    "month": "3",
    "week": "15",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-blocks';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'year' => '2025',
            'month' => '3',
            'week' => '15',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-blocks'
params = {
  'year': '2025',
  'month': '3',
  'week': '15',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, By blocks (year filter)):


{
    "success": true,
    "data": {
        "filter": {
            "type": "year",
            "value": 2025
        },
        "total_completed": 240,
        "data": [
            {
                "location_id": 1,
                "location_name": "A01",
                "count": 15
            },
            {
                "location_id": 2,
                "location_name": "A02",
                "count": 20
            },
            {
                "location_id": 3,
                "location_name": "B01",
                "count": 25
            }
        ]
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/analytics/tasks-by-blocks

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

year   integer  optional    

Filter by year. Required when using month or week filter. Example: 2025

month   integer  optional    

Filter by month (1-12). Requires year. Example: 3

week   integer  optional    

Filter by week (1-53). Requires year. Example: 15

Get resource usage by task type.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/resource-usage?task_type=manuring&sanitation_type=spraying&start_date=2025-01-01&end_date=2025-12-31&location_id=1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/resource-usage"
);

const params = {
    "task_type": "manuring",
    "sanitation_type": "spraying",
    "start_date": "2025-01-01",
    "end_date": "2025-12-31",
    "location_id": "1",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/resource-usage';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'task_type' => 'manuring',
            'sanitation_type' => 'spraying',
            'start_date' => '2025-01-01',
            'end_date' => '2025-12-31',
            'location_id' => '1',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/resource-usage'
params = {
  'task_type': 'manuring',
  'sanitation_type': 'spraying',
  'start_date': '2025-01-01',
  'end_date': '2025-12-31',
  'location_id': '1',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success - Fertilizer Usage):


{
    "success": true,
    "data": {
        "resource_type": "fertilizer",
        "unit": "kg",
        "records": [
            {
                "date": "25/10/2025",
                "estate_officer": "Paul Don",
                "block": "A02",
                "amount": 20
            }
        ]
    }
}
 

Example response (200, Success - Herbicide Usage):


{
    "success": true,
    "data": {
        "resource_type": "herbicide",
        "unit": "liter",
        "records": [
            {
                "date": "25/10/2025",
                "estate_officer": "Paul Don",
                "block": "A02",
                "amount": 20
            }
        ]
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "task_type": [
            "The task type field is required."
        ]
    }
}
 

Request      

GET api/v1/analytics/resource-usage

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

task_type   string  optional    

Filter by task type. Required: manuring (fertilizer), sanitation (herbicide/fuel). Example: manuring

sanitation_type   string  optional    

Filter sanitation type (spraying/slashing). Required when task_type=sanitation. Example: spraying

start_date   string  optional    

date Filter from this date (YYYY-MM-DD). Example: 2025-01-01

end_date   string  optional    

date Filter to this date (YYYY-MM-DD). Example: 2025-12-31

location_id   integer  optional    

Filter by location ID. Example: 1

Get task completion analytics by Estate Officers (mandors).

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-mandors?year=2025&month=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-mandors"
);

const params = {
    "year": "2025",
    "month": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-mandors';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'year' => '2025',
            'month' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/tasks-by-mandors'
params = {
  'year': '2025',
  'month': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success - Monthly):


{
    "success": true,
    "data": {
        "period": "October 2025",
        "filter": {
            "type": "month",
            "year": 2025,
            "month": 10
        },
        "records": [
            {
                "estate_officer_id": 1,
                "estate_officer_name": "Paul Don",
                "team_task_completion": 28
            },
            {
                "estate_officer_id": 2,
                "estate_officer_name": "Martin Agus",
                "team_task_completion": 24
            }
        ]
    }
}
 

Example response (200, Success - Yearly):


{
    "success": true,
    "data": {
        "period": "2025",
        "filter": {
            "type": "year",
            "year": 2025
        },
        "records": [
            {
                "estate_officer_id": 1,
                "estate_officer_name": "Paul Don",
                "team_task_completion": 250
            }
        ]
    }
}
 

Request      

GET api/v1/analytics/tasks-by-mandors

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

year   integer  optional    

Filter by year. Required when using month filter. Example: 2025

month   integer  optional    

Filter by month (1-12). Requires year. Example: 10

Get attendance rate by Estate Officers (mandors).

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/attendance-by-mandors?year=2025&month=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/attendance-by-mandors"
);

const params = {
    "year": "2025",
    "month": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/attendance-by-mandors';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'year' => '2025',
            'month' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/attendance-by-mandors'
params = {
  'year': '2025',
  'month': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success - Monthly):


{
    "success": true,
    "data": {
        "period": "October 2025",
        "filter": {
            "type": "month",
            "year": 2025,
            "month": 10
        },
        "records": [
            {
                "estate_officer_id": 1,
                "estate_officer_name": "Adam Graham",
                "attendance_rate": 100
            },
            {
                "estate_officer_id": 2,
                "estate_officer_name": "Danial O",
                "attendance_rate": 100
            },
            {
                "estate_officer_id": 3,
                "estate_officer_name": "Martin Agus",
                "attendance_rate": 100
            },
            {
                "estate_officer_id": 4,
                "estate_officer_name": "Tunku Ibrahim",
                "attendance_rate": 98
            }
        ]
    }
}
 

Request      

GET api/v1/analytics/attendance-by-mandors

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

year   integer  optional    

Filter by year. Required when using month filter. Example: 2025

month   integer  optional    

Filter by month (1-12). Requires year. Example: 10

Get list of absent workers (staff) with their absent dates.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/absent-workers?year=2025&month=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/absent-workers"
);

const params = {
    "year": "2025",
    "month": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/absent-workers';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'year' => '2025',
            'month' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/absent-workers'
params = {
  'year': '2025',
  'month': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "period": "October 2025",
        "filter": {
            "type": "month",
            "year": 2025,
            "month": 10
        },
        "records": [
            {
                "staff_id": 1,
                "staff_name": "Ali bin Abu",
                "absent_dates": [
                    "2025-10-05",
                    "2025-10-12",
                    "2025-10-18"
                ],
                "total_absent_days": 3
            }
        ]
    }
}
 

Request      

GET api/v1/analytics/absent-workers

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

year   integer     

Filter by year. Example: 2025

month   integer     

Filter by month (1-12). Example: 10

Get audited summary grouped by payment rate categories.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/audited-summary?year=2025&month=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/audited-summary"
);

const params = {
    "year": "2025",
    "month": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/audited-summary';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'year' => '2025',
            'month' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/audited-summary'
params = {
  'year': '2025',
  'month': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "period": "October 2025",
        "filter": {
            "type": "month",
            "year": 2025,
            "month": 10
        },
        "summary": [
            {
                "category_id": 1,
                "category_name": "Normal Pruning",
                "task_type": "pruning",
                "task_name": "Pruning",
                "unit": "per palm",
                "total_value": 14,
                "recent_block": {
                    "location_id": 2,
                    "location_name": "A02",
                    "checked_by": "Ethan Muller",
                    "checked_at": "2025-10-13"
                }
            },
            {
                "category_id": 2,
                "category_name": "Routine Pruning",
                "task_type": "pruning",
                "task_name": "Pruning",
                "unit": "per acre",
                "total_value": 115.06999999999999317878973670303821563720703125,
                "recent_block": {
                    "location_id": 3,
                    "location_name": "C01",
                    "checked_by": "Ethan Muller",
                    "checked_at": "2025-10-24"
                }
            }
        ]
    }
}
 

Request      

GET api/v1/analytics/audited-summary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

year   integer  optional    

Filter by year. Example: 2025

month   integer  optional    

Filter by month (1-12). Example: 10

Get resources analytics including vehicles, car spare parts, and fuel data.

requires authentication

This endpoint provides comprehensive analytics for organizational resources with flexible time period filtering.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/resources-usage?period=month" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/resources-usage"
);

const params = {
    "period": "month",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/resources-usage';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'period' => 'month',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/resources-usage'
params = {
  'period': 'month',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success - Monthly Data (Default)):


{
    "success": true,
    "data": {
        "period": "month",
        "vehicle_analytics": {
            "total_vehicles": 25,
            "available": 18,
            "in_use": 5,
            "under_maintenance": 2,
            "bookings_trend": [
                {
                    "period": 1,
                    "period_label": "Jan",
                    "bookings": 12
                },
                {
                    "period": 2,
                    "period_label": "Feb",
                    "bookings": 19
                },
                {
                    "period": 3,
                    "period_label": "Mar",
                    "bookings": 14
                }
            ]
        },
        "tools_analytics": {
            "total_spare_parts": 78,
            "available": 60,
            "used": 18,
            "status_distribution": [
                {
                    "status": "Available",
                    "count": 60
                },
                {
                    "status": "Used",
                    "count": 18
                }
            ]
        },
        "fuel_analytics": {
            "remaining_fuel": 540,
            "total_fuel_bought": 1000,
            "total_fuel_used": 460,
            "fuel_usage_trend": [
                {
                    "period": 1,
                    "period_label": "Jan",
                    "fuel_used": 180,
                    "fuel_used_by_type": [
                        {
                            "fuel_type": "Petrol",
                            "fuel_used": 80
                        },
                        {
                            "fuel_type": "Diesel",
                            "fuel_used": 100
                        }
                    ]
                }
            ],
            "fuel_by_type": [
                {
                    "fuel_type": "Petrol",
                    "total_fuel_bought": 500,
                    "total_fuel_used": 300,
                    "remaining_fuel": 200
                }
            ]
        }
    }
}
 

Example response (200, Success - Daily Data):


{
    "success": true,
    "data": {
        "period": "day",
        "vehicle_analytics": {
            "total_vehicles": 25,
            "available": 18,
            "in_use": 5,
            "under_maintenance": 2,
            "bookings_trend": [
                {
                    "period": "2025-12-01",
                    "period_label": "Dec 01",
                    "bookings": 3
                },
                {
                    "period": "2025-12-02",
                    "period_label": "Dec 02",
                    "bookings": 5
                }
            ]
        },
        "tools_analytics": {
            "total_spare_parts": 78,
            "available": 60,
            "used": 18,
            "status_distribution": []
        },
        "fuel_analytics": {
            "remaining_fuel": 540,
            "total_fuel_bought": 1000,
            "total_fuel_used": 460,
            "fuel_usage_trend": [
                {
                    "period": "2025-12-01",
                    "period_label": "Dec 01",
                    "fuel_used": 15.5,
                    "fuel_used_by_type": []
                }
            ],
            "fuel_by_type": []
        }
    }
}
 

Example response (200, Success - Weekly Data):


{
    "success": true,
    "data": {
        "period": "week",
        "vehicle_analytics": {
            "total_vehicles": 25,
            "available": 18,
            "in_use": 5,
            "under_maintenance": 2,
            "bookings_trend": [
                {
                    "period": "2025-11-04",
                    "period_label": "Week 45",
                    "bookings": 18
                },
                {
                    "period": "2025-11-11",
                    "period_label": "Week 46",
                    "bookings": 22
                }
            ]
        },
        "tools_analytics": {},
        "fuel_analytics": {
            "remaining_fuel": 540,
            "total_fuel_bought": 1000,
            "total_fuel_used": 460,
            "fuel_usage_trend": [
                {
                    "period": "2025-11-04",
                    "period_label": "Week 45",
                    "fuel_used": 85.5,
                    "fuel_used_by_type": []
                }
            ],
            "fuel_by_type": []
        }
    }
}
 

Example response (200, Success - Yearly Data):


{
    "success": true,
    "data": {
        "period": "year",
        "vehicle_analytics": {
            "total_vehicles": 25,
            "available": 18,
            "in_use": 5,
            "under_maintenance": 2,
            "bookings_trend": [
                {
                    "period": 2021,
                    "period_label": "2021",
                    "bookings": 145
                },
                {
                    "period": 2022,
                    "period_label": "2022",
                    "bookings": 178
                },
                {
                    "period": 2023,
                    "period_label": "2023",
                    "bookings": 210
                },
                {
                    "period": 2024,
                    "period_label": "2024",
                    "bookings": 198
                },
                {
                    "period": 2025,
                    "period_label": "2025",
                    "bookings": 85
                }
            ]
        },
        "tools_analytics": {},
        "fuel_analytics": {
            "remaining_fuel": 540,
            "total_fuel_bought": 1000,
            "total_fuel_used": 460,
            "fuel_usage_trend": [
                {
                    "period": 2021,
                    "period_label": "2021",
                    "fuel_used": 2400,
                    "fuel_used_by_type": []
                }
            ],
            "fuel_by_type": []
        }
    }
}
 

Example response (400, Invalid Period):


{
    "success": false,
    "message": "Invalid period. Allowed values: day, week, month, year"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (500, Server Error):


{
  "success": false,
  "message": "Failed to fetch resources analytics.",
  "error": "Error message here"
}

## Response Data Structure

### Vehicle Analytics
- **total_vehicles**: Total number of vehicles in the system
- **available**: Number of vehicles with "Available" status
- **in_use**: Number of vehicles currently in use
- **under_maintenance**: Number of vehicles under maintenance
- **bookings_trend**: Array of booking counts for the selected time period

### Tools Analytics (Car Spare Parts)
- **total_spare_parts**: Total count of all spare parts/tools
- **available**: Spare parts not assigned to any vehicle (vehicle_id is null)
- **used**: Spare parts currently assigned to vehicles
- **status_distribution**: Breakdown for visualization (donut/pie charts)

### Fuel Analytics
- **remaining_fuel**: Total remaining fuel across all types (bought - used)
- **total_fuel_bought**: Sum of all fuel purchases
- **total_fuel_used**: Sum of all fuel consumption
- **fuel_usage_trend**: Fuel consumption trend for the selected period
  - Each entry includes breakdown by fuel type (Petrol, Diesel, Hydraulic Oils)
- **fuel_by_type**: Overall fuel statistics per fuel type

## Period Field Values

The `period` field in trend arrays varies by the selected time period:
- **day**: ISO date string (e.g., "2025-12-08")
- **week**: ISO date of week start (e.g., "2025-12-01")
- **month**: Month number 1-12
- **year**: Year number (e.g., 2025)

The `period_label` field provides human-readable labels:
- **day**: "Dec 08" (short month + day)
- **week**: "Week 49" (ISO week number)
- **month**: "Dec" (short month name)
- **year**: "2025" (year as string)
 

Request      

GET api/v1/analytics/resources-usage

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

period   string  optional    

Optional. Time period for trend data. Accepts: "day", "week", "month", "year".

  • day: Returns data for the last 30 days
  • week: Returns data for the last 12 weeks
  • month: Returns data for all 12 months of the current year (default)
  • year: Returns data for the last 5 years

Defaults to "month" if not specified. Example: month

Attendance

Get All Attendance Records

requires authentication

Retrieve a paginated list of all attendance records with optional month filtering.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/attendance?month=2025-01&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"month\": \"6425-59\",
    \"page\": 4,
    \"per_page\": 17
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/attendance"
);

const params = {
    "month": "2025-01",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "month": "6425-59",
    "page": 4,
    "per_page": 17
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/attendance';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
            'page' => '1',
            'per_page' => '10',
        ],
        'json' => [
            'month' => '6425-59',
            'page' => 4,
            'per_page' => 17,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/attendance'
payload = {
    "month": "6425-59",
    "page": 4,
    "per_page": 17
}
params = {
  'month': '2025-01',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "OK",
    "data": {
        "current_page": 1,
        "per_page": 15,
        "total": 75,
        "last_page": 5,
        "from": 1,
        "to": 15,
        "data": [
            {
                "id": 1,
                "date": "2025-01-15",
                "status": "active",
                "created_at": "2025-01-15T08:00:00.000000Z",
                "updated_at": "2025-01-15T08:00:00.000000Z"
            }
        ]
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/attendance

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

month   string  optional    

Filter attendance by month (format: YYYY-MM). Example: 2025-01

page   integer  optional    

Page number for pagination. Example: 1

per_page   integer  optional    

Number of records per page (default: 15). Example: 10

Body Parameters

month   string  optional    

Must match the regex /^\d{4}-\d{2}$/. Example: 6425-59

page   integer  optional    

Must be at least 1. Example: 4

per_page   integer  optional    

Must be at least 1. Must not be greater than 100. Example: 17

Check Date Attendance ID

requires authentication

Check if a date attendance record exists for the given date and return its ID.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/attendance/check?date=2025-01-15" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date\": \"2026-01-12T11:56:42\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/attendance/check"
);

const params = {
    "date": "2025-01-15",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date": "2026-01-12T11:56:42"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/attendance/check';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'date' => '2025-01-15',
        ],
        'json' => [
            'date' => '2026-01-12T11:56:42',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/attendance/check'
payload = {
    "date": "2026-01-12T11:56:42"
}
params = {
  'date': '2025-01-15',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Found):


{
    "success": true,
    "message": "Date attendance found",
    "data": {
        "id": 1,
        "date": "2025-01-15",
        "status": "active",
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (200, Not Found):


{
    "success": true,
    "message": "Date attendance ID does not exist yet",
    "data": null
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

POST api/v1/attendance/check

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

date   string     

The attendance date (YYYY-MM-DD format). Example: 2025-01-15

Body Parameters

date   string     

Must be a valid date. Example: 2026-01-12T11:56:42

Create New Attendance Date

requires authentication

Create a new date attendance record. Duplicate dates are not allowed.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/attendance" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date\": \"2025-01-15\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/attendance"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date": "2025-01-15"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/attendance';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date' => '2025-01-15',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/attendance'
payload = {
    "date": "2025-01-15"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Duplicate Date Error):


{
    "success": true,
    "message": "Date attendance already exists",
    "data": {
        "id": 1,
        "date": "2025-01-15",
        "status": "active",
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, Success):


{
    "success": true,
    "message": "Date attendance created successfully",
    "data": {
        "id": 1,
        "date": "2025-01-15",
        "status": "active",
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to manage attendance"
}
 

Request      

POST api/v1/attendance

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date   string     

The attendance date (YYYY-MM-DD format). Example: 2025-01-15

Delete Attendance Date (Set Status to Inactive)

requires authentication

Set the attendance date status to inactive instead of physically deleting the record.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/attendance/architecto" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/attendance/architecto"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/attendance/architecto';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/attendance/architecto'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
  "success": true,
  "message": "Date attendance deleted successfully",
}
 

Example response (200, Already Inactive):


{
    "success": true,
    "message": "Date attendance already inactive"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to manage attendance"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Date attendance not found"
}
 

Request      

DELETE api/v1/attendance/{attendance}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

attendance   string     

The attendance. Example: architecto

id   integer     

The ID of the attendance date. Example: 1

Authentication

Login

Authenticate a user and receive a Sanctum API token.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/auth/login" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"user_nickname\": \"johndoe\",
    \"password\": \"password123\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/auth/login"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "user_nickname": "johndoe",
    "password": "password123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/auth/login';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'user_nickname' => 'johndoe',
            'password' => 'password123',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/auth/login'
payload = {
    "user_nickname": "johndoe",
    "password": "password123"
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Successful login):


{
    "success": true,
    "message": "Logged in",
    "data": {
        "token": "1|abcdefghijklmnopqrstuvwxyz1234567890",
        "token_type": "Bearer",
        "user": {
            "id": 1,
            "user_nickname": "johndoe",
            "user_fullname": "John Doe",
            "user_role": "admin",
            "user_img": null,
            "user_phone": "+1234567890",
            "user_ic": "123456789012",
            "user_gender": "male",
            "user_dob": "1990-01-01",
            "user_employment_start_date": "2024-01-15",
            "user_bank_name": "Maybank",
            "user_bank_number": "1234567890",
            "user_kwsp_number": "1234567890"
        }
    }
}
 

Example response (401, Invalid credentials):


{
    "success": false,
    "message": "Invalid credentials"
}
 

Request      

POST api/v1/auth/login

Headers

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

user_nickname   string     

The user's nickname. Example: johndoe

password   string     

The user's password. Example: password123

Register

Register a new user account.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/auth/register" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"user_nickname\": \"johndoe\",
    \"user_fullname\": \"John Doe\",
    \"password\": \"password123\",
    \"user_role\": \"manager\",
    \"user_gender\": \"male\",
    \"user_dob\": \"1990-01-01\",
    \"user_employment_start_date\": \"2024-01-15\",
    \"user_phone\": \"+1234567890\",
    \"user_ic\": \"123456789012\",
    \"user_bank_name\": \"Maybank\",
    \"user_bank_number\": \"1234567890\",
    \"user_kwsp_number\": \"1234567890\",
    \"user_img\": \"https:\\/\\/example.com\\/image.jpg\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/auth/register"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "user_nickname": "johndoe",
    "user_fullname": "John Doe",
    "password": "password123",
    "user_role": "manager",
    "user_gender": "male",
    "user_dob": "1990-01-01",
    "user_employment_start_date": "2024-01-15",
    "user_phone": "+1234567890",
    "user_ic": "123456789012",
    "user_bank_name": "Maybank",
    "user_bank_number": "1234567890",
    "user_kwsp_number": "1234567890",
    "user_img": "https:\/\/example.com\/image.jpg"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/auth/register';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'user_nickname' => 'johndoe',
            'user_fullname' => 'John Doe',
            'password' => 'password123',
            'user_role' => 'manager',
            'user_gender' => 'male',
            'user_dob' => '1990-01-01',
            'user_employment_start_date' => '2024-01-15',
            'user_phone' => '+1234567890',
            'user_ic' => '123456789012',
            'user_bank_name' => 'Maybank',
            'user_bank_number' => '1234567890',
            'user_kwsp_number' => '1234567890',
            'user_img' => 'https://example.com/image.jpg',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/auth/register'
payload = {
    "user_nickname": "johndoe",
    "user_fullname": "John Doe",
    "password": "password123",
    "user_role": "manager",
    "user_gender": "male",
    "user_dob": "1990-01-01",
    "user_employment_start_date": "2024-01-15",
    "user_phone": "+1234567890",
    "user_ic": "123456789012",
    "user_bank_name": "Maybank",
    "user_bank_number": "1234567890",
    "user_kwsp_number": "1234567890",
    "user_img": "https:\/\/example.com\/image.jpg"
}
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Successful registration):


{
    "success": true,
    "message": "User registered successfully",
    "data": {
        "id": 1,
        "user_nickname": "johndoe",
        "user_fullname": "John Doe",
        "user_role": "manager",
        "user_img": null,
        "user_phone": "+1234567890",
        "user_ic": "123456789012",
        "user_gender": "male",
        "user_dob": "1990-01-01",
        "user_bank_name": "Maybank",
        "user_bank_number": "1234567890",
        "user_kwsp_number": "1234567890",
        "user_employment_start_date": "2024-01-15"
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "user_nickname": [
            "The user nickname has already been taken."
        ],
        "user_fullname": [
            "The user fullname has already been taken."
        ]
    }
}
 

Request      

POST api/v1/auth/register

Headers

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

user_nickname   string     

The user's nickname (must be unique). Example: johndoe

user_fullname   string     

The user's full name (must be unique). Example: John Doe

password   string     

The user's password. Example: password123

user_role   string     

The user's role. One of: admin, manager, checker, mandor. Example: manager

user_gender   string     

The user's gender. One of: male, female. Example: male

user_dob   string     

The user's date of birth (YYYY-MM-DD). Example: 1990-01-01

user_employment_start_date   string     

The user's employment start date (YYYY-MM-DD). Example: 2024-01-15

user_phone   string  optional    

nullable The user's phone number. Example: +1234567890

user_ic   string  optional    

nullable The user's IC number (must be unique if provided). Example: 123456789012

user_bank_name   string  optional    

nullable The user's bank name. Example: Maybank

user_bank_number   string  optional    

nullable The user's bank account number. Example: 1234567890

user_kwsp_number   string  optional    

nullable The user's KWSP number. Example: 1234567890

user_img   string|file  optional    

nullable The user's profile image URL or file upload. Example: https://example.com/image.jpg

Get Current User

requires authentication

Retrieve the currently authenticated user's information.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/profile" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/profile"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/profile';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/profile'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "OK",
    "data": {
        "id": 1,
        "user_nickname": "johndoe",
        "user_fullname": "John Doe",
        "user_role": "admin",
        "user_img": null,
        "user_phone": "+1234567890",
        "user_ic": "123456789012",
        "user_gender": "male",
        "user_dob": "1990-01-01",
        "user_bank_name": "Maybank",
        "user_bank_number": "1234567890",
        "user_kwsp_number": "1234567890",
        "user_employment_start_date": "2024-01-15",
        "attendance_count_month": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/profile

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Update User Profile

requires authentication

Update the currently authenticated user's profile information. Users can update their image, phone, password, and other profile fields.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/profile" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"user_fullname\": \"b\",
    \"user_nickname\": \"n\",
    \"user_phone\": \"+1234567890\",
    \"user_password\": \"password123\",
    \"user_role\": \"mandor\",
    \"user_gender\": \"male\",
    \"user_dob\": \"1990-01-01\",
    \"user_ic\": \"123456789012\",
    \"user_bank_name\": \"Maybank\",
    \"user_bank_number\": \"1234567890\",
    \"user_kwsp_number\": \"1234567890\",
    \"user_employment_start_date\": \"2024-01-15\",
    \"user_img\": \"https:\\/\\/example.com\\/image.jpg\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/profile"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "user_fullname": "b",
    "user_nickname": "n",
    "user_phone": "+1234567890",
    "user_password": "password123",
    "user_role": "mandor",
    "user_gender": "male",
    "user_dob": "1990-01-01",
    "user_ic": "123456789012",
    "user_bank_name": "Maybank",
    "user_bank_number": "1234567890",
    "user_kwsp_number": "1234567890",
    "user_employment_start_date": "2024-01-15",
    "user_img": "https:\/\/example.com\/image.jpg"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/profile';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'user_fullname' => 'b',
            'user_nickname' => 'n',
            'user_phone' => '+1234567890',
            'user_password' => 'password123',
            'user_role' => 'mandor',
            'user_gender' => 'male',
            'user_dob' => '1990-01-01',
            'user_ic' => '123456789012',
            'user_bank_name' => 'Maybank',
            'user_bank_number' => '1234567890',
            'user_kwsp_number' => '1234567890',
            'user_employment_start_date' => '2024-01-15',
            'user_img' => 'https://example.com/image.jpg',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/profile'
payload = {
    "user_fullname": "b",
    "user_nickname": "n",
    "user_phone": "+1234567890",
    "user_password": "password123",
    "user_role": "mandor",
    "user_gender": "male",
    "user_dob": "1990-01-01",
    "user_ic": "123456789012",
    "user_bank_name": "Maybank",
    "user_bank_number": "1234567890",
    "user_kwsp_number": "1234567890",
    "user_employment_start_date": "2024-01-15",
    "user_img": "https:\/\/example.com\/image.jpg"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User updated successfully",
    "data": {
        "id": 1,
        "user_nickname": "johndoe",
        "user_fullname": "John Doe",
        "user_img": "https://example.com/image.jpg",
        "user_phone": "+1234567890",
        "user_ic": "123456789012",
        "user_role": "admin",
        "user_gender": "male",
        "user_dob": "1990-01-01",
        "user_bank_name": "Maybank",
        "user_bank_number": "1234567890",
        "user_kwsp_number": "1234567890",
        "user_employment_start_date": "2024-01-15"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "user_nickname": [
            "The user nickname field is required."
        ]
    }
}
 

Request      

POST api/v1/profile

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

user_fullname   string  optional    

Must not be greater than 255 characters. Example: b

user_nickname   string  optional    

Must not be greater than 255 characters. Example: n

user_phone   string  optional    

nullable The user's phone number. Example: +1234567890

user_password   string  optional    

nullable The user's new password. Example: password123

user_role   string  optional    

Example: mandor

Must be one of:
  • admin
  • manager
  • checker
  • mandor
user_gender   string  optional    

Example: male

Must be one of:
  • male
  • female
user_dob   string  optional    

nullable The user's date of birth (YYYY-MM-DD). Example: 1990-01-01

user_ic   string  optional    

nullable The user's IC number (must be unique if provided). Example: 123456789012

user_bank_name   string  optional    

nullable The user's bank name. Example: Maybank

user_bank_number   string  optional    

nullable The user's bank account number. Example: 1234567890

user_kwsp_number   string  optional    

nullable The user's KWSP number. Example: 1234567890

user_employment_start_date   string  optional    

nullable The user's employment start date (YYYY-MM-DD). Example: 2024-01-15

user_img   string|file  optional    

nullable The user's profile image URL or file upload. Example: https://example.com/image.jpg

Logout

requires authentication

Revoke all API tokens for the authenticated user.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/auth/logout" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/auth/logout"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/auth/logout';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/auth/logout'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "OK",
    "data": "Logged out"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

POST api/v1/auth/logout

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Change Password

requires authentication

Allow the authenticated user to update their password after verifying the current password.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/auth/change-password" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"current_password\": \"architecto\",
    \"password\": \"|]|{+-\",
    \"password_confirmation\": \"architecto\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/auth/change-password"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "current_password": "architecto",
    "password": "|]|{+-",
    "password_confirmation": "architecto"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/auth/change-password';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'current_password' => 'architecto',
            'password' => '|]|{+-',
            'password_confirmation' => 'architecto',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/auth/change-password'
payload = {
    "current_password": "architecto",
    "password": "|]|{+-",
    "password_confirmation": "architecto"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Password updated successfully"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "current_password": [
            "The provided password does not match your current password."
        ]
    }
}
 

Request      

POST api/v1/auth/change-password

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

current_password   string     

The user's current password. Example: architecto

password   string     

The new password. Must be confirmed. Example: |]|{+-

password_confirmation   string     

The new password confirmation. Example: architecto

Car Spare Parts Management

Get all car spare parts.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tools?search=Brake+Pad&status=available&vehicle_id=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tools"
);

const params = {
    "search": "Brake Pad",
    "status": "available",
    "vehicle_id": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tools';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'Brake Pad',
            'status' => 'available',
            'vehicle_id' => '1',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tools'
params = {
  'search': 'Brake Pad',
  'status': 'available',
  'vehicle_id': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Spare parts retrieved successfully",
    "data": [
        {
            "id": 1,
            "name": "Brake Pad",
            "vehicle_id": null,
            "status": "available",
            "vehicle": null,
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        },
        {
            "id": 2,
            "name": "Oil Filter",
            "vehicle_id": 1,
            "status": "used",
            "vehicle": {
                "id": 1,
                "vehicle_name": "Toyota Hilux",
                "plate_number": "ABC1234",
                "status": "available"
            },
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/tools

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

optional Search by spare part name. Example: Brake Pad

status   string  optional    

optional Filter by status (available/used). Example: available

vehicle_id   integer  optional    

optional Filter by vehicle ID. Example: 1

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Store a newly created spare part.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tools" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"Brake Pad\",
    \"vehicle_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tools"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "Brake Pad",
    "vehicle_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tools';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'Brake Pad',
            'vehicle_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tools'
payload = {
    "name": "Brake Pad",
    "vehicle_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Spare part created successfully",
    "data": {
        "id": 1,
        "name": "Brake Pad",
        "vehicle_id": null,
        "status": "available",
        "vehicle": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

POST api/v1/tools

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

name   string     

The spare part name. Example: Brake Pad

vehicle_id   integer  optional    

optional The vehicle ID if installed. Example: 1

Display the specified spare part.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tools/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tools/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tools/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tools/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Spare part retrieved successfully",
    "data": {
        "id": 1,
        "name": "Brake Pad",
        "vehicle_id": null,
        "status": "available",
        "vehicle": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

GET api/v1/tools/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the tool. Example: 16

tool   integer     

The ID of the spare part. Example: 1

Update the specified spare part.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/tools/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"name\": \"Brake Pad\",
    \"vehicle_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tools/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "name": "Brake Pad",
    "vehicle_id": 1
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tools/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'name' => 'Brake Pad',
            'vehicle_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tools/16'
payload = {
    "name": "Brake Pad",
    "vehicle_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Spare part updated successfully",
    "data": {
        "id": 1,
        "name": "Brake Pad",
        "vehicle_id": 1,
        "status": "used",
        "vehicle": {
            "id": 1,
            "vehicle_name": "Toyota Hilux",
            "plate_number": "ABC1234",
            "status": "available",
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        },
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

PUT api/v1/tools/{id}

PATCH api/v1/tools/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the tool. Example: 16

tool   integer     

The ID of the spare part. Example: 1

Body Parameters

name   string  optional    

optional The spare part name. Example: Brake Pad

vehicle_id   integer  optional    

optional The vehicle ID if installed. Example: 1

Remove the specified spare part.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/tools/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tools/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tools/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tools/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Spare part deleted successfully"
}
 

Request      

DELETE api/v1/tools/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the tool. Example: 16

tool   integer     

The ID of the spare part. Example: 1

Checker Analytics

Get Checker Analytics Overview Retrieves analytics data for checkers including task counts and absent people statistics. Only accessible by users with 'checker' role.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/checker" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/checker"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/checker';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/checker'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):


{
    "success": true,
    "message": "Analytics retrieved successfully",
    "data": {
        "pending_task_count": 5,
        "complete_task_count": 12,
        "absent_people_count": 3,
        "payroll_date": "2025-10-16",
        "time_until_payroll": 10
    }
}
 

Example response (401):


{
    "success": false,
    "message": "Unauthenticated"
}
 

Example response (403):


{
    "success": false,
    "message": "You are not authorized to access this resource"
}
 

Request      

GET api/v1/analytics/checker

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Get Pending Tasks for Checker Retrieves a list of pending tasks. Only accessible by users with 'checker' role.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/analytics/checker/pending-tasks" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/analytics/checker/pending-tasks"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/analytics/checker/pending-tasks';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/analytics/checker/pending-tasks'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200):


{
    "success": true,
    "message": "Pending tasks retrieved successfully",
    "data": [
        {
            "id": 1,
            "task_name": "Sample Task",
            "task_description": "Task description here",
            "task_status": "pending",
            "created_by": 1,
            "created_at": "2024-01-01T00:00:00.000000Z",
            "updated_at": "2024-01-01T00:00:00.000000Z"
        }
    ]
}
 

Example response (401):


{
    "success": false,
    "message": "Unauthenticated"
}
 

Example response (403):


{
    "success": false,
    "message": "You are not authorized to access this resource"
}
 

Request      

GET api/v1/analytics/checker/pending-tasks

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Endpoints

Temporary File Access (Public, Signed URL)

Serve a file via a temporary signed URL without requiring authentication. This route is public but protected by signature verification.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/files/temporary/|{+-0p" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/temporary/|{+-0p"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/temporary/|{+-0p';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/temporary/|{+-0p'
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (403):

Show headers
cache-control: no-cache, private
content-type: application/json
access-control-allow-origin: *
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS, PATCH
access-control-allow-headers: Content-Type, Authorization, X-Requested-With, Accept, Origin, X-CSRF-TOKEN
access-control-allow-credentials: true
 

{
    "success": false,
    "message": "Invalid signature.",
    "status_code": 403
}
 

Request      

GET api/v1/files/temporary/{path}

Headers

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

path   string     

Example: |{+-0p

File Transfer Management

Upload Single File

requires authentication

Upload a single file to the file storage system with optional directory and metadata. Supports various file types including documents, images, and videos.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/files/upload" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: multipart/form-data" \
    --header "Accept: application/json" \
    --form "directory=uploads/documents"\
    --form "metadata[description]=Important document"\
    --form "metadata[category]=legal"\
    --form "file=@/tmp/php2icvk6" 
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/upload"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "multipart/form-data",
    "Accept": "application/json",
};

const body = new FormData();
body.append('directory', 'uploads/documents');
body.append('metadata[description]', 'Important document');
body.append('metadata[category]', 'legal');
body.append('file', document.querySelector('input[name="file"]').files[0]);

fetch(url, {
    method: "POST",
    headers,
    body,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/upload';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'multipart/form-data',
            'Accept' => 'application/json',
        ],
        'multipart' => [
            [
                'name' => 'directory',
                'contents' => 'uploads/documents'
            ],
            [
                'name' => 'metadata[description]',
                'contents' => 'Important document'
            ],
            [
                'name' => 'metadata[category]',
                'contents' => 'legal'
            ],
            [
                'name' => 'file',
                'contents' => fopen('/tmp/php2icvk6', 'r')
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/upload'
files = {
  'directory': (None, 'uploads/documents'),
  'metadata[description]': (None, 'Important document'),
  'metadata[category]': (None, 'legal'),
  'file': open('/tmp/php2icvk6', 'rb')}
payload = {
    "directory": "uploads\/documents",
    "metadata[description]": "Important document",
    "metadata[category]": "legal"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'multipart/form-data',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, files=files)
response.json()

Example response (201, Successful upload):


{
    "success": true,
    "message": "File uploaded successfully",
    "data": {
        "path": "uploads/documents/document_20250115_123456.pdf",
        "name": "document.pdf",
        "size": 1024000,
        "mime_type": "application/pdf",
        "url": "https://example.com/storage/uploads/documents/document_20250115_123456.pdf",
        "metadata": {
            "description": "Important document",
            "category": "legal"
        }
    }
}
 

Example response (400, Upload failed):


{
    "success": false,
    "message": "File upload failed",
    "errors": [
        "Insufficient storage space"
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "file": [
            "The file field is required."
        ],
        "file.0": [
            "The file must not be greater than 10240 kilobytes."
        ]
    }
}
 

Request      

POST api/v1/files/upload

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: multipart/form-data

Accept        

Example: application/json

Body Parameters

file   file     

The file to upload (max 100MB). Example: /tmp/php2icvk6

directory   string  optional    

nullable Target directory for the file. Example: uploads/documents

metadata   object  optional    
metadata[description]   string  optional    

nullable Description of the file. Example: Important document

metadata[category]   string  optional    

nullable Category of the file. Example: legal

Upload Multiple Files

requires authentication

Upload multiple files to the file storage system with optional directory and metadata. Maximum 10 files per request, each file limited to 100MB. Supports various file types including documents, images, and videos.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/files/upload-multiple" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"files\": null,
    \"directory\": \"uploads\\/batch\",
    \"metadata[batch_id]\": \"batch_001\",
    \"metadata[uploaded_by]\": \"user123\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/upload-multiple"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "files": null,
    "directory": "uploads\/batch",
    "metadata[batch_id]": "batch_001",
    "metadata[uploaded_by]": "user123"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/upload-multiple';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'files' => null,
            'directory' => 'uploads/batch',
            'metadata[batch_id]' => 'batch_001',
            'metadata[uploaded_by]' => 'user123',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/upload-multiple'
payload = {
    "files": null,
    "directory": "uploads\/batch",
    "metadata[batch_id]": "batch_001",
    "metadata[uploaded_by]": "user123"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Successful upload):


{
    "success": true,
    "message": "Files uploaded successfully",
    "data": {
        "uploaded_files": [
            {
                "path": "uploads/batch/document_20250115_123456.pdf",
                "name": "document.pdf",
                "size": 1024000,
                "mime_type": "application/pdf",
                "url": "https://example.com/storage/uploads/batch/document_20250115_123456.pdf"
            },
            {
                "path": "uploads/batch/image_20250115_123457.jpg",
                "name": "image.jpg",
                "size": 512000,
                "mime_type": "image/jpeg",
                "url": "https://example.com/storage/uploads/batch/image_20250115_123457.jpg"
            }
        ],
        "total_files": 2,
        "total_size": 1536000,
        "metadata": {
            "batch_id": "batch_001",
            "uploaded_by": "user123"
        }
    }
}
 

Example response (400, Upload failed):


{
    "success": false,
    "message": "Files upload failed",
    "errors": [
        "Some files failed to upload"
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "files": [
            "The files field is required."
        ],
        "files.0": [
            "The files.0 must not be greater than 10240 kilobytes."
        ]
    }
}
 

Request      

POST api/v1/files/upload-multiple

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

files   string[]     

Array of files to upload (max 10 files).

*   file     

Each file in the array (max 100MB per file). Example: /tmp/phpX8lNBC

directory   string  optional    

nullable Target directory for the files. Example: uploads/batch

metadata   object  optional    
metadata[batch_id]   string  optional    

nullable Batch ID for the files. Example: batch_001

metadata[uploaded_by]   string  optional    

nullable User who uploaded the files. Example: user123

Download File

requires authentication

Download a file from the storage system. Returns the file as a streamed response.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/files/download?path=uploads%2Fdocuments%2Fdocument.pdf&download_name=my_document.pdf" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"path\": \"architecto\",
    \"download_name\": \"n\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/download"
);

const params = {
    "path": "uploads/documents/document.pdf",
    "download_name": "my_document.pdf",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "path": "architecto",
    "download_name": "n"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/download';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'path' => 'uploads/documents/document.pdf',
            'download_name' => 'my_document.pdf',
        ],
        'json' => [
            'path' => 'architecto',
            'download_name' => 'n',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/download'
payload = {
    "path": "architecto",
    "download_name": "n"
}
params = {
  'path': 'uploads/documents/document.pdf',
  'download_name': 'my_document.pdf',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Successful download):


{
    "file": "Binary file content"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, File not found):


{
    "success": false,
    "message": "File not found",
    "errors": [
        "The specified file does not exist"
    ]
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "path": [
            "The path field is required."
        ]
    }
}
 

Request      

GET api/v1/files/download

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

path   string     

The path to the file to download. Example: uploads/documents/document.pdf

download_name   string  optional    

nullable Custom name for the downloaded file. Example: my_document.pdf

Body Parameters

path   string     

Example: architecto

download_name   string  optional    

Must not be greater than 255 characters. Example: n

Get File URL

requires authentication

Get a public URL for accessing a file without downloading it.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/files/url?path=uploads%2Fdocuments%2Fdocument.pdf" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"path\": \"architecto\",
    \"expires\": 22
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/url"
);

const params = {
    "path": "uploads/documents/document.pdf",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "path": "architecto",
    "expires": 22
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/url';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'path' => 'uploads/documents/document.pdf',
        ],
        'json' => [
            'path' => 'architecto',
            'expires' => 22,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/url'
payload = {
    "path": "architecto",
    "expires": 22
}
params = {
  'path': 'uploads/documents/document.pdf',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "File URL retrieved successfully",
    "data": {
        "url": "https://example.com/storage/uploads/documents/document.pdf",
        "path": "uploads/documents/document.pdf",
        "expires_at": "2025-01-16T12:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, File not found):


{
    "success": false,
    "message": "File not found",
    "errors": [
        "The specified file does not exist"
    ]
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "path": [
            "The path field is required."
        ]
    }
}
 

Request      

GET api/v1/files/url

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

path   string     

The path to the file. Example: uploads/documents/document.pdf

Body Parameters

path   string     

Example: architecto

expires   integer  optional    

Must be at least 1. Must not be greater than 43200. Example: 22

Delete File

requires authentication

Delete a file from the storage system.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/files/delete" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"path\": \"uploads\\/documents\\/document.pdf\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/delete"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "path": "uploads\/documents\/document.pdf"
};

fetch(url, {
    method: "DELETE",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/delete';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'path' => 'uploads/documents/document.pdf',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/delete'
payload = {
    "path": "uploads\/documents\/document.pdf"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "File deleted successfully",
    "data": {
        "path": "uploads/documents/document.pdf",
        "deleted_at": "2025-01-15T12:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, File not found):


{
    "success": false,
    "message": "File not found",
    "errors": [
        "The specified file does not exist"
    ]
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "path": [
            "The path field is required."
        ]
    }
}
 

Request      

DELETE api/v1/files/delete

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

path   string     

The path to the file to delete. Example: uploads/documents/document.pdf

List Files

requires authentication

List all files in a directory with optional recursive search.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/files/list?directory=uploads%2Fdocuments&recursive=1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"directory\": \"b\",
    \"recursive\": false
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/list"
);

const params = {
    "directory": "uploads/documents",
    "recursive": "1",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "directory": "b",
    "recursive": false
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/list';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'directory' => 'uploads/documents',
            'recursive' => '1',
        ],
        'json' => [
            'directory' => 'b',
            'recursive' => false,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/list'
payload = {
    "directory": "b",
    "recursive": false
}
params = {
  'directory': 'uploads/documents',
  'recursive': '1',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Files listed successfully",
    "data": {
        "files": [
            {
                "name": "document.pdf",
                "path": "uploads/documents/document.pdf",
                "size": 1024000,
                "mime_type": "application/pdf",
                "url": "https://example.com/storage/uploads/documents/document.pdf",
                "created_at": "2025-01-15T10:00:00.000000Z",
                "modified_at": "2025-01-15T10:00:00.000000Z"
            },
            {
                "name": "image.jpg",
                "path": "uploads/documents/image.jpg",
                "size": 512000,
                "mime_type": "image/jpeg",
                "url": "https://example.com/storage/uploads/documents/image.jpg",
                "created_at": "2025-01-15T11:00:00.000000Z",
                "modified_at": "2025-01-15T11:00:00.000000Z"
            }
        ],
        "directory": "uploads/documents",
        "total_files": 2,
        "total_size": 1536000
    }
}
 

Example response (400, Error):


{
    "success": false,
    "message": "Failed to list files",
    "errors": [
        "Directory access denied"
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "recursive": [
            "The recursive field must be true or false."
        ]
    }
}
 

Request      

GET api/v1/files/list

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

directory   string  optional    

nullable Directory to list files from. Example: uploads/documents

recursive   boolean  optional    

nullable Whether to search subdirectories recursively. Example: true

Body Parameters

directory   string  optional    

Must not be greater than 255 characters. Example: b

recursive   boolean  optional    

Example: false

Move File

requires authentication

Move or rename a file from one location to another.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/files/move" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"uploads\\/documents\\/old_name.pdf\",
    \"to\": \"uploads\\/archive\\/new_name.pdf\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/move"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "from": "uploads\/documents\/old_name.pdf",
    "to": "uploads\/archive\/new_name.pdf"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/move';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'from' => 'uploads/documents/old_name.pdf',
            'to' => 'uploads/archive/new_name.pdf',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/move'
payload = {
    "from": "uploads\/documents\/old_name.pdf",
    "to": "uploads\/archive\/new_name.pdf"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "File moved successfully",
    "data": {
        "from": "uploads/documents/old_name.pdf",
        "to": "uploads/archive/new_name.pdf",
        "moved_at": "2025-01-15T12:00:00.000000Z"
    }
}
 

Example response (400, Move failed):


{
    "success": false,
    "message": "File move failed",
    "errors": [
        "Source file not found",
        "Destination already exists"
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "from": [
            "The from field is required."
        ],
        "to": [
            "The to field is required."
        ]
    }
}
 

Request      

PUT api/v1/files/move

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

from   string     

Current path of the file. Example: uploads/documents/old_name.pdf

to   string     

New path for the file. Example: uploads/archive/new_name.pdf

Copy File

requires authentication

Create a copy of a file at a new location.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/files/copy" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"from\": \"uploads\\/documents\\/original.pdf\",
    \"to\": \"uploads\\/backup\\/copy_of_original.pdf\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/copy"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "from": "uploads\/documents\/original.pdf",
    "to": "uploads\/backup\/copy_of_original.pdf"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/copy';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'from' => 'uploads/documents/original.pdf',
            'to' => 'uploads/backup/copy_of_original.pdf',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/copy'
payload = {
    "from": "uploads\/documents\/original.pdf",
    "to": "uploads\/backup\/copy_of_original.pdf"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "File copied successfully",
    "data": {
        "from": "uploads/documents/original.pdf",
        "to": "uploads/backup/copy_of_original.pdf",
        "copied_at": "2025-01-15T12:00:00.000000Z",
        "original_size": 1024000,
        "copy_size": 1024000
    }
}
 

Example response (400, Copy failed):


{
    "success": false,
    "message": "File copy failed",
    "errors": [
        "Source file not found",
        "Destination already exists"
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "from": [
            "The from field is required."
        ],
        "to": [
            "The to field is required."
        ]
    }
}
 

Request      

POST api/v1/files/copy

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

from   string     

Source path of the file to copy. Example: uploads/documents/original.pdf

to   string     

Destination path for the copy. Example: uploads/backup/copy_of_original.pdf

Get File Information

requires authentication

Retrieve detailed information about a specific file.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/files/info?path=uploads%2Fdocuments%2Fdocument.pdf" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"path\": \"architecto\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/info"
);

const params = {
    "path": "uploads/documents/document.pdf",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "path": "architecto"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/info';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'path' => 'uploads/documents/document.pdf',
        ],
        'json' => [
            'path' => 'architecto',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/info'
payload = {
    "path": "architecto"
}
params = {
  'path': 'uploads/documents/document.pdf',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "File information retrieved successfully",
    "data": {
        "name": "document.pdf",
        "path": "uploads/documents/document.pdf",
        "size": 1024000,
        "mime_type": "application/pdf",
        "url": "https://example.com/storage/uploads/documents/document.pdf",
        "created_at": "2025-01-15T10:00:00.000000Z",
        "modified_at": "2025-01-15T10:00:00.000000Z",
        "is_readable": true,
        "is_writable": true,
        "permissions": "0644"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, File not found):


{
    "success": false,
    "message": "File not found",
    "errors": [
        "The specified file does not exist"
    ]
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "path": [
            "The path field is required."
        ]
    }
}
 

Request      

GET api/v1/files/info

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

path   string     

The path to the file. Example: uploads/documents/document.pdf

Body Parameters

path   string     

Example: architecto

Get Service Configuration

requires authentication

Retrieve the current configuration settings for the file transfer service.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/files/config" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/config"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/config';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/config'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Configuration retrieved successfully",
    "data": {
        "allowed_mime_types": [
            "application/pdf",
            "image/jpeg",
            "image/png",
            "text/plain"
        ],
        "max_file_size": 10485760,
        "storage_driver": "local",
        "base_directory": "storage/app/public",
        "url_prefix": "storage"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/files/config

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Update Service Configuration

requires authentication

Update the configuration settings for the file transfer service.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/files/config" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"allowed_mime_types\": [
        \"application\\/pdf\",
        \"image\\/jpeg\",
        \"image\\/png\"
    ],
    \"max_file_size\": 10485760
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/files/config"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "allowed_mime_types": [
        "application\/pdf",
        "image\/jpeg",
        "image\/png"
    ],
    "max_file_size": 10485760
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/files/config';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'allowed_mime_types' => [
                'application/pdf',
                'image/jpeg',
                'image/png',
            ],
            'max_file_size' => 10485760,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/files/config'
payload = {
    "allowed_mime_types": [
        "application\/pdf",
        "image\/jpeg",
        "image\/png"
    ],
    "max_file_size": 10485760
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Configuration updated successfully",
    "data": {
        "allowed_mime_types": [
            "application/pdf",
            "image/jpeg",
            "image/png"
        ],
        "max_file_size": 10485760,
        "storage_driver": "local",
        "base_directory": "storage/app/public",
        "url_prefix": "storage",
        "updated_at": "2025-01-15T12:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "max_file_size": [
            "The max file size must be between 1024 and 104857600."
        ],
        "allowed_mime_types.0": [
            "The allowed mime types.0 must be a string."
        ]
    }
}
 

Request      

PUT api/v1/files/config

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

allowed_mime_types   string[]  optional    

nullable Array of allowed MIME types.

*   string  optional    

nullable Each MIME type in the array. Example: application/pdf

max_file_size   integer  optional    

nullable Maximum file size in bytes (1KB to 100MB). Example: 10485760

Fuel Management

Get all fuel records.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/fuels?search=Petronas&user_id=1&fuel_type=Petrol&date_from=2025-01-01&date_to=2025-01-31&fuelFilter=fuel-desc&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuels"
);

const params = {
    "search": "Petronas",
    "user_id": "1",
    "fuel_type": "Petrol",
    "date_from": "2025-01-01",
    "date_to": "2025-01-31",
    "fuelFilter": "fuel-desc",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuels';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'Petronas',
            'user_id' => '1',
            'fuel_type' => 'Petrol',
            'date_from' => '2025-01-01',
            'date_to' => '2025-01-31',
            'fuelFilter' => 'fuel-desc',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuels'
params = {
  'search': 'Petronas',
  'user_id': '1',
  'fuel_type': 'Petrol',
  'date_from': '2025-01-01',
  'date_to': '2025-01-31',
  'fuelFilter': 'fuel-desc',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel records retrieved successfully",
    "data": [
        {
            "id": 1,
            "supplier_name": "Petronas",
            "fuel_bought": "50.00",
            "date_bought": "2025-01-01",
            "user_id": 1,
            "user": {
                "id": 1,
                "user_fullname": "John Doe"
            },
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/fuels

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

optional Search across all fields. Example: Petronas

user_id   integer  optional    

optional Filter by user ID. Example: 1

fuel_type   string  optional    

optional Filter by fuel type. One of: Petrol, Diesel, Hydraulic Oil 10, Hydraulic Oil 40, Hydraulic Oil 68, Hydraulic Oil 90. Example: Petrol

date_from   string  optional    

optional Filter from date (YYYY-MM-DD). Example: 2025-01-01

date_to   string  optional    

optional Filter to date (YYYY-MM-DD). Example: 2025-01-31

fuelFilter   string  optional    

optional Sort order: fuel-asc, fuel-desc, date-asc, date-desc. Example: fuel-desc

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Store a newly created fuel record.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/fuels" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"supplier_name\": \"Petronas\",
    \"fuel_bought\": 50,
    \"fuel_type\": \"Petrol\",
    \"date_bought\": \"2025-01-01\",
    \"user_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuels"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "supplier_name": "Petronas",
    "fuel_bought": 50,
    "fuel_type": "Petrol",
    "date_bought": "2025-01-01",
    "user_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuels';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'supplier_name' => 'Petronas',
            'fuel_bought' => 50.0,
            'fuel_type' => 'Petrol',
            'date_bought' => '2025-01-01',
            'user_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuels'
payload = {
    "supplier_name": "Petronas",
    "fuel_bought": 50,
    "fuel_type": "Petrol",
    "date_bought": "2025-01-01",
    "user_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Fuel record created successfully",
    "data": {
        "id": 1,
        "supplier_name": "Petronas",
        "fuel_bought": "50.00",
        "date_bought": "2025-01-01",
        "user_id": 1,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

POST api/v1/fuels

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

supplier_name   string     

The supplier name. Example: Petronas

fuel_bought   number     

The amount of fuel bought. Example: 50

fuel_type   string     

The type of fuel. One of: Petrol, Diesel, Hydraulic Oil 10, Hydraulic Oil 40, Hydraulic Oil 68, Hydraulic Oil 90. Example: Petrol

date_bought   string     

The purchase date (YYYY-MM-DD). Example: 2025-01-01

user_id   integer  optional    

optional The user ID who recorded this. Example: 1

Display the specified fuel record.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/fuels/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuels/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuels/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuels/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel record retrieved successfully",
    "data": {
        "id": 1,
        "supplier_name": "Petronas",
        "fuel_bought": "50.00",
        "date_bought": "2025-01-01",
        "user_id": 1,
        "user": {
            "id": 1,
            "user_fullname": "John Doe"
        },
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

GET api/v1/fuels/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the fuel. Example: 16

fuel   integer     

The ID of the fuel record. Example: 1

Update the specified fuel record.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/fuels/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"supplier_name\": \"Petronas\",
    \"fuel_bought\": 50,
    \"fuel_type\": \"Petrol\",
    \"date_bought\": \"2025-01-01\",
    \"user_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuels/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "supplier_name": "Petronas",
    "fuel_bought": 50,
    "fuel_type": "Petrol",
    "date_bought": "2025-01-01",
    "user_id": 1
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuels/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'supplier_name' => 'Petronas',
            'fuel_bought' => 50.0,
            'fuel_type' => 'Petrol',
            'date_bought' => '2025-01-01',
            'user_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuels/16'
payload = {
    "supplier_name": "Petronas",
    "fuel_bought": 50,
    "fuel_type": "Petrol",
    "date_bought": "2025-01-01",
    "user_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel record updated successfully",
    "data": {
        "id": 1,
        "supplier_name": "Petronas",
        "fuel_bought": "50.00",
        "date_bought": "2025-01-01",
        "user_id": 1,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

PUT api/v1/fuels/{id}

PATCH api/v1/fuels/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the fuel. Example: 16

fuel   integer     

The ID of the fuel record. Example: 1

Body Parameters

supplier_name   string  optional    

optional The supplier name. Example: Petronas

fuel_bought   number  optional    

optional The amount of fuel bought. Example: 50

fuel_type   string  optional    

optional The type of fuel. One of: Petrol, Diesel, Hydraulic Oil 10, Hydraulic Oil 40, Hydraulic Oil 68, Hydraulic Oil 90. Example: Petrol

date_bought   string  optional    

optional The purchase date (YYYY-MM-DD). Example: 2025-01-01

user_id   integer  optional    

optional The user ID who recorded this. Example: 1

Remove the specified fuel record.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/fuels/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuels/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuels/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuels/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel record deleted successfully"
}
 

Request      

DELETE api/v1/fuels/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the fuel. Example: 16

fuel   integer     

The ID of the fuel record. Example: 1

Fuel Usage Management

Get all fuel usage records.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/fuel-usages?search=vehicle+1&user_id=1&staff_id=1&vehicle_id=1&fuel_type=Petrol&date_from=2025-01-01&date_to=2025-01-31&usageFilter=date-asc&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuel-usages"
);

const params = {
    "search": "vehicle 1",
    "user_id": "1",
    "staff_id": "1",
    "vehicle_id": "1",
    "fuel_type": "Petrol",
    "date_from": "2025-01-01",
    "date_to": "2025-01-31",
    "usageFilter": "date-asc",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'vehicle 1',
            'user_id' => '1',
            'staff_id' => '1',
            'vehicle_id' => '1',
            'fuel_type' => 'Petrol',
            'date_from' => '2025-01-01',
            'date_to' => '2025-01-31',
            'usageFilter' => 'date-asc',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages'
params = {
  'search': 'vehicle 1',
  'user_id': '1',
  'staff_id': '1',
  'vehicle_id': '1',
  'fuel_type': 'Petrol',
  'date_from': '2025-01-01',
  'date_to': '2025-01-31',
  'usageFilter': 'date-asc',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel usage records retrieved successfully",
    "data": [
        {
            "id": 1,
            "usage_quantity": "10.00",
            "usage_date": "2025-01-01",
            "usage_description": "Used in vehicle 1",
            "user_id": 1,
            "staff_id": null,
            "user": {
                "id": 1,
                "user_fullname": "John Doe"
            },
            "staff": null,
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/fuel-usages

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

optional Search across usage dates, descriptions, quantities, user names, and staff names. Example: vehicle 1

user_id   integer  optional    

optional Filter by user ID. Example: 1

staff_id   integer  optional    

optional Filter by staff ID. Example: 1

vehicle_id   integer  optional    

optional Filter by vehicle ID. Example: 1

fuel_type   string  optional    

optional Filter by fuel type. One of: Petrol, Diesel, Hydraulic Oil 10, Hydraulic Oil 40, Hydraulic Oil 68, Hydraulic Oil 90. Example: Petrol

date_from   string  optional    

optional Filter from date (YYYY-MM-DD). Example: 2025-01-01

date_to   string  optional    

optional Filter to date (YYYY-MM-DD). Example: 2025-01-31

usageFilter   string  optional    

optional Sort by date or quantity. Options: date-asc, date-desc, quantity-asc, quantity-desc. Defaults to date-desc. Example: date-asc

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Store a newly created fuel usage record.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/fuel-usages" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"usage_quantity\": 10,
    \"fuel_type\": \"Petrol\",
    \"usage_date\": \"2025-01-01\",
    \"usage_description\": \"Used for field work\",
    \"user_id\": 1,
    \"staff_id\": 1,
    \"vehicle_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuel-usages"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "usage_quantity": 10,
    "fuel_type": "Petrol",
    "usage_date": "2025-01-01",
    "usage_description": "Used for field work",
    "user_id": 1,
    "staff_id": 1,
    "vehicle_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'usage_quantity' => 10.0,
            'fuel_type' => 'Petrol',
            'usage_date' => '2025-01-01',
            'usage_description' => 'Used for field work',
            'user_id' => 1,
            'staff_id' => 1,
            'vehicle_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages'
payload = {
    "usage_quantity": 10,
    "fuel_type": "Petrol",
    "usage_date": "2025-01-01",
    "usage_description": "Used for field work",
    "user_id": 1,
    "staff_id": 1,
    "vehicle_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Fuel usage record created successfully",
    "data": {
        "id": 1,
        "usage_quantity": "10.00",
        "usage_date": "2025-01-01",
        "usage_description": "Used for field work",
        "user_id": 1,
        "staff_id": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

POST api/v1/fuel-usages

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

usage_quantity   number     

The quantity of fuel used. Example: 10

fuel_type   string     

The type of fuel used. One of: Petrol, Diesel, Hydraulic Oil 10, Hydraulic Oil 40, Hydraulic Oil 68, Hydraulic Oil 90. Example: Petrol

usage_date   string     

The usage date (YYYY-MM-DD). Example: 2025-01-01

usage_description   string  optional    

optional Description of the usage. Example: Used for field work

user_id   integer  optional    

optional The user ID who recorded this. Example: 1

staff_id   integer  optional    

optional The staff ID associated with this usage. Example: 1

vehicle_id   integer  optional    

optional The vehicle ID associated with this usage. Example: 1

Display the specified fuel usage record.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/fuel-usages/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuel-usages/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel usage record retrieved successfully",
    "data": {
        "id": 1,
        "usage_quantity": "10.00",
        "usage_date": "2025-01-01",
        "usage_description": "Used for field work",
        "user_id": 1,
        "staff_id": null,
        "user": {
            "id": 1,
            "user_fullname": "John Doe"
        },
        "staff": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

GET api/v1/fuel-usages/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the fuel usage. Example: 16

fuelUsage   integer     

The ID of the fuel usage record. Example: 1

Update the specified fuel usage record.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/fuel-usages/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"usage_quantity\": 10,
    \"usage_date\": \"2025-01-01\",
    \"usage_description\": \"Used for field work\",
    \"user_id\": 1,
    \"staff_id\": 1,
    \"vehicle_id\": 1,
    \"fuel_type\": \"petrol\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuel-usages/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "usage_quantity": 10,
    "usage_date": "2025-01-01",
    "usage_description": "Used for field work",
    "user_id": 1,
    "staff_id": 1,
    "vehicle_id": 1,
    "fuel_type": "petrol"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'usage_quantity' => 10.0,
            'usage_date' => '2025-01-01',
            'usage_description' => 'Used for field work',
            'user_id' => 1,
            'staff_id' => 1,
            'vehicle_id' => 1,
            'fuel_type' => 'petrol',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages/16'
payload = {
    "usage_quantity": 10,
    "usage_date": "2025-01-01",
    "usage_description": "Used for field work",
    "user_id": 1,
    "staff_id": 1,
    "vehicle_id": 1,
    "fuel_type": "petrol"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel usage record updated successfully",
    "data": {
        "id": 1,
        "usage_quantity": "10.00",
        "usage_date": "2025-01-01",
        "usage_description": "Used for field work",
        "user_id": 1,
        "staff_id": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

PUT api/v1/fuel-usages/{id}

PATCH api/v1/fuel-usages/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the fuel usage. Example: 16

fuelUsage   integer     

The ID of the fuel usage record. Example: 1

Body Parameters

usage_quantity   number  optional    

optional The quantity of fuel used. Example: 10

usage_date   string  optional    

optional The usage date (YYYY-MM-DD). Example: 2025-01-01

usage_description   string  optional    

optional Description of the usage. Example: Used for field work

user_id   integer  optional    

optional The user ID who recorded this. Example: 1

staff_id   integer  optional    

optional The staff ID associated with this usage. Example: 1

vehicle_id   integer  optional    

optional The vehicle ID associated with this usage. Example: 1

fuel_type   string  optional    

optional The type of fuel used. One of: petrol, diesel, Hydraulic Oil 10, Hydraulic Oil 40, Hydraulic Oil 68, Hydraulic Oil 90. Example: petrol

Remove the specified fuel usage record.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/fuel-usages/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/fuel-usages/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/fuel-usages/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Fuel usage record deleted successfully"
}
 

Request      

DELETE api/v1/fuel-usages/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the fuel usage. Example: 16

fuelUsage   integer     

The ID of the fuel usage record. Example: 1

Location Management

Get all locations accessible to the authenticated user.

requires authentication

Returns a list of locations based on the user's role:

The response includes the task count for each location filtered by the user's role.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/locations" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/locations"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/locations';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/locations'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Manager Success):


{
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "A01",
            "taskCount": 3,
            "createdAt": "2025-01-01 00:00:00",
            "updatedAt": "2025-01-01 00:00:00"
        },
        {
            "id": 2,
            "name": "B02",
            "taskCount": 1,
            "createdAt": "2025-01-01 00:00:00",
            "updatedAt": "2025-01-01 00:00:00"
        }
    ]
}
 

Example response (200, Checker Success):


{
    "success": true,
    "data": [
        {
            "id": 1,
            "name": "A01",
            "taskCount": 2,
            "createdAt": "2025-01-01 00:00:00",
            "updatedAt": "2025-01-01 00:00:00"
        }
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Invalid Role):


{
    "success": false,
    "message": "Access denied"
}
 

Request      

GET api/v1/locations

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Store a newly created location.

requires authentication

Creates a new location. Only admin users can create locations.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/locations" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"location_name\": \"D01\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/locations"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "location_name": "D01"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/locations';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'location_name' => 'D01',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/locations'
payload = {
    "location_name": "D01"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Location created successfully",
    "data": {
        "id": 10,
        "name": "D01",
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Access denied):


{
    "success": false,
    "message": "Access denied. Only admin users can create locations."
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "location_name": [
            "The location name field is required.",
            "The location name has already been taken."
        ]
    }
}
 

Request      

POST api/v1/locations

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

location_name   string     

The name of the location. Must be unique. Example: D01

Get details of a specific location.

requires authentication

Returns detailed information about a single location if the user has access to it. Access is determined by the user's role and whether the location has relevant tasks:

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/locations/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/locations/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/locations/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/locations/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Manager Access):


{
    "success": true,
    "data": {
        "id": 1,
        "name": "A01",
        "taskCount": 3,
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (200, Checker Access):


{
    "success": true,
    "data": {
        "id": 1,
        "name": "A01",
        "taskCount": 2,
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Access denied):


{
    "success": false,
    "message": "No tasks found for this location"
}
 

Example response (404, Location not found):


{
    "success": false,
    "message": "Location not found or access denied"
}
 

Request      

GET api/v1/locations/{location_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

location_id   integer     

The ID of the location. Example: 16

location   integer     

The ID of the location to retrieve. Example: 1

Update the specified location.

requires authentication

Updates an existing location. Only admin users can update locations.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/locations/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"location_name\": \"A01-UPDATED\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/locations/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "location_name": "A01-UPDATED"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/locations/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'location_name' => 'A01-UPDATED',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/locations/16'
payload = {
    "location_name": "A01-UPDATED"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Location updated successfully",
    "data": {
        "id": 1,
        "name": "A01-UPDATED",
        "taskCount": 3,
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-15 10:30:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Access denied):


{
    "success": false,
    "message": "Access denied. Only admin users can update locations."
}
 

Example response (404, Location not found):


{
    "success": false,
    "message": "Location not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "location_name": [
            "The location name has already been taken."
        ]
    }
}
 

Request      

PUT api/v1/locations/{location_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

location_id   integer     

The ID of the location. Example: 16

location   integer     

The ID of the location to update. Example: 1

Body Parameters

location_name   string  optional    

optional The name of the location. Must be unique if provided. Example: A01-UPDATED

Toggle the active status of the specified location.

requires authentication

Sets the location's is_active status to false (inactive). Only admin users can deactivate locations. This is a soft delete operation - the location is marked as inactive rather than being permanently deleted.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/locations/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/locations/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/locations/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/locations/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Location deactivated successfully",
    "data": {
        "id": 1,
        "name": "A01",
        "isActive": false,
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-15 10:30:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Access denied):


{
    "success": false,
    "message": "Access denied. Only admin users can deactivate locations."
}
 

Example response (404, Location not found):


{
    "success": false,
    "message": "Location not found"
}
 

Request      

DELETE api/v1/locations/{location_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

location_id   integer     

The ID of the location. Example: 16

location   integer     

The ID of the location to deactivate. Example: 1

Get tasks for a specific location.

requires authentication

Returns a paginated list of tasks for the specified location, filtered by user role:

The response includes both location details and the paginated tasks list. Tasks are ordered by task_date in descending order (newest first).

Task Meta Structure: Each task includes worker-specific meta data based on task type:

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/locations/16/tasks" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/locations/16/tasks"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/locations/16/tasks';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/locations/16/tasks'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Manager Success):


{
    "success": true,
    "data": {
        "location": {
            "id": 1,
            "name": "A01",
            "taskCount": 3,
            "createdAt": "2025-01-01 00:00:00",
            "updatedAt": "2025-01-01 00:00:00"
        },
        "tasks": [
            {
                "id": 1,
                "location": {
                    "id": 1,
                    "name": "A01"
                },
                "taskName": "Fertilizer Application",
                "taskType": "manuring",
                "taskDate": "2025-01-15",
                "taskStatus": "in_progress",
                "createdBy": {
                    "id": 1,
                    "name": "John Manager"
                },
                "submittedAt": null,
                "workers": [
                    {
                        "id": 1,
                        "fullName": "Worker One",
                        "phone": "019-1234567"
                    }
                ],
                "task_meta": [
                    {
                        "id": 1,
                        "task_id": 1,
                        "staff_id": 1,
                        "meta_key": "fertilizer_type",
                        "meta_value": "NPK",
                        "staff": {
                            "id": 1,
                            "staff_name": "Worker One",
                            "staff_id": 1
                        }
                    },
                    {
                        "id": 2,
                        "task_id": 1,
                        "staff_id": 1,
                        "meta_key": "fertilizer_amount",
                        "meta_value": "50",
                        "staff": {
                            "id": 1,
                            "staff_name": "Worker One",
                            "staff_id": 1
                        }
                    }
                ],
                "createdAt": "2025-01-01 00:00:00",
                "updatedAt": "2025-01-01 00:00:00"
            }
        ]
    },
    "pagination": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 15,
        "total": 1
    }
}
 

Example response (200, Checker Success):


{
    "success": true,
    "data": {
        "location": {
            "id": 1,
            "name": "A01",
            "taskCount": 2,
            "createdAt": "2025-01-01 00:00:00",
            "updatedAt": "2025-01-01 00:00:00"
        },
        "tasks": [
            {
                "id": 2,
                "location": {
                    "id": 1,
                    "name": "A01"
                },
                "taskName": "Harvest Check",
                "taskType": "harvesting",
                "taskDate": "2025-01-16",
                "taskStatus": "pending",
                "createdBy": {
                    "id": 1,
                    "name": "John Manager"
                },
                "submittedAt": "2025-01-16T10:00:00.000000Z",
                "workers": [
                    {
                        "id": 1,
                        "fullName": "Checker Worker",
                        "phone": "019-9999999"
                    }
                ],
                "task_meta": [
                    {
                        "id": 5,
                        "task_id": 2,
                        "staff_id": 1,
                        "meta_key": "harvesting_type",
                        "meta_value": "normal harvesting",
                        "staff": {
                            "id": 1,
                            "staff_name": "Checker Worker",
                            "staff_id": 1
                        }
                    }
                ],
                "createdAt": "2025-01-01 00:00:00",
                "updatedAt": "2025-01-01 00:00:00"
            }
        ]
    },
    "pagination": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 15,
        "total": 1
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Access denied):


{
    "success": false,
    "message": "Location not found or access denied"
}
 

Example response (404, Location not found):


{
    "success": false,
    "message": "Location not found"
}
 

Request      

GET api/v1/locations/{location_id}/tasks

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

location_id   integer     

The ID of the location. Example: 16

location   integer     

The ID of the location to get tasks for. Example: 1

Overtime Management

Get all overtime records.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/overtimes?user_id=1&staff_id=1&status=approved&date_attendance_id=1&date_from=2025-01-01&date_to=2025-01-31&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/overtimes"
);

const params = {
    "user_id": "1",
    "staff_id": "1",
    "status": "approved",
    "date_attendance_id": "1",
    "date_from": "2025-01-01",
    "date_to": "2025-01-31",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/overtimes';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'user_id' => '1',
            'staff_id' => '1',
            'status' => 'approved',
            'date_attendance_id' => '1',
            'date_from' => '2025-01-01',
            'date_to' => '2025-01-31',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/overtimes'
params = {
  'user_id': '1',
  'staff_id': '1',
  'status': 'approved',
  'date_attendance_id': '1',
  'date_from': '2025-01-01',
  'date_to': '2025-01-31',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Overtime records retrieved successfully",
    "data": [
        {
            "id": 1,
            "user_id": 1,
            "staff_id": null,
            "date_attendance_id": 1,
            "duration": 120,
            "remark": "Overtime for project completion",
            "status": "approved",
            "user": {
                "id": 1,
                "user_fullname": "John Doe"
            },
            "staff": null,
            "date_attendance": {
                "id": 1,
                "date": "2025-01-01",
                "status": "active"
            },
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/overtimes

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

user_id   integer  optional    

optional Filter by user ID. Example: 1

staff_id   integer  optional    

optional Filter by staff ID. Example: 1

status   string  optional    

optional Filter by status. Example: approved

date_attendance_id   integer  optional    

optional Filter by date attendance ID. Example: 1

date_from   string  optional    

optional Filter from date (YYYY-MM-DD). Example: 2025-01-01

date_to   string  optional    

optional Filter to date (YYYY-MM-DD). Example: 2025-01-31

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Store a newly created overtime record.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/overtimes" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date\": \"2025-01-01\",
    \"user_id\": 1,
    \"staff_id\": 1,
    \"duration\": 120,
    \"remark\": \"Overtime for project completion\",
    \"status\": \"pending\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/overtimes"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date": "2025-01-01",
    "user_id": 1,
    "staff_id": 1,
    "duration": 120,
    "remark": "Overtime for project completion",
    "status": "pending"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/overtimes';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date' => '2025-01-01',
            'user_id' => 1,
            'staff_id' => 1,
            'duration' => 120,
            'remark' => 'Overtime for project completion',
            'status' => 'pending',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/overtimes'
payload = {
    "date": "2025-01-01",
    "user_id": 1,
    "staff_id": 1,
    "duration": 120,
    "remark": "Overtime for project completion",
    "status": "pending"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Overtime record created successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "staff_id": null,
        "date_attendance_id": 1,
        "duration": 120,
        "remark": "Overtime for project completion",
        "status": "pending",
        "user": {
            "id": 1,
            "user_fullname": "John Doe"
        },
        "staff": null,
        "date_attendance": {
            "id": 1,
            "date": "2025-01-01",
            "status": "active"
        },
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "date": [
            "The date field is required."
        ],
        "duration": [
            "The duration field is required."
        ]
    }
}
 

Request      

POST api/v1/overtimes

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date   string     

The overtime date (YYYY-MM-DD). Example: 2025-01-01

user_id   integer  optional    

optional The user ID. Required if staff_id is not provided. Example: 1

staff_id   integer  optional    

optional The staff ID. Required if user_id is not provided. Example: 1

duration   integer     

The overtime duration in minutes. Example: 120

remark   string  optional    

optional Additional remarks. Example: Overtime for project completion

status   string  optional    

optional The overtime status. Example: pending

Display the specified overtime record.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/overtimes/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/overtimes/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/overtimes/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/overtimes/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Overtime record retrieved successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "staff_id": null,
        "date_attendance_id": 1,
        "duration": 120,
        "remark": "Overtime for project completion",
        "status": "approved",
        "user": {
            "id": 1,
            "user_fullname": "John Doe"
        },
        "staff": null,
        "date_attendance": {
            "id": 1,
            "date": "2025-01-01",
            "status": "active"
        },
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

GET api/v1/overtimes/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the overtime. Example: 16

overtime   integer     

The ID of the overtime record. Example: 1

Update the specified overtime record.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/overtimes/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date\": \"2025-01-01\",
    \"user_id\": 1,
    \"staff_id\": 1,
    \"duration\": 120,
    \"remark\": \"Overtime for project completion\",
    \"status\": \"approved\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/overtimes/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date": "2025-01-01",
    "user_id": 1,
    "staff_id": 1,
    "duration": 120,
    "remark": "Overtime for project completion",
    "status": "approved"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/overtimes/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date' => '2025-01-01',
            'user_id' => 1,
            'staff_id' => 1,
            'duration' => 120,
            'remark' => 'Overtime for project completion',
            'status' => 'approved',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/overtimes/16'
payload = {
    "date": "2025-01-01",
    "user_id": 1,
    "staff_id": 1,
    "duration": 120,
    "remark": "Overtime for project completion",
    "status": "approved"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Overtime record updated successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "staff_id": null,
        "date_attendance_id": 1,
        "duration": 120,
        "remark": "Overtime for project completion",
        "status": "approved",
        "user": {
            "id": 1,
            "user_fullname": "John Doe"
        },
        "staff": null,
        "date_attendance": {
            "id": 1,
            "date": "2025-01-01",
            "status": "active"
        },
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "duration": [
            "The duration must be at least 1."
        ]
    }
}
 

Request      

PUT api/v1/overtimes/{id}

PATCH api/v1/overtimes/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the overtime. Example: 16

overtime   integer     

The ID of the overtime record. Example: 1

Body Parameters

date   string  optional    

optional The overtime date (YYYY-MM-DD). Example: 2025-01-01

user_id   integer  optional    

optional The user ID. Example: 1

staff_id   integer  optional    

optional The staff ID. Example: 1

duration   integer  optional    

optional The overtime duration in minutes. Example: 120

remark   string  optional    

optional Additional remarks. Example: Overtime for project completion

status   string  optional    

optional The overtime status. Example: approved

Remove the specified overtime record.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/overtimes/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/overtimes/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/overtimes/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/overtimes/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Overtime record deleted successfully"
}
 

Request      

DELETE api/v1/overtimes/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the overtime. Example: 16

overtime   integer     

The ID of the overtime record. Example: 1

Payment Rate Management

APIs for managing payment rates for different task types

Get all payment rates

requires authentication

Retrieve all payment rates with their categories.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payment-rates" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": [
        {
            "id": 1,
            "task_name": "Pruning",
            "task_type": "pruning",
            "description": "Pruning palm trees",
            "is_active": true,
            "categories": [
                {
                    "id": 1,
                    "category_name": "Normal Pruning",
                    "category_key": "normal",
                    "rate": "4.00",
                    "unit": "per palm",
                    "conditions": null,
                    "display_order": 0
                }
            ]
        }
    ]
}
 

Request      

GET api/v1/payment-rates

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Create a new payment rate

requires authentication

Create a new payment rate with optional categories. Categories can be added later via the update endpoint.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/payment-rates" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"task_name\": \"Pruning\",
    \"task_type\": \"pruning\",
    \"description\": \"Eius et animi quos velit et.\",
    \"is_active\": true,
    \"categories\": [
        {
            \"category_name\": \"Normal\",
            \"category_key\": \"normal\",
            \"rate\": 4,
            \"unit\": \"per palm\"
        }
    ]
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "task_name": "Pruning",
    "task_type": "pruning",
    "description": "Eius et animi quos velit et.",
    "is_active": true,
    "categories": [
        {
            "category_name": "Normal",
            "category_key": "normal",
            "rate": 4,
            "unit": "per palm"
        }
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
            $o = [
                clone (\Symfony\Component\VarExporter\Internal\Registry::$prototypes['stdClass'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('stdClass')),
            ],
            null,
            [
                'stdClass' => [
                    'category_name' => [
                        'Normal',
                    ],
                    'category_key' => [
                        'normal',
                    ],
                    'rate' => [
                        4.0,
                    ],
                    'unit' => [
                        'per palm',
                    ],
                ],
            ],
            [
                'task_name' => 'Pruning',
                'task_type' => 'pruning',
                'description' => 'Eius et animi quos velit et.',
                'is_active' => true,
                'categories' => [
                    $o[0],
                ],
            ],
            []
        ),
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates'
payload = {
    "task_name": "Pruning",
    "task_type": "pruning",
    "description": "Eius et animi quos velit et.",
    "is_active": true,
    "categories": [
        {
            "category_name": "Normal",
            "category_key": "normal",
            "rate": 4,
            "unit": "per palm"
        }
    ]
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Payment rate created successfully.",
    "data": {
        "id": 1,
        "task_name": "Pruning",
        "task_type": "pruning",
        "categories": []
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation failed.",
    "errors": {
        "task_name": [
            "The task name field is required."
        ]
    }
}
 

Request      

POST api/v1/payment-rates

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

task_name   string     

The display name of the task. Example: Pruning

task_type   string  optional    

optional The task type key (auto-generated from task_name if not provided). Example: pruning

description   string  optional    

optional Task description. Example: Eius et animi quos velit et.

is_active   boolean  optional    

optional Whether this rate is active. Default: true. Example: true

categories   string[]  optional    

optional Array of payment rate categories. Can be empty or omitted.

category_name   string     

Must not be greater than 255 characters. Example: b

category_key   string  optional    

Must not be greater than 100 characters. Example: n

rate   number     

Must be at least 0. Example: 84

unit   string     

Must not be greater than 100 characters. Example: z

conditions   object  optional    
display_order   integer  optional    

Example: 16

*   object  optional    
category_name   string     

The display name of the category (required if categories array is provided). Example: Normal Pruning

category_key   string  optional    

optional The category key (auto-generated if not provided). Example: normal

rate   numeric     

The payment rate (required if categories array is provided). Example: 4.00

unit   string     

The unit of measurement (required if categories array is provided). Example: per palm

conditions   object  optional    

optional Conditions for this rate (JSON).

display_order   integer  optional    

optional Display order. Example: 0

Get payment rate by task type

requires authentication

Retrieve payment rate information for a specific task type. This is useful when creating/editing tasks to show available rates.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payment-rates/task-type/pruning" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates/task-type/pruning"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/task-type/pruning';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/task-type/pruning'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "id": 1,
        "task_name": "Pruning",
        "task_type": "pruning",
        "categories": []
    }
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Payment rate not found for this task type."
}
 

Request      

GET api/v1/payment-rates/task-type/{taskType}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

taskType   string     

The task type. Example: pruning

Get a single payment rate

requires authentication

Retrieve a specific payment rate with its categories.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payment-rates/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "id": 1,
        "task_name": "Pruning",
        "task_type": "pruning",
        "description": "Pruning palm trees",
        "is_active": true,
        "categories": [
            {
                "id": 1,
                "category_name": "Normal Pruning",
                "category_key": "normal",
                "rate": "4.00",
                "unit": "per palm"
            }
        ]
    }
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Payment rate not found."
}
 

Request      

GET api/v1/payment-rates/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The payment rate ID. Example: 1

Update a payment rate

requires authentication

Update an existing payment rate and its categories.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"task_name\": \"Pruning\",
    \"description\": \"Eius et animi quos velit et.\",
    \"is_active\": true,
    \"categories\": [
        {
            \"id\": 1,
            \"rate\": 5
        }
    ]
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "task_name": "Pruning",
    "description": "Eius et animi quos velit et.",
    "is_active": true,
    "categories": [
        {
            "id": 1,
            "rate": 5
        }
    ]
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
            $o = [
                clone (\Symfony\Component\VarExporter\Internal\Registry::$prototypes['stdClass'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('stdClass')),
            ],
            null,
            [
                'stdClass' => [
                    'id' => [
                        1,
                    ],
                    'rate' => [
                        5.0,
                    ],
                ],
            ],
            [
                'task_name' => 'Pruning',
                'description' => 'Eius et animi quos velit et.',
                'is_active' => true,
                'categories' => [
                    $o[0],
                ],
            ],
            []
        ),
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1'
payload = {
    "task_name": "Pruning",
    "description": "Eius et animi quos velit et.",
    "is_active": true,
    "categories": [
        {
            "id": 1,
            "rate": 5
        }
    ]
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Payment rate updated successfully.",
    "data": {}
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Payment rate not found."
}
 

Request      

PUT api/v1/payment-rates/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The payment rate ID. Example: 1

Body Parameters

task_name   string  optional    

optional The display name of the task. Example: Pruning

description   string  optional    

optional Task description. Example: Eius et animi quos velit et.

is_active   boolean  optional    

optional Whether this rate is active. Example: true

categories   string[]  optional    

optional Array of payment rate categories to update/add.

id   integer  optional    

The id of an existing record in the payment_rate_categories table. Example: 16

category_name   string  optional    

Must not be greater than 255 characters. Example: n

category_key   string  optional    

Must not be greater than 100 characters. Example: g

rate   number  optional    

Must be at least 0. Example: 12

unit   string  optional    

Must not be greater than 100 characters. Example: m

conditions   object  optional    
display_order   integer  optional    

Example: 16

*   object  optional    
id   integer  optional    

optional Category ID (if updating existing category). Example: 1

category_name   string     

The display name of the category. Example: Normal Pruning

category_key   string  optional    

optional The category key. Example: normal

rate   numeric     

The payment rate. Example: 5.00

unit   string     

The unit of measurement. Example: per palm

conditions   object  optional    

optional Conditions for this rate.

display_order   integer  optional    

optional Display order. Example: 0

Delete a payment rate

requires authentication

Delete a payment rate and all its categories.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Payment rate deleted successfully."
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Payment rate not found."
}
 

Request      

DELETE api/v1/payment-rates/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The payment rate ID. Example: 1

Delete a payment rate category

requires authentication

Delete a specific category from a payment rate.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1/categories/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payment-rates/1/categories/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1/categories/1';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payment-rates/1/categories/1'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Category deleted successfully."
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Category not found."
}
 

Request      

DELETE api/v1/payment-rates/{id}/categories/{categoryId}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The payment rate ID. Example: 1

categoryId   integer     

The category ID. Example: 1

Salary Management

Get the current base salary for the given user.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/users/16/base-salary" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16/base-salary"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16/base-salary';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16/base-salary'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "user_id": 5,
    "base_salary": 1800,
    "updated_at": "2025-11-04 10:00:00"
}
 

Request      

GET api/v1/users/{user_id}/base-salary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user. Example: 5

Create or update the base salary for the given user.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/users/16/base-salary" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"base_salary\": 2000
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16/base-salary"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "base_salary": 2000
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16/base-salary';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'base_salary' => 2000.0,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16/base-salary'
payload = {
    "base_salary": 2000
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Saved):


{
    "message": "Base salary saved",
    "user_id": 5,
    "base_salary": 2000,
    "updated_at": "2025-11-04 10:15:00"
}
 

Example response (422, Validation error):


{
    "message": "The base salary field is required."
}
 

Request      

POST api/v1/users/{user_id}/base-salary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user. Example: 5

Body Parameters

base_salary   number     

The monthly base salary. Must be >= 0. Example: 2000

Remove the base salary for the given user.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/users/16/base-salary" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16/base-salary"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16/base-salary';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16/base-salary'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Removed):


{
    "message": "Base salary removed",
    "user_id": 5
}
 

Request      

DELETE api/v1/users/{user_id}/base-salary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user. Example: 5

Staff Attendance

Get Staff Attendance Records

requires authentication

Retrieve a paginated list of staff attendance records for a specific date attendance. This endpoint returns all staff members with their attendance status (Absent, Check in, or Present) for the specified date attendance ID.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff-attendance?date_attendance_id=1&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 16,
    \"page\": 22,
    \"per_page\": 7
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance"
);

const params = {
    "date_attendance_id": "1",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 16,
    "page": 22,
    "per_page": 7
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'date_attendance_id' => '1',
            'page' => '1',
            'per_page' => '10',
        ],
        'json' => [
            'date_attendance_id' => 16,
            'page' => 22,
            'per_page' => 7,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance'
payload = {
    "date_attendance_id": 16,
    "page": 22,
    "per_page": 7
}
params = {
  'date_attendance_id': '1',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff attendance retrieved successfully",
    "data": {
        "data": [
            {
                "staff_id": 1,
                "staff_img": "staff_avatar.jpg",
                "staff_name": "John Doe",
                "status": "Present",
                "check_in": "2025-01-15 08:00:00",
                "check_out": "2025-01-15 17:00:00",
                "checkedin_by": "Admin User",
                "checkedout_by": "Admin User"
            },
            {
                "staff_id": 2,
                "staff_img": "staff_avatar2.jpg",
                "staff_name": "Jane Smith",
                "status": "Check_in",
                "check_in": "2025-01-15 08:30:00",
                "check_out": null,
                "checkedin_by": "Manager User",
                "checkedout_by": null
            },
            {
                "staff_id": 3,
                "staff_img": "staff_avatar3.jpg",
                "staff_name": "Mike Johnson",
                "status": "Absent",
                "check_in": null,
                "check_out": null,
                "checkedin_by": null,
                "checkedout_by": null
            }
        ],
        "current_page": 1,
        "per_page": 15,
        "total": 50,
        "last_page": 4,
        "from": 1,
        "to": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "date_attendance_id": [
            "The date attendance id field is required."
        ],
        "page": [
            "The page field must be at least 1."
        ],
        "per_page": [
            "The per page field must not be greater than 100."
        ]
    }
}
 

Request      

GET api/v1/staff-attendance

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

date_attendance_id   integer     

The date attendance ID to filter by. Example: 1

page   integer  optional    

Page number for pagination (default: 1). Example: 1

per_page   integer  optional    

Number of records per page (default: 15, max: 100). Example: 10

Body Parameters

date_attendance_id   integer     

The id of an existing record in the date_attendance table. Example: 16

page   integer  optional    

Must be at least 1. Example: 22

per_page   integer  optional    

Must be at least 1. Must not be greater than 100. Example: 7

Show Staff Attendance Analytics

requires authentication

Retrieve the analytics of a staff attendance record. This endpoint returns the analytics of the attendance record for the staff ID.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff-attendance/1/analytics?month=2025-01" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1/analytics"
);

const params = {
    "month": "2025-01",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1/analytics';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1/analytics'
params = {
  'month': '2025-01',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
  "success": true,
  "message": "Staff attendance retrieved successfully",
  "data": {
    "staff_id": 1,
    "attendance_rate": 90,
    "punctuality_rate": "90,
    "number_absent": 1
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Request      

GET api/v1/staff-attendance/{staff}/analytics

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff   integer     

The ID of the staff member. Example: 1

Query Parameters

month   string  optional    

nullable The month of the attendance record. Example: 2025-01

Get Specific Staff Attendance Records

requires authentication

Retrieve the details of a specific staff attendance record. This endpoint returns the attendance record for the specified staff ID and month.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff-attendance/1/records?month=2025-01&status=present%2C+check_in%2C+check_out%2C+absent&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1/records"
);

const params = {
    "month": "2025-01",
    "status": "present, check_in, check_out, absent",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1/records';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
            'status' => 'present, check_in, check_out, absent',
            'page' => '1',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1/records'
params = {
  'month': '2025-01',
  'status': 'present, check_in, check_out, absent',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff attendance retrieved successfully",
    "data": {
        "data": [
            {
                "id": 1,
                "date": "19-01-2025",
                "status": "Present",
                "checkedin_by": "Admin User",
                "checkedout_by": "Admin User",
                "check_in": "2025-01-19 07:30:00",
                "check_out": "2025-01-19 17:00:00",
                "duration": 34200,
                "remark_late": null,
                "notes": null
            },
            {
                "id": 2,
                "date": "20-01-2025",
                "status": "Check_in",
                "checkedin_by": "Manager User",
                "checkedout_by": null,
                "check_in": "2025-01-20 08:00:00",
                "check_out": null,
                "duration": null,
                "remark_late": "Traffic jam",
                "notes": null
            },
            {
                "id": 3,
                "date": "21-01-2025",
                "status": "Absent",
                "checkedin_by": null,
                "checkedout_by": null,
                "check_in": null,
                "check_out": null,
                "duration": null,
                "remark_late": null,
                "notes": null
            }
        ],
        "current_page": 1,
        "per_page": 15,
        "total": 50,
        "last_page": 4,
        "from": 1,
        "to": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Staff member not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "staff_id": [
            "The staff id field is required."
        ],
        "month": [
            "The month field is required."
        ]
    }
}
 

Request      

GET api/v1/staff-attendance/{staff}/records

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff   integer     

The ID of the staff member. Example: 1

Query Parameters

month   string  optional    

nullable The month of the attendance record. Example: 2025-01

status   string  optional    

nullable The status of the attendance record. Example: present, check_in, check_out, absent

page   integer  optional    

Page number for pagination (default: 1). Example: 1

per_page   integer  optional    

Number of records per page (default: 15, max: 100). Example: 10

Get Staff Leave Records

requires authentication

Retrieve a paginated list of staff leave attendance records. This endpoint returns only leave types (sick_leave, annual_leave, unpaid_leave).

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff-attendance/1/leaves?month=2025-01&status=%22sick_leave%22&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1/leaves"
);

const params = {
    "month": "2025-01",
    "status": ""sick_leave"",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1/leaves';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
            'status' => '"sick_leave"',
            'page' => '1',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1/leaves'
params = {
  'month': '2025-01',
  'status': '"sick_leave"',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff leave records retrieved successfully",
    "data": {
        "data": [
            {
                "id": 1,
                "date": "24-10-2025",
                "type_of_leave": "Annual Leave",
                "created_by": "Admin User",
                "created_at": "2025-10-24T08:00:00.000000Z",
                "start_date": "24-10-2025",
                "end_date": "24-10-2025",
                "remarks": "Going back to hometown: Family passed away"
            },
            {
                "id": 2,
                "date": "25-10-2025",
                "type_of_leave": "Sick Leave",
                "created_by": "Manager User",
                "created_at": "2025-10-25T08:00:00.000000Z",
                "start_date": "25-10-2025",
                "end_date": "25-10-2025",
                "remarks": "Medical appointment"
            }
        ],
        "current_page": 1,
        "per_page": 15,
        "total": 50,
        "last_page": 4,
        "from": 1,
        "to": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Staff member not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "month": [
            "The month must be in Y-m format (e.g., 2025-01)"
        ]
    }
}
 

Request      

GET api/v1/staff-attendance/{staff}/leaves

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff   integer     

The ID of the staff member. Example: 1

Query Parameters

month   string  optional    

nullable The month of the leave records. Example: 2025-01

status   string  optional    

nullable The type of leave. Must be "sick_leave", "annual_leave", "unpaid_leave". Example: "sick_leave"

page   integer  optional    

Page number for pagination (default: 1). Example: 1

per_page   integer  optional    

Number of records per page (default: 15, max: 100). Example: 10

Check In Staff

requires authentication

Record staff check-in time with offline sync support. This endpoint handles duplicate submissions intelligently by always saving the earliest time.

Offline Sync Logic:

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/check-in" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 1,
    \"staff_id\": 1,
    \"check_in\": \"2025-01-15 08:00:00\",
    \"remark_late\": \"\\\"Traffic jam\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/check-in"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 1,
    "staff_id": 1,
    "check_in": "2025-01-15 08:00:00",
    "remark_late": "\"Traffic jam\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/check-in';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date_attendance_id' => 1,
            'staff_id' => 1,
            'check_in' => '2025-01-15 08:00:00',
            'remark_late' => '"Traffic jam"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/check-in'
payload = {
    "date_attendance_id": 1,
    "staff_id": 1,
    "check_in": "2025-01-15 08:00:00",
    "remark_late": "\"Traffic jam\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, New Check-in Record):


{
    "success": true,
    "message": "Staff checked in successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 08:00:00",
        "check_out": null,
        "status": "check_in",
        "duration": null,
        "remark_late": "Traffic jam",
        "notes": null,
        "checkedin_by": 2,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, Updated Check-in Time):


{
    "success": true,
    "message": "Staff check-in updated successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 07:30:00",
        "check_out": "2025-01-15 17:00:00",
        "status": "present",
        "duration": 34200,
        "remark_late": "Early arrival",
        "notes": null,
        "checkedin_by": 3,
        "checkedout_by": 2,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T07:30:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "check_in": [
            "The check in field is required."
        ]
    }
}
 

Request      

POST api/v1/staff-attendance/check-in

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date_attendance_id   integer     

The date attendance ID. Example: 1

staff_id   integer     

The staff member ID. Example: 1

check_in   string     

Check-in time in Y-m-d H:i:s format. Example: 2025-01-15 08:00:00

remark_late   string  optional    

nullable Late remark. Example: "Traffic jam"

Check Out Staff

requires authentication

Record staff check-out time with offline sync support. This endpoint handles duplicate submissions intelligently by always saving the latest time.

Offline Sync Logic:

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/check-out" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 1,
    \"staff_id\": 1,
    \"check_out\": \"2025-01-15 17:00:00\",
    \"notes\": \"architecto\",
    \"remark_ot\": \"\\\"Extra work required\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/check-out"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 1,
    "staff_id": 1,
    "check_out": "2025-01-15 17:00:00",
    "notes": "architecto",
    "remark_ot": "\"Extra work required\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/check-out';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date_attendance_id' => 1,
            'staff_id' => 1,
            'check_out' => '2025-01-15 17:00:00',
            'notes' => 'architecto',
            'remark_ot' => '"Extra work required"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/check-out'
payload = {
    "date_attendance_id": 1,
    "staff_id": 1,
    "check_out": "2025-01-15 17:00:00",
    "notes": "architecto",
    "remark_ot": "\"Extra work required\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, New Check-out Record):


{
    "success": true,
    "message": "Staff checked out successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 08:00:00",
        "check_out": "2025-01-15 17:00:00",
        "status": "present",
        "duration": 32400,
        "remark_late": null,
        "notes": "Extra work required",
        "checkedin_by": 2,
        "checkedout_by": 2,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T17:00:00.000000Z"
    }
}
 

Example response (201, Updated Check-out Time):


{
    "success": true,
    "message": "Staff check-out updated successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 08:00:00",
        "check_out": "2025-01-15 18:00:00",
        "status": "present",
        "duration": 36000,
        "remark_late": null,
        "notes": "Extended hours",
        "checkedin_by": 2,
        "checkedout_by": 3,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T18:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Example response (422, No Check-in Found):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "check_out": [
            "Staff must check in before checking out"
        ]
    }
}
 

Request      

POST api/v1/staff-attendance/check-out

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date_attendance_id   integer     

The date attendance ID. Example: 1

staff_id   integer     

The staff member ID. Example: 1

check_out   string     

Check-out time in Y-m-d H:i:s format. Example: 2025-01-15 17:00:00

notes   string  optional    

Example: architecto

remark_ot   string  optional    

nullable Overtime remark. Example: "Extra work required"

Mark Staff as Absent

requires authentication

Mark staff as absent for a specific date attendance. This will clear any existing check-in/out times and set status to absent. If staff has already checked in, the request will be ignored.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-absent" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 1,
    \"staff_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-absent"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 1,
    "staff_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-absent';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date_attendance_id' => 1,
            'staff_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-absent'
payload = {
    "date_attendance_id": 1,
    "staff_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Staff Already Present):


{
    "success": true,
    "message": "Staff is already present, absent request ignored",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15T08:00:00.000000Z",
        "check_out": null,
        "status": "check_in",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": 2,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, Staff Marked Absent):


{
    "success": true,
    "message": "Staff marked as absent successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "absent",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": null,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Request      

POST api/v1/staff-attendance/mark-absent

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date_attendance_id   integer     

The date attendance ID. Example: 1

staff_id   integer     

The staff member ID. Example: 1

Mark Staff as Leave

requires authentication

Mark staff as leave (sick leave or annual leave) for a specific date attendance. This will clear any existing check-in/out times and set status to the specified leave type. If staff has already checked in, the request will be ignored.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-leave" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"staff_id\": 1,
    \"from_date\": \"2025-01-01\",
    \"to_date\": \"2025-01-01\",
    \"status\": \"\\\"sick_leave\\\"\",
    \"notes\": \"\\\"Sick leave for 1 day\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-leave"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "staff_id": 1,
    "from_date": "2025-01-01",
    "to_date": "2025-01-01",
    "status": "\"sick_leave\"",
    "notes": "\"Sick leave for 1 day\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-leave';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'staff_id' => 1,
            'from_date' => '2025-01-01',
            'to_date' => '2025-01-01',
            'status' => '"sick_leave"',
            'notes' => '"Sick leave for 1 day"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/mark-leave'
payload = {
    "staff_id": 1,
    "from_date": "2025-01-01",
    "to_date": "2025-01-01",
    "status": "\"sick_leave\"",
    "notes": "\"Sick leave for 1 day\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Staff Already Present):


{
    "success": true,
    "message": "Staff is already present, leave request ignored",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15T08:00:00.000000Z",
        "check_out": null,
        "status": "check_in",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": 2,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, Staff Marked Sick Leave):


{
    "success": true,
    "message": "Staff marked as sick leave successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "sick_leave",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": null,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, Staff Marked Annual Leave):


{
    "success": true,
    "message": "Staff marked as annual leave successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "annual_leave",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": null,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "status": [
            "The selected status is invalid."
        ]
    }
}
 

Request      

POST api/v1/staff-attendance/mark-leave

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

staff_id   integer     

The staff member ID. Example: 1

from_date   string     

The date from which the leave is applicable. Example: 2025-01-01

to_date   string     

The date to which the leave is applicable. Example: 2025-01-01

status   string     

The type of leave. Must be "sick_leave", "annual_leave", "unpaid_leave". Example: "sick_leave"

notes   string  optional    

nullable Notes for the leave. Example: "Sick leave for 1 day"

Update Staff Leave Attendance

requires authentication

Update a staff leave attendance record. Only leave types (sick_leave, annual_leave, unpaid_leave) can be updated.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"status\": \"\\\"sick_leave\\\"\",
    \"notes\": \"\\\"Updated sick leave notes\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "\"sick_leave\"",
    "notes": "\"Updated sick leave notes\""
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'status' => '"sick_leave"',
            'notes' => '"Updated sick leave notes"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1'
payload = {
    "status": "\"sick_leave\"",
    "notes": "\"Updated sick leave notes\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff leave attendance updated successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "sick_leave",
        "duration": null,
        "remark_late": null,
        "notes": "Updated sick leave notes",
        "checkedin_by": 2,
        "checkedout_by": 2,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T09:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Attendance record not found"
}
 

Example response (422, Not a Leave Type):


{
    "success": false,
    "message": "Only leave attendance records can be updated"
}
 

Request      

PUT api/v1/staff-attendance/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The attendance record ID. Example: 1

Body Parameters

status   string  optional    

nullable The type of leave. Must be "sick_leave", "annual_leave", "unpaid_leave". Example: "sick_leave"

notes   string  optional    

nullable Notes for the leave. Example: "Updated sick leave notes"

Delete Staff Leave Attendance

requires authentication

Soft delete a staff leave attendance record. Only leave types (sick_leave, annual_leave, unpaid_leave) can be deleted.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/1'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff leave attendance deleted successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "sick_leave",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": 2,
        "checkedout_by": 2,
        "deleted_at": "2025-01-15T09:00:00.000000Z",
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T09:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record staff attendance"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Attendance record not found"
}
 

Example response (422, Not a Leave Type):


{
    "success": false,
    "message": "Only leave attendance records can be deleted"
}
 

Request      

DELETE api/v1/staff-attendance/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The attendance record ID. Example: 1

Mark All attendance that is not checked out yet to be checked out

requires authentication

Mark staff attendance that is not checked out yet to set the checkout time. Checkout time will be set to 4pm on the same date as check-in. Should be done with cron job every 7 PM. Only for staff attendance that is not checked out yet. Processes all attendance records (not just today).

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/auto-checkout" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff-attendance/auto-checkout"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/auto-checkout';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff-attendance/auto-checkout'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers)
response.json()

Example response (200, All attendance that is not checked out yet to be checked out):


{
    "success": true,
    "message": "All attendance that is not checked out yet to be checked out",
    "data": {
        "count": 10
    }
}
 

Request      

POST api/v1/staff-attendance/auto-checkout

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Staff Management

Display a listing of the staff.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff?search=john&gender=male&claimed=&per_page=10&page=1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff"
);

const params = {
    "search": "john",
    "gender": "male",
    "claimed": "0",
    "per_page": "10",
    "page": "1",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'john',
            'gender' => 'male',
            'claimed' => '0',
            'per_page' => '10',
            'page' => '1',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff'
params = {
  'search': 'john',
  'gender': 'male',
  'claimed': '0',
  'per_page': '10',
  'page': '1',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff list retrieved successfully",
    "data": [
        {
            "id": 1,
            "staff_fullname": "John Doe",
            "staff_phone": "+1234567890",
            "staff_dob": "1990-01-01",
            "staff_img": "https://example.com/staff.jpg",
            "staff_doc": null,
            "staff_gender": "male",
            "staff_bank_name": "Maybank",
            "staff_bank_number": "1234567890",
            "staff_kwsp_number": "1234567890",
            "staff_employment_start_date": "2024-01-15",
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z",
            "claimed_staff": {
                "claimedStaff_id": 1,
                "staff_id": 1,
                "user_id": 2,
                "created_at": "2025-01-01T00:00:00.000000Z",
                "updated_at": "2025-01-01T00:00:00.000000Z",
                "user": {
                    "id": 2,
                    "user_fullname": "Manager Name"
                }
            }
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/staff

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

Search staff by name or phone number. Example: john

gender   string  optional    

Filter by gender (male/female). Example: male

claimed   boolean  optional    

Filter by claim status (true/false). Example: false

per_page   integer  optional    

Number of items per page. Example: 10

page   integer  optional    

Page number. Example: 1

Register Staff

requires authentication

Register a new staff member.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff/register" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"staff_fullname\": \"John Doe\",
    \"staff_phone\": \"+1234567890\",
    \"staff_dob\": \"1990-01-01\",
    \"staff_gender\": \"male\",
    \"staff_doc\": \"https:\\/\\/example.com\\/doc.pdf\",
    \"staff_bank_name\": \"Maybank\",
    \"staff_bank_number\": \"1234567890\",
    \"staff_kwsp_number\": \"1234567890\",
    \"staff_employment_start_date\": \"2024-01-15\",
    \"staff_img\": \"https:\\/\\/example.com\\/image.jpg\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/register"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "staff_fullname": "John Doe",
    "staff_phone": "+1234567890",
    "staff_dob": "1990-01-01",
    "staff_gender": "male",
    "staff_doc": "https:\/\/example.com\/doc.pdf",
    "staff_bank_name": "Maybank",
    "staff_bank_number": "1234567890",
    "staff_kwsp_number": "1234567890",
    "staff_employment_start_date": "2024-01-15",
    "staff_img": "https:\/\/example.com\/image.jpg"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/register';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'staff_fullname' => 'John Doe',
            'staff_phone' => '+1234567890',
            'staff_dob' => '1990-01-01',
            'staff_gender' => 'male',
            'staff_doc' => 'https://example.com/doc.pdf',
            'staff_bank_name' => 'Maybank',
            'staff_bank_number' => '1234567890',
            'staff_kwsp_number' => '1234567890',
            'staff_employment_start_date' => '2024-01-15',
            'staff_img' => 'https://example.com/image.jpg',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/register'
payload = {
    "staff_fullname": "John Doe",
    "staff_phone": "+1234567890",
    "staff_dob": "1990-01-01",
    "staff_gender": "male",
    "staff_doc": "https:\/\/example.com\/doc.pdf",
    "staff_bank_name": "Maybank",
    "staff_bank_number": "1234567890",
    "staff_kwsp_number": "1234567890",
    "staff_employment_start_date": "2024-01-15",
    "staff_img": "https:\/\/example.com\/image.jpg"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Successful registration):


{
    "success": true,
    "message": "Staff registered successfully",
    "data": {
        "id": 1,
        "staff_fullname": "John Doe",
        "staff_phone": "+1234567890",
        "staff_dob": "1990-01-01",
        "staff_img": null,
        "staff_doc": null,
        "staff_gender": "male",
        "staff_bank_name": "Maybank",
        "staff_bank_number": "1234567890",
        "staff_kwsp_number": "1234567890",
        "staff_employment_start_date": "2024-01-15",
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "staff_fullname": [
            "The staff fullname field is required."
        ],
        "staff_phone": [
            "The staff phone field is required."
        ]
    }
}
 

Request      

POST api/v1/staff/register

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

staff_fullname   string     

The staff's full name. Example: John Doe

staff_phone   string     

The staff's phone number. Example: +1234567890

staff_dob   string     

The staff's date of birth (YYYY-MM-DD). Example: 1990-01-01

staff_gender   string     

The staff's gender. One of: male, female. Example: male

staff_doc   string  optional    

nullable The staff's document URL. Example: https://example.com/doc.pdf

staff_bank_name   string  optional    

nullable The staff's bank name. Example: Maybank

staff_bank_number   string  optional    

nullable The staff's bank account number. Example: 1234567890

staff_kwsp_number   string  optional    

nullable The staff's KWSP number. Example: 1234567890

staff_employment_start_date   string     

The staff's employment start date (YYYY-MM-DD). Example: 2024-01-15

staff_img   string  optional    

nullable The staff's profile image URL. Example: https://example.com/image.jpg

Get list of staff members assigned to a manager.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff/my-staff?user_id=2" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/my-staff"
);

const params = {
    "user_id": "2",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/my-staff';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'user_id' => '2',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/my-staff'
params = {
  'user_id': '2',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success - Manager viewing own staff):


{
    "success": true,
    "message": "Assigned staff retrieved successfully",
    "data": [
        {
            "id": 1,
            "staff_fullname": "John Doe",
            "staff_phone": "+1234567890",
            "staff_dob": "1990-01-01",
            "staff_img": "https://example.com/staff.jpg",
            "staff_doc": null,
            "staff_gender": "male",
            "staff_bank_name": "Maybank",
            "staff_bank_number": "1234567890",
            "staff_kwsp_number": "1234567890",
            "staff_employment_start_date": "2024-01-15",
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ]
}
 

Example response (200, Success - Admin viewing manager's staff):


{
    "success": true,
    "message": "Manager's assigned staff retrieved successfully",
    "data": {
        "manager": {
            "id": 2,
            "user_fullname": "Manager Name",
            "user_nickname": "manager1",
            "user_role": "manager",
            "user_img": null
        },
        "staff": [
            {
                "id": 1,
                "staff_fullname": "John Doe",
                "staff_phone": "+1234567890",
                "staff_dob": "1990-01-01",
                "staff_img": "https://example.com/staff.jpg",
                "staff_doc": null,
                "staff_gender": "male",
                "staff_bank_name": "Maybank",
                "staff_bank_number": "1234567890",
                "staff_kwsp_number": "1234567890",
                "created_at": "2025-01-01T00:00:00.000000Z",
                "updated_at": "2025-01-01T00:00:00.000000Z"
            }
        ]
    }
}
 

Example response (400, Not a manager):


{
    "success": false,
    "message": "The specified user is not a manager"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden - Manager trying to view other manager's staff):


{
    "success": false,
    "message": "Only admins can view other manager's assigned staff"
}
 

Example response (404, User not found):


{
    "success": false,
    "message": "User not found"
}
 

Request      

GET api/v1/staff/my-staff

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

user_id   integer  optional    

optional The ID of the manager/user (Admin only). Example: 2

Assign a staff member to a manager (Admin only).

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff/claim" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"staff_id\": 1,
    \"user_id\": 2
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/claim"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "staff_id": 1,
    "user_id": 2
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/claim';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'staff_id' => 1,
            'user_id' => 2,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/claim'
payload = {
    "staff_id": 1,
    "user_id": 2
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff assigned to manager successfully",
    "data": {
        "claimedStaff_id": 1,
        "staff_id": 1,
        "user_id": 2,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (400, Staff already claimed):


{
    "success": false,
    "message": "This staff member is already assigned to another manager"
}
 

Example response (400, Not a manager):


{
    "success": false,
    "message": "The specified user is not a manager"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can assign staff to managers"
}
 

Request      

POST api/v1/staff/claim

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

staff_id   integer     

The ID of the staff member. Example: 1

user_id   integer     

The ID of the manager. Example: 2

Unassign a staff member from their manager (Admin only).

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/staff/16/unclaim" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16/unclaim"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16/unclaim';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16/unclaim'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff unassigned successfully"
}
 

Example response (400, Staff not assigned):


{
    "success": false,
    "message": "This staff member is not assigned to any manager"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can unassign staff from managers"
}
 

Request      

DELETE api/v1/staff/{staff_id}/unclaim

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

Update staff status (Admin only).

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/staff/16/status" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"staff_status\": \"inactive\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16/status"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "staff_status": "inactive"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16/status';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'staff_status' => 'inactive',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16/status'
payload = {
    "staff_status": "inactive"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff status updated successfully",
    "data": {
        "id": 1,
        "staff_fullname": "John Doe",
        "staff_status": "inactive",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can update staff status"
}
 

Example response (404, Staff not found):


{
    "success": false,
    "message": "Staff not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "staff_status": [
            "The selected staff status is invalid."
        ]
    }
}
 

Request      

PUT api/v1/staff/{staff_id}/status

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 1

Body Parameters

staff_status   string     

The staff status. One of: active, inactive. Example: inactive

Display the specific staff.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff details retrieved successfully",
    "data": {
        "id": 1,
        "staff_fullname": "John Doe",
        "staff_phone": "+1234567890",
        "staff_dob": "1990-01-01",
        "staff_img": "https://example.com/staff.jpg",
        "staff_doc": null,
        "staff_gender": "male",
        "staff_bank_name": "Maybank",
        "staff_bank_number": "1234567890",
        "staff_kwsp_number": "1234567890",
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z",
        "attendance_count_month": 15,
        "claimed_staff": {
            "claimedStaff_id": 1,
            "staff_id": 1,
            "user_id": 2,
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z",
            "user": {
                "id": 2,
                "user_fullname": "Manager Name",
                "user_nickname": "manager1"
            }
        }
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Staff not found):


{
    "success": false,
    "message": "Staff not found"
}
 

Request      

GET api/v1/staff/{staff_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 1

Update staff details.

requires authentication

Update an existing staff member's information.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"staff_fullname\": \"John Doe\",
    \"staff_phone\": \"+1234567890\",
    \"staff_dob\": \"1990-01-01\",
    \"staff_gender\": \"male\",
    \"staff_doc\": \"https:\\/\\/example.com\\/doc.pdf\",
    \"staff_bank_name\": \"Maybank\",
    \"staff_bank_number\": \"1234567890\",
    \"staff_kwsp_number\": \"1234567890\",
    \"staff_employment_start_date\": \"2026-01-12T11:56:41\",
    \"staff_img\": \"https:\\/\\/example.com\\/image.jpg\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "staff_fullname": "John Doe",
    "staff_phone": "+1234567890",
    "staff_dob": "1990-01-01",
    "staff_gender": "male",
    "staff_doc": "https:\/\/example.com\/doc.pdf",
    "staff_bank_name": "Maybank",
    "staff_bank_number": "1234567890",
    "staff_kwsp_number": "1234567890",
    "staff_employment_start_date": "2026-01-12T11:56:41",
    "staff_img": "https:\/\/example.com\/image.jpg"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'staff_fullname' => 'John Doe',
            'staff_phone' => '+1234567890',
            'staff_dob' => '1990-01-01',
            'staff_gender' => 'male',
            'staff_doc' => 'https://example.com/doc.pdf',
            'staff_bank_name' => 'Maybank',
            'staff_bank_number' => '1234567890',
            'staff_kwsp_number' => '1234567890',
            'staff_employment_start_date' => '2026-01-12T11:56:41',
            'staff_img' => 'https://example.com/image.jpg',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16'
payload = {
    "staff_fullname": "John Doe",
    "staff_phone": "+1234567890",
    "staff_dob": "1990-01-01",
    "staff_gender": "male",
    "staff_doc": "https:\/\/example.com\/doc.pdf",
    "staff_bank_name": "Maybank",
    "staff_bank_number": "1234567890",
    "staff_kwsp_number": "1234567890",
    "staff_employment_start_date": "2026-01-12T11:56:41",
    "staff_img": "https:\/\/example.com\/image.jpg"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Successful update):


{
    "success": true,
    "message": "Staff details updated successfully",
    "data": {
        "id": 1,
        "staff_fullname": "John Doe Updated",
        "staff_phone": "+1234567890",
        "staff_dob": "1990-01-01",
        "staff_img": "https://example.com/staff-updated.jpg",
        "staff_doc": null,
        "staff_gender": "male",
        "staff_bank_name": "Maybank",
        "staff_bank_number": "1234567890",
        "staff_kwsp_number": "1234567890",
        "staff_employment_start_date": "2024-01-15",
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Staff not found):


{
    "success": false,
    "message": "Staff not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "staff_gender": [
            "The selected staff gender is invalid."
        ]
    }
}
 

Request      

POST api/v1/staff/{staff_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 1

Body Parameters

staff_fullname   string  optional    

optional The staff's full name. Example: John Doe

staff_phone   string  optional    

optional The staff's phone number. Example: +1234567890

staff_dob   string  optional    

optional The staff's date of birth (YYYY-MM-DD). Example: 1990-01-01

staff_gender   string  optional    

optional The staff's gender. One of: male, female. Example: male

staff_doc   string  optional    

nullable The staff's document URL. Example: https://example.com/doc.pdf

staff_bank_name   string  optional    

nullable The staff's bank name. Example: Maybank

staff_bank_number   string  optional    

nullable The staff's bank account number. Example: 1234567890

staff_kwsp_number   string  optional    

nullable The staff's KWSP number. Example: 1234567890

staff_employment_start_date   string  optional    

Must be a valid date. Example: 2026-01-12T11:56:41

staff_img   string|file  optional    

nullable The staff's profile image URL or file upload. Example: https://example.com/image.jpg

Delete a staff member.

requires authentication

Permanently delete a staff member from the system. Only admins can delete staff. This will also delete related records such as claimed staff assignments and task worker assignments.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/staff/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff deleted successfully"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can delete staff members"
}
 

Example response (404, Staff not found):


{
    "success": false,
    "message": "Staff not found"
}
 

Request      

DELETE api/v1/staff/{staff_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member to delete. Example: 1

Staff Payroll Management

Get list of staff with their payroll information for manage payroll page.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payroll/staff?search=john" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/staff"
);

const params = {
    "search": "john",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'john',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff'
params = {
  'search': 'john',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Staff list retrieved successfully",
    "data": [
        {
            "id": 1,
            "staff_fullname": "John Doe",
            "staff_phone": "+1234567890",
            "staff_dob": "1990-01-01",
            "staff_img": null,
            "age": 35,
            "staff_employment_start_date": "2024-01-15",
            "joined_since": "2024",
            "payslips_count": 5
        }
    ]
}
 

Request      

GET api/v1/payroll/staff

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

Search staff by name or phone. Example: john

Get employment overview with payslip history for a specific staff member.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payroll/staff/16/overview" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/staff/16/overview"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/16/overview';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/16/overview'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Data retrieved successfully",
    "data": {
        "staff": {
            "id": 1,
            "staff_fullname": "John Doe",
            "staff_phone": "+1234567890",
            "staff_dob": "1990-01-01",
            "staff_img": null,
            "age": 35,
            "staff_employment_start_date": "2024-01-15",
            "joined_since": "2024"
        },
        "payslips": [
            {
                "id": 1,
                "payslip_month": "October 2025",
                "payslip_month_short": "10/25",
                "total_income": 5000,
                "total_deduction": 500,
                "net_salary": 4500,
                "created_at": "2025-11-01T10:30:00.000000Z"
            }
        ]
    }
}
 

Example response (404, Staff not found):


{
    "success": false,
    "message": "Staff not found"
}
 

Request      

GET api/v1/payroll/staff/{staff_id}/overview

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 1

Generate a new payslip for a staff member for a specific month.

requires authentication

Calculates total income from base salary and task earnings, applies deductions including manual deductions, attendance-based deductions (early out, lateness), and optional advance loan repayments.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/payroll/staff/16/generate" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"payslip_month\": \"10\\/25\",
    \"deductions\": [
        \"architecto\"
    ],
    \"advance_repayment_amount\": \"500.00\",
    \"advance_repayment_remarks\": \"Partial loan repayment\",
    \"employer_epf\": 19,
    \"employer_socso\": 17,
    \"employer_eis\": 5,
    \"employer_pcb\": 8
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/staff/16/generate"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "payslip_month": "10\/25",
    "deductions": [
        "architecto"
    ],
    "advance_repayment_amount": "500.00",
    "advance_repayment_remarks": "Partial loan repayment",
    "employer_epf": 19,
    "employer_socso": 17,
    "employer_eis": 5,
    "employer_pcb": 8
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/16/generate';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'payslip_month' => '10/25',
            'deductions' => [
                'architecto',
            ],
            'advance_repayment_amount' => '500.00',
            'advance_repayment_remarks' => 'Partial loan repayment',
            'employer_epf' => 19,
            'employer_socso' => 17,
            'employer_eis' => 5,
            'employer_pcb' => 8,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/16/generate'
payload = {
    "payslip_month": "10\/25",
    "deductions": [
        "architecto"
    ],
    "advance_repayment_amount": "500.00",
    "advance_repayment_remarks": "Partial loan repayment",
    "employer_epf": 19,
    "employer_socso": 17,
    "employer_eis": 5,
    "employer_pcb": 8
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Payslip generated successfully",
    "data": {
        "id": 1,
        "staff_id": 1,
        "staff": {
            "id": 1,
            "staff_fullname": "John Doe",
            "staff_doc": "DOC123",
            "staff_bank_name": "Bank XYZ",
            "staff_bank_number": "1234567890",
            "staff_kwsp_number": "KWSP123"
        },
        "payslip_month": "10/25",
        "payslip_month_readable": "October 2025",
        "base_salary": 3000,
        "task_income": 2000,
        "total_income": 5000,
        "total_deduction": 600,
        "net_salary": 4400,
        "breakdown": {},
        "deductions": [
            {
                "deduction_type": "Insurance",
                "deduction_amount": 100,
                "deduction_note": "Health insurance",
                "source": "manual"
            },
            {
                "deduction_type": "Early Out",
                "deduction_amount": 50,
                "deduction_note": "Early checkout 2 time(s), total 120 minutes",
                "source": "calculated"
            },
            {
                "deduction_type": "Advance Repayment",
                "deduction_amount": 500,
                "deduction_note": "Partial loan repayment",
                "source": "advance_repayment"
            }
        ],
        "advance_repayment_requested": 500,
        "advance_repayment_applied_total": 500,
        "advance_repayment_applied": [],
        "advance_outstanding_before": 1000,
        "advance_outstanding_after": 500,
        "attendance_deductions": {
            "early_out": {
                "count": 2,
                "total_minutes": 120,
                "amount": 50
            },
            "lateness": {
                "count": 0,
                "total_minutes": 0,
                "amount": 0
            },
            "calculation_info": {}
        }
    }
}
 

Example response (404, Staff not found):


{
    "success": false,
    "message": "Staff not found"
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Payslip for this month already exists"
}
 

Example response (500, Server error):


{
    "success": false,
    "message": "Failed to generate payslip: [error details]"
}
 

Request      

POST api/v1/payroll/staff/{staff_id}/generate

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 1

Body Parameters

payslip_month   string     

Month in MM/YY format (e.g., 10/25 for October 2025). Must be unique per staff. Example: 10/25

deductions   string[]  optional    

optional Array of manual deduction items.

deduction_type   string     

Must not be greater than 255 characters. Example: h

deduction_amount   number     

Must be at least 0. Must not be greater than 99999999.99. Example: 18

deduction_note   string  optional    

Must not be greater than 500 characters. Example: a

*   object  optional    
deduction_type   string     

Type/name of the deduction. Example: Insurance

deduction_amount   numeric     

Deduction amount (0-99999999.99). Example: 100.50

deduction_note   string  optional    

optional Additional notes about the deduction. Example: Health insurance premium

advance_repayment_amount   numeric  optional    

optional Amount to apply towards staff loan repayment (0-99999999.99). Example: 500.00

advance_repayment_remarks   string  optional    

optional Notes about the advance repayment. Example: Partial loan repayment

employer_epf   number  optional    

Employer contributions (optional, to display on payslip). Must be at least 0. Must not be greater than 99999999.99. Example: 19

employer_socso   number  optional    

Must be at least 0. Must not be greater than 99999999.99. Example: 17

employer_eis   number  optional    

Must be at least 0. Must not be greater than 99999999.99. Example: 5

employer_pcb   number  optional    

Must be at least 0. Must not be greater than 99999999.99. Example: 8

Retrieve details of a specific staff payslip.

requires authentication

Returns comprehensive payslip information including staff details, income breakdown, deductions, and net salary. Supports both JSON API response and HTML view rendering.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16?view=html" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16"
);

const params = {
    "view": "html",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'view' => 'html',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16'
params = {
  'view': 'html',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Payslip details retrieved successfully",
    "data": {
        "id": 1,
        "staff": {
            "id": 1,
            "staff_fullname": "John Doe",
            "staff_doc": "DOC123",
            "staff_bank_name": "Bank XYZ",
            "staff_bank_number": "1234567890",
            "staff_kwsp_number": "KWSP123"
        },
        "payslip_month": "10/25",
        "payslip_month_readable": "October 2025",
        "base_salary": 3000,
        "task_income": 2000,
        "total_income": 5000,
        "total_deduction": 500,
        "net_salary": 4500,
        "breakdown": {},
        "deductions": [],
        "created_at": "2025-11-01T10:30:00.000000Z"
    }
}
 

Example response (404, Payslip not found):


{
    "success": false,
    "message": "Payslip not found"
}
 

Request      

GET api/v1/payroll/staff/payslips/{payslip_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

payslip_id   integer     

The ID of the payslip. Example: 16

payslip   integer     

The ID of the payslip. Example: 1

Query Parameters

view   string  optional    

optional Set to 'html' to render HTML view instead of JSON response. Example: html

Delete a payslip.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/staff/payslips/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Payslip deleted successfully"
}
 

Request      

DELETE api/v1/payroll/staff/payslips/{payslip_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

payslip_id   integer     

The ID of the payslip. Example: 16

payslip   integer     

The ID of the payslip. Example: 1

Staff Salary Management

Get the current base salary for the given staff member.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/staff/16/base-salary" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16/base-salary"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16/base-salary';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16/base-salary'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "staff_id": 5,
    "base_salary": 1800,
    "updated_at": "2025-11-04 10:00:00"
}
 

Request      

GET api/v1/staff/{staff_id}/base-salary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 5

Create or update the base salary for the given staff member.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/staff/16/base-salary" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"base_salary\": 2000
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16/base-salary"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "base_salary": 2000
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16/base-salary';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'base_salary' => 2000.0,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16/base-salary'
payload = {
    "base_salary": 2000
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Saved):


{
    "message": "Base salary saved",
    "staff_id": 5,
    "base_salary": 2000,
    "updated_at": "2025-11-04 10:15:00"
}
 

Example response (422, Validation error):


{
    "message": "The base salary field is required."
}
 

Request      

POST api/v1/staff/{staff_id}/base-salary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 5

Body Parameters

base_salary   number     

The monthly base salary. Must be >= 0. Example: 2000

Remove the base salary for the given staff member.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/staff/16/base-salary" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/staff/16/base-salary"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/staff/16/base-salary';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/staff/16/base-salary'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Removed):


{
    "message": "Base salary removed",
    "staff_id": 5
}
 

Request      

DELETE api/v1/staff/{staff_id}/base-salary

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The ID of the staff member. Example: 5

Task Audit

Get All Audited Tasks

requires authentication

Retrieve all audited tasks with their complete data including media files. Media files (video and images) are returned as accessible temporary URLs since they are stored in private storage.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks/audits?page=1&per_page=15&action=approve&task_id=1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/audits"
);

const params = {
    "page": "1",
    "per_page": "15",
    "action": "approve",
    "task_id": "1",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'page' => '1',
            'per_page' => '15',
            'action' => 'approve',
            'task_id' => '1',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits'
params = {
  'page': '1',
  'per_page': '15',
  'action': 'approve',
  'task_id': '1',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Audited tasks retrieved successfully",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "task_id": 1,
                "approved_by": 2,
                "task_video": "https://example.com/temporary-url/video.mp4",
                "task_img": [
                    "https://example.com/temporary-url/image1.png",
                    "https://example.com/temporary-url/image2.png"
                ],
                "action": "approve",
                "remarks": "Task completed successfully",
                "created_at": "2025-01-15T10:00:00.000000Z",
                "updated_at": "2025-01-15T10:00:00.000000Z",
                "task": {
                    "id": 1,
                    "task_name": "Pruning Task",
                    "task_status": "completed"
                },
                "approved_by_user": {
                    "id": 2,
                    "user_fullname": "John Approver"
                },
                "worker_audit_meta": [
                    {
                        "id": 1,
                        "task_audit_id": 1,
                        "staff_id": 1,
                        "payment_rate_category_id": 12,
                        "meta_value": "10",
                        "staff": {
                            "id": 1,
                            "staff_fullname": "Jane Worker"
                        },
                        "payment_rate_category": {
                            "id": 12,
                            "category_name": "Normal Pruning"
                        }
                    }
                ]
            }
        ],
        "total": 50,
        "per_page": 15,
        "last_page": 4
    }
}
 

Request      

GET api/v1/tasks/audits

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

page   integer  optional    

nullable Page number for pagination. Example: 1

per_page   integer  optional    

nullable Number of items per page. Example: 15

action   string  optional    

nullable Filter by action (approve/reject). Example: approve

task_id   integer  optional    

nullable Filter by task ID. Example: 1

Get Task With Payment Rate Categories

requires authentication

Get a list of task categories with id and the category name. This endpoint is used to get the list of task categories for the task audit. Can also get the for specific task type.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks/audits/categories?task_type=%22pruning%22" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/audits/categories"
);

const params = {
    "task_type": ""pruning"",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits/categories';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'task_type' => '"pruning"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits/categories'
params = {
  'task_type': '"pruning"',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": [
        {
            "id": 1,
            "category_name": "Normal Pruning"
        },
        {
            "id": 2,
            "category_name": "Routine Pruning"
        }
    ]
}
 

Request      

GET api/v1/tasks/audits/categories

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

task_type   string  optional    

nullable The task type to get the categories for. Example: "pruning"

Reject Task

requires authentication

Reject a pending task and change its status to in_progress. This endpoint allows approvers to reject tasks that need to be redone.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks/audits/16/reject" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"remarks\": \"\\\"Task not completed properly\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/audits/16/reject"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "remarks": "\"Task not completed properly\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits/16/reject';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'remarks' => '"Task not completed properly"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits/16/reject'
payload = {
    "remarks": "\"Task not completed properly\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Task rejected successfully",
    "data": {
        "id": 1,
        "task_id": 1,
        "approved_by": 2,
        "task_video": null,
        "task_img": null,
        "action": "reject",
        "remarks": "Task not completed properly",
        "created_at": "2025-01-15T10:00:00.000000Z",
        "updated_at": "2025-01-15T10:00:00.000000Z",
        "task": {
            "id": 1,
            "task_name": "Pruning Task",
            "task_status": "pending"
        }
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to audit tasks"
}
 

Example response (404, Task Not Found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "remarks": [
            "The remarks field must be a string."
        ]
    }
}
 

Request      

POST api/v1/tasks/audits/{task_id}/reject

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

task   integer     

The ID of the task to reject. Example: 1

Body Parameters

remarks   string  optional    

nullable Rejection remarks. Example: "Task not completed properly"

Approve Task

requires authentication

Approve a pending task and change its status to completed. This endpoint allows approvers to approve tasks with evidence (video and images).

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks/audits/16/approve" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"task_video\": \"\\\"https:\\/\\/example.com\\/video.mp4\\\"\",
    \"task_img\": [
        \"https:\\/\\/example.com\\/img1.jpg\",
        \"https:\\/\\/example.com\\/img2.jpg\"
    ],
    \"remarks\": \"\\\"Task completed successfully\\\"\",
    \"worker_audit_meta\": null
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/audits/16/approve"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "task_video": "\"https:\/\/example.com\/video.mp4\"",
    "task_img": [
        "https:\/\/example.com\/img1.jpg",
        "https:\/\/example.com\/img2.jpg"
    ],
    "remarks": "\"Task completed successfully\"",
    "worker_audit_meta": null
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits/16/approve';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'task_video' => '"https://example.com/video.mp4"',
            'task_img' => [
                'https://example.com/img1.jpg',
                'https://example.com/img2.jpg',
            ],
            'remarks' => '"Task completed successfully"',
            'worker_audit_meta' => null,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/audits/16/approve'
payload = {
    "task_video": "\"https:\/\/example.com\/video.mp4\"",
    "task_img": [
        "https:\/\/example.com\/img1.jpg",
        "https:\/\/example.com\/img2.jpg"
    ],
    "remarks": "\"Task completed successfully\"",
    "worker_audit_meta": null
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Task approved successfully",
    "data": {
        "id": 1,
        "task_id": 1,
        "approved_by": 2,
        "task_video": "https://example.com/video.mp4",
        "task_img": [
            "https://example.com/img1.jpg",
            "https://example.com/img2.jpg"
        ],
        "action": "approve",
        "remarks": "Task completed successfully",
        "created_at": "2025-01-15T10:00:00.000000Z",
        "updated_at": "2025-01-15T10:00:00.000000Z",
        "task": {
            "id": 1,
            "task_name": "Pruning Task",
            "task_status": "completed"
        },
        "worker_audit_meta": [
            {
                "id": 1,
                "task_audit_id": 1,
                "staff_id": 1,
                "payment_rate_category_id": 12,
                "meta_value": "10",
                "staff": {
                    "id": 1,
                    "staff_name": "Jane Worker"
                }
            },
            {
                "id": 2,
                "task_audit_id": 1,
                "staff_id": 1,
                "payment_rate_category_id": 15,
                "meta_value": "5000",
                "staff": {
                    "id": 1,
                    "staff_name": "Jane Worker"
                }
            }
        ]
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to audit tasks"
}
 

Example response (404, Task Not Found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "task_video": [
            "The task video field is required."
        ],
        "task_img": [
            "The task img field is required."
        ],
        "worker_audit_meta": [
            "The worker audit meta field is required."
        ],
        "worker_audit_meta.0.staff_id": [
            "The worker audit meta.0.staff id field is required."
        ],
        "worker_audit_meta.0.meta": [
            "The worker audit meta.0.meta field must be an array."
        ]
    }
}
 

Request      

POST api/v1/tasks/audits/{task_id}/approve

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

task   integer     

The ID of the task to approve. Example: 1

Body Parameters

task_video   string     

Video URL as evidence. Example: "https://example.com/video.mp4"

task_img   string[]     

Array of image URLs as evidence.

remarks   string  optional    

nullable Approval remarks. Example: "Task completed successfully"

worker_audit_meta   string[]     

Array of worker-specific audit meta data.

New Format (Recommended): Example (list form): [{"staff_id": 1, "meta": [{"payment_rate_category_id": 12, "value": "10"}]}] Example (map form): [{"staff_id": 1, "meta": {"12": "10"}}]

Old Format (Backward Compatible):

staff_id   integer     

The id of an existing record in the staff table. Example: 16

meta   object     

Accept both formats: array of {payment_rate_id, value} or associative map {payment_rate_id: value}.

Task Management

Display a listing of tasks with their assigned workers and individual meta data.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks?location_id=1&task_type=manuring&task_status=in_progress&task_name=Fertilize" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks"
);

const params = {
    "location_id": "1",
    "task_type": "manuring",
    "task_status": "in_progress",
    "task_name": "Fertilize",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'location_id' => '1',
            'task_type' => 'manuring',
            'task_status' => 'in_progress',
            'task_name' => 'Fertilize',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks'
params = {
  'location_id': '1',
  'task_type': 'manuring',
  'task_status': 'in_progress',
  'task_name': 'Fertilize',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": [
        {
            "id": 1,
            "location": {
                "id": 1,
                "name": "A01"
            },
            "taskName": "Fertilize Field A",
            "taskType": "manuring",
            "taskDate": "2025-01-15",
            "taskStatus": "in_progress",
            "createdBy": {
                "id": 1,
                "name": "Manager Name"
            },
            "submittedAt": null,
            "meta": {},
            "workers": [
                {
                    "id": 1,
                    "fullName": "John Doe",
                    "phone": "019-1234567",
                    "meta": {
                        "fertilizer_type": "NPK",
                        "fertilizer_amount": "50"
                    }
                },
                {
                    "id": 2,
                    "fullName": "Jane Smith",
                    "phone": "019-7654321",
                    "meta": {
                        "fertilizer_type": "Urea",
                        "fertilizer_amount": "30"
                    }
                }
            ],
            "createdAt": "2025-01-01 00:00:00",
            "updatedAt": "2025-01-01 00:00:00"
        }
    ],
    "pagination": {
        "current_page": 1,
        "last_page": 1,
        "per_page": 15,
        "total": 1
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/tasks

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

location_id   integer  optional    

Filter tasks by location ID. Example: 1

task_type   string  optional    

Filter tasks by type (manuring/sanitation/pruning/harvesting/planting). Example: manuring

task_status   string  optional    

Filter tasks by status (in_progress/pending/completed). Example: in_progress

task_name   string  optional    

Search tasks by name (partial match). Example: Fertilize

Store a newly created group task in storage (Step 1 of 2).

requires authentication

This creates a group task without workers. Use POST /tasks/{task}/assign-workers to assign workers with their individual meta data (Step 2).

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"location_id\": 1,
    \"task_name\": \"\\\"Fertilize Field A\\\"\",
    \"task_type\": \"manuring\",
    \"task_date\": \"2025-01-15\",
    \"task_status\": \"completed\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "location_id": 1,
    "task_name": "\"Fertilize Field A\"",
    "task_type": "manuring",
    "task_date": "2025-01-15",
    "task_status": "completed"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'location_id' => 1,
            'task_name' => '"Fertilize Field A"',
            'task_type' => 'manuring',
            'task_date' => '2025-01-15',
            'task_status' => 'completed',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks'
payload = {
    "location_id": 1,
    "task_name": "\"Fertilize Field A\"",
    "task_type": "manuring",
    "task_date": "2025-01-15",
    "task_status": "completed"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success - Group Task Created):


{
    "success": true,
    "message": "Task created successfully.",
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Fertilize Field A",
        "taskType": "manuring",
        "taskDate": "2025-01-15",
        "taskStatus": "in_progress",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": null,
        "meta": {},
        "workers": [],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "One or more selected workers are not claimed by the current manager."
}
 

Example response (500, Server Error):


{
    "success": false,
    "message": "Failed to create task.",
    "error": "Error message"
}
 

Request      

POST api/v1/tasks

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

location_id   integer     

The ID of the location. Example: 1

task_name   string     

The name of the task. Example: "Fertilize Field A"

task_type   string     

The type of task (manuring/sanitation/pruning/harvesting/planting). Example: manuring

task_date   date     

The date for the task. Example: 2025-01-15

task_status   string  optional    

Example: completed

Must be one of:
  • in_progress
  • pending
  • completed

Get task breakdown for a single worker for a specific month.

requires authentication

Returns all tasks assigned to the specified worker for the month. Endpoint: GET /tasks/staff/{staff}/breakdown-by-worker?month=1&year=2025

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks/staff/16/breakdown-by-worker?month=1&year=2025" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/staff/16/breakdown-by-worker"
);

const params = {
    "month": "1",
    "year": "2025",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/staff/16/breakdown-by-worker';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '1',
            'year' => '2025',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/staff/16/breakdown-by-worker'
params = {
  'month': '1',
  'year': '2025',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": [
        {
            "worker_id": 1,
            "worker_name": "John Doe",
            "worker_phone": "019-1234567",
            "tasks": [
                {
                    "id": 1,
                    "task_name": "Fertilize Field A",
                    "task_type": "manuring",
                    "task_date": "2025-01-15",
                    "task_status": "completed",
                    "location": {
                        "id": 1,
                        "name": "A01"
                    },
                    "meta": {
                        "fertilizer_type": "NPK",
                        "fertilizer_amount": "50"
                    }
                },
                {
                    "id": 2,
                    "task_name": "Prune Trees",
                    "task_type": "pruning",
                    "task_date": "2025-01-20",
                    "task_status": "completed",
                    "location": {
                        "id": 2,
                        "name": "B02"
                    },
                    "meta": {
                        "pruning_type": "normal pruning"
                    }
                }
            ],
            "total_tasks": 2
        },
        {
            "worker_id": 2,
            "worker_name": "Jane Smith",
            "worker_phone": "019-7654321",
            "tasks": [
                {
                    "id": 3,
                    "task_name": "Harvest Fruits",
                    "task_type": "harvesting",
                    "task_date": "2025-01-18",
                    "task_status": "completed",
                    "location": {
                        "id": 3,
                        "name": "C03"
                    },
                    "meta": {
                        "harvesting_type": "normal harvesting"
                    }
                }
            ],
            "total_tasks": 1
        }
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The month field is required.",
    "errors": {
        "month": [
            "The month field is required."
        ]
    }
}
 

Request      

GET api/v1/tasks/staff/{staff_id}/breakdown-by-worker

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

staff_id   integer     

The ID of the staff. Example: 16

staff   integer     

The staff ID. Example: 5

Query Parameters

month   integer     

The month (1-12). Example: 1

year   integer     

The year (4 digits). Example: 2025

Get task breakdown for all workers in a specific location.

requires authentication

Returns all workers that have tasks in the specified location, with their tasks, types, statuses, and metadata, grouped by worker. Endpoint: GET /tasks/location/{location}/breakdown-by-location

Optional filters:

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks/location/16/breakdown-by-location?month=1&year=2025&task_type=manuring" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/location/16/breakdown-by-location"
);

const params = {
    "month": "1",
    "year": "2025",
    "task_type": "manuring",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/location/16/breakdown-by-location';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '1',
            'year' => '2025',
            'task_type' => 'manuring',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/location/16/breakdown-by-location'
params = {
  'month': '1',
  'year': '2025',
  'task_type': 'manuring',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "location": {
            "id": 1,
            "name": "A01",
            "isActive": true,
            "createdAt": "2025-11-06 12:13:38",
            "updatedAt": "2025-11-06 12:13:38"
        },
        "workers": [
            {
                "worker_id": 1,
                "worker_name": "John Doe",
                "worker_phone": "019-1234567",
                "tasks": [
                    {
                        "id": 1,
                        "task_name": "Fertilize Field A",
                        "task_type": "manuring",
                        "task_date": "2025-01-15",
                        "task_status": "completed",
                        "location": {
                            "id": 1,
                            "name": "A01"
                        },
                        "meta": {
                            "fertilizer_type": "NPK",
                            "fertilizer_amount": "50"
                        }
                    }
                ],
                "total_tasks": 1
            }
        ]
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Request      

GET api/v1/tasks/location/{location_id}/breakdown-by-location

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

location_id   integer     

The ID of the location. Example: 16

location   integer     

The location ID. Example: 1

Query Parameters

month   integer  optional    

The month (1-12). Example: 1

year   integer  optional    

The year (4 digits). Example: 2025

task_type   string  optional    

Filter by task type (manuring/sanitation/pruning/harvesting/planting). Example: manuring

Display the specified task with workers and their individual meta data.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Fertilize Field A",
        "taskType": "manuring",
        "taskDate": "2025-01-15",
        "taskStatus": "in_progress",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": null,
        "meta": {},
        "workers": [
            {
                "id": 1,
                "fullName": "John Doe",
                "phone": "019-1234567",
                "meta": {
                    "fertilizer_type": "NPK",
                    "fertilizer_amount": "50"
                }
            },
            {
                "id": 2,
                "fullName": "Jane Smith",
                "phone": "019-7654321",
                "meta": {
                    "fertilizer_type": "Urea",
                    "fertilizer_amount": "30"
                }
            }
        ],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Request      

GET api/v1/tasks/{task_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

Update the specified task in storage (basic info only).

requires authentication

Note: To assign/reassign workers, use the POST /tasks/{task}/assign-workers endpoint.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/tasks/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"task_name\": \"\\\"Updated Task Name\\\"\",
    \"task_type\": \"sanitation\",
    \"task_date\": \"2025-01-20\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "task_name": "\"Updated Task Name\"",
    "task_type": "sanitation",
    "task_date": "2025-01-20"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'task_name' => '"Updated Task Name"',
            'task_type' => 'sanitation',
            'task_date' => '2025-01-20',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16'
payload = {
    "task_name": "\"Updated Task Name\"",
    "task_type": "sanitation",
    "task_date": "2025-01-20"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Task updated successfully.",
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Updated Task Name",
        "taskType": "sanitation",
        "taskDate": "2025-01-20",
        "taskStatus": "in_progress",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": null,
        "meta": {},
        "workers": [],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (500, Server Error):


{
    "success": false,
    "message": "Failed to update task.",
    "error": "Error message"
}
 

Request      

PUT api/v1/tasks/{task_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

Body Parameters

task_name   string  optional    

The name of the task. Example: "Updated Task Name"

task_type   string  optional    

The type of task (manuring/sanitation/pruning/harvesting/planting). Example: sanitation

task_date   date  optional    

The date for the task. Example: 2025-01-20

Submit a task for review.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks/16/submit" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16/submit"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/submit';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/submit'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Task submitted successfully.",
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Fertilize Field A",
        "taskType": "manuring",
        "taskDate": "2025-01-15",
        "taskStatus": "pending",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": "2025-01-15 14:30:00",
        "meta": {
            "fertilizer_type": "NPK",
            "fertilizer_amount": "100"
        },
        "workers": [],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-15 14:30:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (422, Task not in progress):


{
    "success": false,
    "message": "Task must be in progress to be submitted."
}
 

Example response (500, Server Error):


{
    "success": false,
    "message": "Failed to submit task.",
    "error": "Error message"
}
 

Request      

POST api/v1/tasks/{task_id}/submit

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

Resume a rejected task back to in_progress status.

requires authentication

This endpoint allows managers to resume work on a task that was previously rejected by a checker. The task status will be changed from "rejected" to "in_progress".

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks/16/resume" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"remarks\": \"\\\"Addressing feedback from checker\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16/resume"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "remarks": "\"Addressing feedback from checker\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/resume';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'remarks' => '"Addressing feedback from checker"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/resume'
payload = {
    "remarks": "\"Addressing feedback from checker\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Task resumed successfully.",
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Fertilize Field A",
        "taskType": "manuring",
        "taskDate": "2025-01-15",
        "taskStatus": "in_progress",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": null,
        "meta": {},
        "workers": [],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-15 14:30:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (422, Task not rejected):


{
    "success": false,
    "message": "Task must be in rejected status to be resumed."
}
 

Example response (500, Server Error):


{
    "success": false,
    "message": "Failed to resume task.",
    "error": "Error message"
}
 

Request      

POST api/v1/tasks/{task_id}/resume

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

task   integer     

The ID of the task to resume. Example: 1

Body Parameters

remarks   string  optional    

nullable Optional remarks for resuming the task. Example: "Addressing feedback from checker"

Assign workers to an existing task with their individual meta data (Step 2 of 2).

requires authentication

This endpoint assigns workers to a group task and stores each worker's individual meta data. Use this after creating a task with POST /tasks.

Behavior:

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks/16/assign-workers" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"workers\": {
        \"0\": {
            \"staff_id\": 1,
            \"meta\": {
                \"fertilizer_type\": \"NPK\",
                \"fertilizer_amount\": 50
            }
        },
        \"1\": {
            \"staff_id\": 2,
            \"meta\": {
                \"fertilizer_type\": \"MOP\",
                \"fertilizer_amount\": 30
            }
        },
        \"*\": {
            \"meta\": {
                \"pruning_type\": \"\\\"normal pruning\\\"\",
                \"harvesting_type\": \"\\\"normal harvesting\\\"\",
                \"fertilizer_type\": \"\\\"NPK\\\"\",
                \"fertilizer_amount\": 50,
                \"sanitation_type\": \"\\\"spraying\\\"\",
                \"herbicide_amount\": 100
            }
        }
    }
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16/assign-workers"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "workers": {
        "0": {
            "staff_id": 1,
            "meta": {
                "fertilizer_type": "NPK",
                "fertilizer_amount": 50
            }
        },
        "1": {
            "staff_id": 2,
            "meta": {
                "fertilizer_type": "MOP",
                "fertilizer_amount": 30
            }
        },
        "*": {
            "meta": {
                "pruning_type": "\"normal pruning\"",
                "harvesting_type": "\"normal harvesting\"",
                "fertilizer_type": "\"NPK\"",
                "fertilizer_amount": 50,
                "sanitation_type": "\"spraying\"",
                "herbicide_amount": 100
            }
        }
    }
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/assign-workers';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => \Symfony\Component\VarExporter\Internal\Hydrator::hydrate(
            $o = [
                clone (($p = &\Symfony\Component\VarExporter\Internal\Registry::$prototypes)['stdClass'] ?? \Symfony\Component\VarExporter\Internal\Registry::p('stdClass')),
                clone $p['stdClass'],
                clone $p['stdClass'],
                clone $p['stdClass'],
            ],
            null,
            [
                'stdClass' => [
                    'staff_id' => [
                        1,
                        2 => 2,
                    ],
                    'meta' => [
                        $o[1],
                        2 => $o[3],
                    ],
                    'fertilizer_type' => [
                        1 => 'NPK',
                        3 => 'MOP',
                    ],
                    'fertilizer_amount' => [
                        1 => 50,
                        3 => 30,
                    ],
                ],
            ],
            [
                'workers' => [
                    $o[0],
                    $o[2],
                    '*' => [
                        'meta' => [
                            'pruning_type' => '"normal pruning"',
                            'harvesting_type' => '"normal harvesting"',
                            'fertilizer_type' => '"NPK"',
                            'fertilizer_amount' => 50,
                            'sanitation_type' => '"spraying"',
                            'herbicide_amount' => 100,
                        ],
                    ],
                ],
            ],
            []
        ),
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/assign-workers'
payload = {
    "workers": {
        "0": {
            "staff_id": 1,
            "meta": {
                "fertilizer_type": "NPK",
                "fertilizer_amount": 50
            }
        },
        "1": {
            "staff_id": 2,
            "meta": {
                "fertilizer_type": "MOP",
                "fertilizer_amount": 30
            }
        },
        "*": {
            "meta": {
                "pruning_type": "\"normal pruning\"",
                "harvesting_type": "\"normal harvesting\"",
                "fertilizer_type": "\"NPK\"",
                "fertilizer_amount": 50,
                "sanitation_type": "\"spraying\"",
                "herbicide_amount": 100
            }
        }
    }
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Workers assigned successfully.",
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Fertilize Field A",
        "taskType": "manuring",
        "taskDate": "2025-01-15",
        "taskStatus": "in_progress",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": null,
        "meta": {},
        "workers": [
            {
                "id": 1,
                "fullName": "John Doe",
                "phone": "019-1234567",
                "meta": {
                    "fertilizer_type": "NPK",
                    "fertilizer_amount": "50"
                }
            }
        ],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "One or more selected workers are not claimed by the current manager."
}
 

Request      

POST api/v1/tasks/{task_id}/assign-workers

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

Body Parameters

workers   string[]     

Array of workers with their individual meta data.

staff_id   string     

The id of an existing record in the staff table. Example: architecto

meta   object     
*   object  optional    
staff_id   integer     

The ID of the staff member. Example: 1

meta   object     

(except planting) Worker-specific metadata based on task type. Not required for planting tasks.

Meta Fields Structure by Task Type:

1. Pruning

  • meta_key: pruning_type
  • meta_value: "normal pruning" or "routine pruning"
  • Example: {"pruning_type": "normal pruning"}

2. Harvesting

  • meta_key: harvesting_type
  • meta_value: "normal harvesting" or "collect loose fruits"
  • Example: {"harvesting_type": "normal harvesting"}

3. Planting

  • No meta required
  • Example: {} or omit meta field

4. Manuring

  • meta_key: fertilizer_type
  • meta_value: "NPK" or "BORATE" or "MOP"
  • meta_key: fertilizer_amount
  • meta_value: integer (amount of fertilizer)
  • Example: {"fertilizer_type": "NPK", "fertilizer_amount": 50}

5. Sanitation

  • meta_key: sanitation_type

  • meta_value: "spraying" or "slashing"

  • If sanitation_type is "spraying":

    • meta_key: herbicide_amount
    • meta_value: integer (amount of herbicide)
    • Example: {"sanitation_type": "spraying", "herbicide_amount": 100}
  • If sanitation_type is "slashing":

    • No additional meta data required (physical work, no machines used)
pruning_type   string  optional    

For pruning tasks. Allowed values: "normal pruning", "routine pruning". Example: "normal pruning"

harvesting_type   string  optional    

For harvesting tasks. Allowed values: "normal harvesting", "collect loose fruits". Example: "normal harvesting"

fertilizer_type   string  optional    

For manuring tasks. Allowed values: "NPK", "BORATE", "MOP". Example: "NPK"

fertilizer_amount   integer  optional    

For manuring tasks. Amount of fertilizer used. Example: 50

sanitation_type   string  optional    

For sanitation tasks. Allowed values: "spraying", "slashing". Example: "spraying"

herbicide_amount   integer  optional    

For sanitation tasks when sanitation_type is "spraying". Amount of herbicide used. Example: 100

Remove workers from a task.

requires authentication

This endpoint removes one or more workers from a task along with their metadata.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/tasks/16/remove-workers" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"staff_ids\": [
        1,
        2,
        3
    ]
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16/remove-workers"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "staff_ids": [
        1,
        2,
        3
    ]
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/remove-workers';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'staff_ids' => [
                1,
                2,
                3,
            ],
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/remove-workers'
payload = {
    "staff_ids": [
        1,
        2,
        3
    ]
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Workers removed successfully.",
    "data": {
        "id": 1,
        "location": {
            "id": 1,
            "name": "A01"
        },
        "taskName": "Fertilize Field A",
        "taskType": "manuring",
        "taskDate": "2025-01-15",
        "taskStatus": "in_progress",
        "createdBy": {
            "id": 1,
            "name": "Manager Name"
        },
        "submittedAt": null,
        "meta": {},
        "workers": [],
        "createdAt": "2025-01-01 00:00:00",
        "updatedAt": "2025-01-01 00:00:00"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The staff ids field is required."
}
 

Request      

POST api/v1/tasks/{task_id}/remove-workers

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

task   integer     

The ID of the task. Example: 1

Body Parameters

staff_ids   string[]     

Array of staff IDs to remove.

Get task logs for a specific task.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/tasks/16/logs" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16/logs"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/logs';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16/logs'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "data": [
        {
            "id": 1,
            "task_id": 1,
            "user_id": 2,
            "task_status": "approved",
            "remarks": "Task completed successfully",
            "user": {
                "id": 2,
                "user_fullname": "Manager Name"
            },
            "created_at": "2025-01-15 14:30:00",
            "updated_at": "2025-01-15 14:30:00"
        },
        {
            "id": 2,
            "task_id": 1,
            "user_id": 2,
            "task_status": "rejected",
            "remarks": "Need more details",
            "user": {
                "id": 2,
                "user_fullname": "Manager Name"
            },
            "created_at": "2025-01-15 10:15:00",
            "updated_at": "2025-01-15 10:15:00"
        }
    ]
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Request      

GET api/v1/tasks/{task_id}/logs

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

Remove the specified task from storage.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/tasks/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/tasks/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/tasks/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/tasks/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Task deleted successfully."
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Task not found):


{
    "success": false,
    "message": "Task not found"
}
 

Example response (500, Server Error):


{
    "success": false,
    "message": "Failed to delete task.",
    "error": "Error message"
}
 

Request      

DELETE api/v1/tasks/{task_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

task_id   integer     

The ID of the task. Example: 16

User Attendance

Get User Attendance Records

requires authentication

Retrieve a paginated list of user attendance records for a specific date attendance. This endpoint returns all user members with their attendance status (Absent, Check in, or Present) for the specified date attendance ID.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/user-attendance?date_attendance_id=1&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 16,
    \"page\": 22,
    \"per_page\": 7
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance"
);

const params = {
    "date_attendance_id": "1",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 16,
    "page": 22,
    "per_page": 7
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'date_attendance_id' => '1',
            'page' => '1',
            'per_page' => '10',
        ],
        'json' => [
            'date_attendance_id' => 16,
            'page' => 22,
            'per_page' => 7,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance'
payload = {
    "date_attendance_id": 16,
    "page": 22,
    "per_page": 7
}
params = {
  'date_attendance_id': '1',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User attendance retrieved successfully",
    "data": {
        "data": [
            {
                "user_id": 1,
                "user_img": "user_avatar.jpg",
                "user_name": "John Doe",
                "status": "Present",
                "check_in": "2025-01-15 08:00:00",
                "check_out": "2025-01-15 17:00:00",
                "checkedin_by": "Admin User",
                "checkedout_by": "Admin User"
            },
            {
                "user_id": 2,
                "user_img": "user_avatar2.jpg",
                "user_name": "Jane Smith",
                "status": "Check_in",
                "check_in": "2025-01-15 08:30:00",
                "check_out": null,
                "checkedin_by": "Manager User",
                "checkedout_by": null
            },
            {
                "user_id": 3,
                "user_img": "user_avatar3.jpg",
                "user_name": "Mike Johnson",
                "status": "Absent",
                "check_in": null,
                "check_out": null,
                "checkedin_by": null,
                "checkedout_by": null
            }
        ],
        "current_page": 1,
        "per_page": 15,
        "total": 50,
        "last_page": 4,
        "from": 1,
        "to": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "date_attendance_id": [
            "The date attendance id field is required."
        ],
        "page": [
            "The page field must be at least 1."
        ],
        "per_page": [
            "The per page field must not be greater than 100."
        ]
    }
}
 

Request      

GET api/v1/user-attendance

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

date_attendance_id   integer     

The date attendance ID to filter by. Example: 1

page   integer  optional    

Page number for pagination (default: 1). Example: 1

per_page   integer  optional    

Number of records per page (default: 15, max: 100). Example: 10

Body Parameters

date_attendance_id   integer     

The id of an existing record in the date_attendance table. Example: 16

page   integer  optional    

Must be at least 1. Example: 22

per_page   integer  optional    

Must be at least 1. Must not be greater than 100. Example: 7

Show User Attendance Analytics

requires authentication

Retrieve the analytics of a user attendance record. This endpoint returns the analytics of the attendance record for the user ID.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/analytics?month=2025-01" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/analytics"
);

const params = {
    "month": "2025-01",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/analytics';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/analytics'
params = {
  'month': '2025-01',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User attendance analytics retrieved successfully",
    "data": {
        "user_id": 1,
        "month": "2025-01",
        "attendance_rate": 90,
        "punctuality_rate": 90,
        "number_absent": 1,
        "total_days": 20,
        "total_present": 18
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to view user attendance"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "User not found"
}
 

Request      

GET api/v1/user-attendance/{user_id}/analytics

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   string     

The ID of the user. Example: architecto

user   integer     

The ID of the user. Example: 1

Query Parameters

month   string  optional    

nullable The month of the attendance record. Example: 2025-01

Get Specific User Attendance Records

requires authentication

Retrieve the details of a specific user attendance record. This endpoint returns the attendance record for the specified user ID and month.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/records?month=2025-01&status=present%2C+check_in%2C+check_out%2C+absent&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/records"
);

const params = {
    "month": "2025-01",
    "status": "present, check_in, check_out, absent",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/records';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
            'status' => 'present, check_in, check_out, absent',
            'page' => '1',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/records'
params = {
  'month': '2025-01',
  'status': 'present, check_in, check_out, absent',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User attendance retrieved successfully",
    "data": {
        "data": [
            {
                "id": 1,
                "date": "19-01-2025",
                "status": "Present",
                "checkedin_by": "Admin User",
                "checkedout_by": "Admin User",
                "check_in": "2025-01-19 07:30:00",
                "check_out": "2025-01-19 17:00:00",
                "duration": 34200,
                "remark_late": null,
                "notes": null
            },
            {
                "id": 2,
                "date": "20-01-2025",
                "status": "Check_in",
                "checkedin_by": "Manager User",
                "checkedout_by": null,
                "check_in": "2025-01-20 08:00:00",
                "check_out": null,
                "duration": null,
                "remark_late": "Traffic jam",
                "notes": null
            },
            {
                "id": 3,
                "date": "21-01-2025",
                "status": "Absent",
                "checkedin_by": null,
                "checkedout_by": null,
                "check_in": null,
                "check_out": null,
                "duration": null,
                "remark_late": null,
                "notes": null
            }
        ],
        "current_page": 1,
        "per_page": 15,
        "total": 50,
        "last_page": 4,
        "from": 1,
        "to": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "User not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "user_id": [
            "The user id field is required."
        ],
        "month": [
            "The month field is required."
        ]
    }
}
 

Request      

GET api/v1/user-attendance/{user_id}/records

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   string     

The ID of the user. Example: architecto

user   integer     

The ID of the user. Example: 1

Query Parameters

month   string  optional    

nullable The month of the attendance record. Example: 2025-01

status   string  optional    

nullable The status of the attendance record. Example: present, check_in, check_out, absent

page   integer  optional    

Page number for pagination (default: 1). Example: 1

per_page   integer  optional    

Number of records per page (default: 15, max: 100). Example: 10

Get User Leave Records

requires authentication

Retrieve a paginated list of user leave attendance records. This endpoint returns only leave types (sick_leave, annual_leave, unpaid_leave).

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/leaves?month=2025-01&status=%22sick_leave%22&page=1&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/leaves"
);

const params = {
    "month": "2025-01",
    "status": ""sick_leave"",
    "page": "1",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/leaves';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'month' => '2025-01',
            'status' => '"sick_leave"',
            'page' => '1',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/architecto/leaves'
params = {
  'month': '2025-01',
  'status': '"sick_leave"',
  'page': '1',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User leave records retrieved successfully",
    "data": {
        "data": [
            {
                "id": 1,
                "date": "24-10-2025",
                "type_of_leave": "Annual Leave",
                "created_by": "Admin User",
                "created_at": "2025-10-24T08:00:00.000000Z",
                "start_date": "24-10-2025",
                "end_date": "24-10-2025",
                "remarks": "Going back to hometown: Family passed away"
            },
            {
                "id": 2,
                "date": "25-10-2025",
                "type_of_leave": "Sick Leave",
                "created_by": "Manager User",
                "created_at": "2025-10-25T08:00:00.000000Z",
                "start_date": "25-10-2025",
                "end_date": "25-10-2025",
                "remarks": "Medical appointment"
            }
        ],
        "current_page": 1,
        "per_page": 15,
        "total": 50,
        "last_page": 4,
        "from": 1,
        "to": 15
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "User not found"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "month": [
            "The month must be in Y-m format (e.g., 2025-01)"
        ]
    }
}
 

Request      

GET api/v1/user-attendance/{user_id}/leaves

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   string     

The ID of the user. Example: architecto

user   integer     

The ID of the user. Example: 1

Query Parameters

month   string  optional    

nullable The month of the leave records. Example: 2025-01

status   string  optional    

nullable The type of leave. Must be "sick_leave", "annual_leave", "unpaid_leave". Example: "sick_leave"

page   integer  optional    

Page number for pagination (default: 1). Example: 1

per_page   integer  optional    

Number of records per page (default: 15, max: 100). Example: 10

Check In User

requires authentication

Record user check-in time with offline sync support. This endpoint handles duplicate submissions intelligently by always saving the earliest time.

Offline Sync Logic:

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/check-in" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 1,
    \"user_id\": 1,
    \"check_in\": \"2025-01-15 08:00:00\",
    \"remark_late\": \"\\\"Traffic jam\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/check-in"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 1,
    "user_id": 1,
    "check_in": "2025-01-15 08:00:00",
    "remark_late": "\"Traffic jam\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/check-in';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date_attendance_id' => 1,
            'user_id' => 1,
            'check_in' => '2025-01-15 08:00:00',
            'remark_late' => '"Traffic jam"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/check-in'
payload = {
    "date_attendance_id": 1,
    "user_id": 1,
    "check_in": "2025-01-15 08:00:00",
    "remark_late": "\"Traffic jam\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, New Check-in Record):


{
    "success": true,
    "message": "You checked in successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 08:00:00",
        "check_out": null,
        "status": "check_in",
        "duration": null,
        "remark_late": "Traffic jam",
        "notes": null,
        "checkedin_by": 1,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, Updated Check-in Time):


{
    "success": true,
    "message": "User check-in updated successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 07:30:00",
        "check_out": "2025-01-15 17:00:00",
        "status": "present",
        "duration": 34200,
        "remark_late": "Early arrival",
        "notes": null,
        "checkedin_by": 2,
        "checkedout_by": 1,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T07:30:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record attendance"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "check_in": [
            "The check in field is required."
        ]
    }
}
 

Request      

POST api/v1/user-attendance/check-in

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date_attendance_id   integer     

The date attendance ID. Example: 1

user_id   integer     

The user member ID. Example: 1

check_in   string     

Check-in time in Y-m-d H:i:s format. Example: 2025-01-15 08:00:00

remark_late   string  optional    

nullable Late remark. Example: "Traffic jam"

Check Out User

requires authentication

Record user check-out time with offline sync support. This endpoint handles duplicate submissions intelligently by always saving the latest time.

Offline Sync Logic:

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/check-out" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 1,
    \"user_id\": 1,
    \"check_out\": \"2025-01-15 17:00:00\",
    \"notes\": \"architecto\",
    \"remark_ot\": \"\\\"Extra work required\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/check-out"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 1,
    "user_id": 1,
    "check_out": "2025-01-15 17:00:00",
    "notes": "architecto",
    "remark_ot": "\"Extra work required\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/check-out';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date_attendance_id' => 1,
            'user_id' => 1,
            'check_out' => '2025-01-15 17:00:00',
            'notes' => 'architecto',
            'remark_ot' => '"Extra work required"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/check-out'
payload = {
    "date_attendance_id": 1,
    "user_id": 1,
    "check_out": "2025-01-15 17:00:00",
    "notes": "architecto",
    "remark_ot": "\"Extra work required\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, New Check-out Record):


{
    "success": true,
    "message": "You checked out successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 08:00:00",
        "check_out": "2025-01-15 17:00:00",
        "status": "present",
        "duration": 32400,
        "remark_late": null,
        "notes": "Extra work required",
        "checkedin_by": 1,
        "checkedout_by": 1,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T17:00:00.000000Z"
    }
}
 

Example response (201, Updated Check-out Time):


{
    "success": true,
    "message": "User check-out updated successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15 08:00:00",
        "check_out": "2025-01-15 18:00:00",
        "status": "present",
        "duration": 36000,
        "remark_late": null,
        "notes": "Extended hours",
        "checkedin_by": 1,
        "checkedout_by": 2,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T18:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record attendance"
}
 

Example response (422, No Check-in Found):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "check_out": [
            "User must check in before checking out"
        ]
    }
}
 

Request      

POST api/v1/user-attendance/check-out

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date_attendance_id   integer     

The date attendance ID. Example: 1

user_id   integer     

The user member ID. Example: 1

check_out   string     

Check-out time in Y-m-d H:i:s format. Example: 2025-01-15 17:00:00

notes   string  optional    

Example: architecto

remark_ot   string  optional    

nullable Overtime remark. Example: "Extra work required"

Mark User as Absent

requires authentication

Mark user as absent for a specific date attendance. This will clear any existing check-in/out times and set status to absent. If user has already checked in, the request will be ignored.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/mark-absent" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"date_attendance_id\": 1,
    \"user_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/mark-absent"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "date_attendance_id": 1,
    "user_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/mark-absent';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'date_attendance_id' => 1,
            'user_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/mark-absent'
payload = {
    "date_attendance_id": 1,
    "user_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, User Already Present):


{
    "success": true,
    "message": "User is already present, absent request ignored",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15T08:00:00.000000Z",
        "check_out": null,
        "status": "check_in",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": 1,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, User Marked Absent):


{
    "success": true,
    "message": "You marked yourself as absent successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "absent",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": null,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record attendance"
}
 

Request      

POST api/v1/user-attendance/mark-absent

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

date_attendance_id   integer     

The date attendance ID. Example: 1

user_id   integer     

The user member ID. Example: 1

Mark User as Leave

requires authentication

Mark user as leave (sick leave, annual leave, or unpaid leave) for a date range. This will clear any existing check-in/out times and set status to the specified leave type for each date. If user has already checked in on a date, that date will be skipped.

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/mark-leave" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"user_id\": 1,
    \"from_date\": \"2025-01-01\",
    \"to_date\": \"2025-01-03\",
    \"status\": \"\\\"sick_leave\\\"\",
    \"notes\": \"\\\"Sick leave for 1 day\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/mark-leave"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "user_id": 1,
    "from_date": "2025-01-01",
    "to_date": "2025-01-03",
    "status": "\"sick_leave\"",
    "notes": "\"Sick leave for 1 day\""
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/mark-leave';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'user_id' => 1,
            'from_date' => '2025-01-01',
            'to_date' => '2025-01-03',
            'status' => '"sick_leave"',
            'notes' => '"Sick leave for 1 day"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/mark-leave'
payload = {
    "user_id": 1,
    "from_date": "2025-01-01",
    "to_date": "2025-01-03",
    "status": "\"sick_leave\"",
    "notes": "\"Sick leave for 1 day\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, User Already Present):


{
    "success": true,
    "message": "You are already present, leave request ignored",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": "2025-01-15T08:00:00.000000Z",
        "check_out": null,
        "status": "check_in",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": 1,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, User Marked Sick Leave):


{
    "success": true,
    "message": "You marked yourself as sick leave successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "sick_leave",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": null,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (201, User Marked Annual Leave):


{
    "success": true,
    "message": "User marked as annual leave successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "annual_leave",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": null,
        "checkedout_by": null,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T08:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record attendance"
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "Validation Error",
    "errors": {
        "status": [
            "The selected status is invalid."
        ]
    }
}
 

Request      

POST api/v1/user-attendance/mark-leave

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

user_id   integer     

The user member ID. Example: 1

from_date   string     

The date from which the leave is applicable. Example: 2025-01-01

to_date   string     

The date to which the leave is applicable. Example: 2025-01-03

status   string     

The type of leave. Must be "sick_leave", "annual_leave", "unpaid_leave". Example: "sick_leave"

notes   string  optional    

nullable Notes for the leave. Example: "Sick leave for 1 day"

Update User Leave Attendance

requires authentication

Update a user leave attendance record. Only leave types (sick_leave, annual_leave, unpaid_leave) can be updated.

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"status\": \"\\\"sick_leave\\\"\",
    \"notes\": \"\\\"Updated sick leave notes\\\"\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "status": "\"sick_leave\"",
    "notes": "\"Updated sick leave notes\""
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/1';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'status' => '"sick_leave"',
            'notes' => '"Updated sick leave notes"',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/1'
payload = {
    "status": "\"sick_leave\"",
    "notes": "\"Updated sick leave notes\""
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User leave attendance updated successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "sick_leave",
        "duration": null,
        "remark_late": null,
        "notes": "Updated sick leave notes",
        "checkedin_by": 2,
        "checkedout_by": 2,
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T09:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record attendance"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Attendance record not found"
}
 

Example response (422, Not a Leave Type):


{
    "success": false,
    "message": "Only leave attendance records can be updated"
}
 

Request      

PUT api/v1/user-attendance/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The attendance record ID. Example: 1

Body Parameters

status   string  optional    

nullable The type of leave. Must be "sick_leave", "annual_leave", "unpaid_leave". Example: "sick_leave"

notes   string  optional    

nullable Notes for the leave. Example: "Updated sick leave notes"

Delete User Leave Attendance

requires authentication

Soft delete a user leave attendance record. Only leave types (sick_leave, annual_leave, unpaid_leave) can be deleted.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/1" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/1"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/1';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/1'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User leave attendance deleted successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "date_attendance_id": 1,
        "check_in": null,
        "check_out": null,
        "status": "sick_leave",
        "duration": null,
        "remark_late": null,
        "notes": null,
        "checkedin_by": 2,
        "checkedout_by": 2,
        "deleted_at": "2025-01-15T09:00:00.000000Z",
        "created_at": "2025-01-15T08:00:00.000000Z",
        "updated_at": "2025-01-15T09:00:00.000000Z"
    }
}
 

Example response (403, Forbidden):


{
    "success": false,
    "message": "You do not have permission to record attendance"
}
 

Example response (404, Not Found):


{
    "success": false,
    "message": "Attendance record not found"
}
 

Example response (422, Not a Leave Type):


{
    "success": false,
    "message": "Only leave attendance records can be deleted"
}
 

Request      

DELETE api/v1/user-attendance/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The attendance record ID. Example: 1

Mark All attendance that is not checked out yet to be checked out

requires authentication

Mark user attendance that is not checked out yet to set the checkout time. Checkout time will be set to 4pm on the same date as check-in. Should be done with cron job every 7 PM. Only for user attendance that is not checked out yet. Processes all attendance records (not just today).

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/user-attendance/auto-checkout" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/user-attendance/auto-checkout"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "POST",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/auto-checkout';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/user-attendance/auto-checkout'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers)
response.json()

Example response (200, All attendance that is not checked out yet to be checked out):


{
    "success": true,
    "message": "All attendance that is not checked out yet to be checked out",
    "data": {
        "count": 10
    }
}
 

Request      

POST api/v1/user-attendance/auto-checkout

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

User Payroll Management

Get list of users with their payroll information for manage payroll page.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payroll/users?role=mandor&search=john" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/users"
);

const params = {
    "role": "mandor",
    "search": "john",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/users';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'role' => 'mandor',
            'search' => 'john',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/users'
params = {
  'role': 'mandor',
  'search': 'john',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Users list retrieved successfully",
    "data": [
        {
            "id": 1,
            "user_fullname": "Oikawa Yamaguchi",
            "user_nickname": "Oikawa",
            "user_role": "mandor",
            "user_img": null,
            "user_dob": "1996-01-15",
            "age": 29,
            "user_employment_start_date": "2024-02-01",
            "joined_since": "2024",
            "base_salary": {
                "base_salary": 2500,
                "updated_at": "2025-11-04T10:00:00.000000Z"
            },
            "payslips_count": 5
        }
    ]
}
 

Request      

GET api/v1/payroll/users

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

role   string  optional    

Filter by user role (mandor/checker/admin). Example: mandor

search   string  optional    

Search users by name or nickname. Example: john

Get employment overview for a specific user including all payslip records.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payroll/users/16/overview" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/users/16/overview"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/users/16/overview';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/users/16/overview'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Employment overview retrieved successfully",
    "data": {
        "user": {
            "id": 1,
            "user_fullname": "Oikawa Yamaguchi",
            "user_nickname": "Oikawa",
            "user_role": "mandor",
            "user_img": null,
            "user_dob": "1996-01-15",
            "age": 29,
            "user_employment_start_date": "2024-02-01",
            "joined_since": "2024"
        },
        "base_salary": 2500,
        "payslips": [
            {
                "id": 5,
                "payslip_month": "May 2025",
                "payslip_month_short": "05/25",
                "net_salary": 1571.3800000000001091393642127513885498046875,
                "status": "generated",
                "created_at": "2025-11-05T08:30:00.000000Z"
            }
        ]
    }
}
 

Request      

GET api/v1/payroll/users/{user_id}/overview

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user. Example: 1

Generate a new payslip for a user.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/payroll/users/16/generate" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"payslip_month\": \"06\\/25\",
    \"base_salary\": 2500,
    \"deductions\": [
        \"architecto\"
    ],
    \"advance_repayment_amount\": 5,
    \"advance_repayment_remarks\": \"j\",
    \"employer_epf\": 17,
    \"employer_socso\": 5,
    \"employer_eis\": 8,
    \"employer_pcb\": 14
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/users/16/generate"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "payslip_month": "06\/25",
    "base_salary": 2500,
    "deductions": [
        "architecto"
    ],
    "advance_repayment_amount": 5,
    "advance_repayment_remarks": "j",
    "employer_epf": 17,
    "employer_socso": 5,
    "employer_eis": 8,
    "employer_pcb": 14
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/users/16/generate';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'payslip_month' => '06/25',
            'base_salary' => 2500.0,
            'deductions' => [
                'architecto',
            ],
            'advance_repayment_amount' => 5,
            'advance_repayment_remarks' => 'j',
            'employer_epf' => 17,
            'employer_socso' => 5,
            'employer_eis' => 8,
            'employer_pcb' => 14,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/users/16/generate'
payload = {
    "payslip_month": "06\/25",
    "base_salary": 2500,
    "deductions": [
        "architecto"
    ],
    "advance_repayment_amount": 5,
    "advance_repayment_remarks": "j",
    "employer_epf": 17,
    "employer_socso": 5,
    "employer_eis": 8,
    "employer_pcb": 14
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Payslip generated successfully",
    "data": {
        "id": 1,
        "user_id": 1,
        "payslip_month": "06/25",
        "base_salary": 2500,
        "total_deduction": 228.6200000000000045474735088646411895751953125,
        "total_income": 2500,
        "net_salary": 2271.3800000000001091393642127513885498046875,
        "status": "generated",
        "deductions": [
            {
                "id": 1,
                "deduction_type": "EPF",
                "deduction_amount": 130.1200000000000045474735088646411895751953125,
                "deduction_note": "Monthly EPF"
            },
            {
                "id": 2,
                "deduction_type": "Lateness",
                "deduction_amount": 98.5,
                "deduction_note": "3 times late"
            }
        ]
    }
}
 

Example response (422, Validation error):


{
    "success": false,
    "message": "Payslip for this month already exists"
}
 

Example response (422, No base salary):


{
    "success": false,
    "message": "User does not have a base salary set. Please set base salary first."
}
 

Request      

POST api/v1/payroll/users/{user_id}/generate

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user. Example: 1

Body Parameters

payslip_month   string     

Month in format MM/YY. Example: 06/25

base_salary   number  optional    

optional Override base salary (uses user's base salary if not provided). Example: 2500

deductions   string[]  optional    

optional Array of deduction items. If not provided or empty, total_deduction will be 0. If provided, total is auto-calculated from sum.

deduction_type   string     

Must not be greater than 255 characters. Example: w

deduction_amount   number     

Must be at least 0. Must not be greater than 99999999.99. Example: 22

deduction_note   string  optional    

Must not be greater than 500 characters. Example: y

*   object  optional    
deduction_type   string     

Type of deduction. Example: EPF

deduction_amount   number     

Deduction amount. Example: 130.12

deduction_note   string  optional    

optional Note for this deduction. Example: Monthly EPF contribution

advance_repayment_amount   number  optional    

Advance repayment for user loans (optional). Must be at least 0. Must not be greater than 99999999.99. Example: 5

advance_repayment_remarks   string  optional    

Must not be greater than 500 characters. Example: j

employer_epf   number  optional    

Employer contributions (optional, to display on payslip). Must be at least 0. Must not be greater than 99999999.99. Example: 17

employer_socso   number  optional    

Must be at least 0. Must not be greater than 99999999.99. Example: 5

employer_eis   number  optional    

Must be at least 0. Must not be greater than 99999999.99. Example: 8

employer_pcb   number  optional    

Must be at least 0. Must not be greater than 99999999.99. Example: 14

Get detailed payslip information.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/payroll/payslips/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/payslips/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/payslips/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/payslips/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Payslip details retrieved successfully",
    "data": {
        "id": 1,
        "user": {
            "id": 1,
            "user_fullname": "Oikawa Yamaguchi",
            "user_ic": "6718081017182",
            "user_bank_name": "Maybank",
            "user_bank_number": "161178229300",
            "user_kwsp_number": "123456789012"
        },
        "payslip_month": "06/25",
        "payslip_month_readable": "June 2025",
        "base_salary": 1800,
        "total_income": 1800,
        "total_deduction": 228.6200000000000045474735088646411895751953125,
        "net_salary": 1571.3800000000001091393642127513885498046875,
        "status": "generated",
        "deductions": [
            {
                "id": 1,
                "deduction_type": "EPF",
                "deduction_amount": 130.1200000000000045474735088646411895751953125,
                "deduction_note": null
            },
            {
                "id": 2,
                "deduction_type": "Early Out",
                "deduction_amount": 67.75,
                "deduction_note": "2 days early checkout"
            },
            {
                "id": 3,
                "deduction_type": "Lateness",
                "deduction_amount": 30.75,
                "deduction_note": "Late arrival 3 times"
            }
        ],
        "approved_by": null,
        "received_by": null,
        "created_at": "2025-11-05T08:30:00.000000Z"
    }
}
 

Example response (404, Not found):


{
    "success": false,
    "message": "Payslip not found"
}
 

Request      

GET api/v1/payroll/payslips/{payslip_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

payslip_id   integer     

The ID of the payslip. Example: 16

payslip   integer     

The ID of the payslip. Example: 1

Delete a payslip.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/payroll/payslips/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/payroll/payslips/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/payroll/payslips/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/payroll/payslips/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Payslip deleted successfully"
}
 

Request      

DELETE api/v1/payroll/payslips/{payslip_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

payslip_id   integer     

The ID of the payslip. Example: 16

payslip   integer     

The ID of the payslip. Example: 1

Users

List Users

requires authentication

Returns a paginated list of users. Optionally filter by role.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/users?role=manager&search=john&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"role\": \"mandor\",
    \"search\": \"architecto\",
    \"per_page\": 22
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users"
);

const params = {
    "role": "manager",
    "search": "john",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "role": "mandor",
    "search": "architecto",
    "per_page": 22
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'role' => 'manager',
            'search' => 'john',
            'per_page' => '10',
        ],
        'json' => [
            'role' => 'mandor',
            'search' => 'architecto',
            'per_page' => 22,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users'
payload = {
    "role": "mandor",
    "search": "architecto",
    "per_page": 22
}
params = {
  'role': 'manager',
  'search': 'john',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Users retrieved successfully",
    "data": [
        {
            "id": 2,
            "user_fullname": "Manager Name",
            "user_nickname": "manager1",
            "user_role": "manager",
            "user_img": null,
            "user_phone": "+1234567890",
            "user_ic": "123456789012",
            "user_gender": "male",
            "user_dob": "1990-01-01",
            "user_employment_start_date": "2024-01-15",
            "user_bank_name": "Maybank",
            "user_bank_number": "1234567890",
            "user_kwsp_number": "1234567890"
        },
        {
            "id": 3,
            "user_fullname": "Mandor Name",
            "user_nickname": "mandor1",
            "user_role": "mandor",
            "user_img": null,
            "staff_count": 5,
            "user_phone": "+1234567890",
            "user_ic": "123456789012",
            "user_gender": "male",
            "user_dob": "1990-01-01",
            "user_employment_start_date": "2024-01-15",
            "user_bank_name": "Maybank",
            "user_bank_number": "1234567890",
            "user_kwsp_number": "1234567890"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 2,
        "last_page": 1
    }
}
 

Example response (422, Validation Error):


{
    "success": false,
    "message": "The given data was invalid.",
    "errors": {
        "role": [
            "The selected role is invalid."
        ]
    }
}
 

Request      

GET api/v1/users

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

role   string  optional    

optional Filter by role. One of: admin, manager, checker, mandor. Example: manager

search   string  optional    

optional Search by fullname or nickname. Example: john

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Body Parameters

role   string  optional    

Example: mandor

Must be one of:
  • admin
  • manager
  • checker
  • mandor
search   string  optional    

Example: architecto

per_page   integer  optional    

Must be at least 1. Must not be greater than 100. Example: 22

Show User Details

requires authentication

Retrieve detailed information about a specific user.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/users/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User details retrieved successfully",
    "data": {
        "id": 2,
        "user_fullname": "Manager Name",
        "user_nickname": "manager1",
        "user_role": "manager",
        "user_img": null,
        "user_phone": "+1234567890",
        "user_ic": "123456789012",
        "user_gender": "male",
        "user_dob": "1990-01-01",
        "user_employment_start_date": "2024-01-15",
        "user_bank_name": "Maybank",
        "user_bank_number": "1234567890",
        "user_kwsp_number": "1234567890",
        "staff_count": 5,
        "attendance_count_month": 15,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (404, User not found):


{
    "success": false,
    "message": "User not found"
}
 

Request      

GET api/v1/users/{user_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user. Example: 2

Admin Update User

requires authentication

Allow an admin to update another user's details (profile, role, personal info, etc).

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/users/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"user_fullname\": \"John Doe\",
    \"user_nickname\": \"johndoe\",
    \"user_phone\": \"+1234567890\",
    \"user_role\": \"manager\",
    \"user_gender\": \"male\",
    \"user_dob\": \"1990-01-01\",
    \"user_ic\": \"123456789012\",
    \"user_bank_name\": \"Maybank\",
    \"user_bank_number\": \"1234567890\",
    \"user_kwsp_number\": \"1234567890\",
    \"user_employment_start_date\": \"2024-01-15\",
    \"user_img\": \"https:\\/\\/example.com\\/image.jpg\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "user_fullname": "John Doe",
    "user_nickname": "johndoe",
    "user_phone": "+1234567890",
    "user_role": "manager",
    "user_gender": "male",
    "user_dob": "1990-01-01",
    "user_ic": "123456789012",
    "user_bank_name": "Maybank",
    "user_bank_number": "1234567890",
    "user_kwsp_number": "1234567890",
    "user_employment_start_date": "2024-01-15",
    "user_img": "https:\/\/example.com\/image.jpg"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'user_fullname' => 'John Doe',
            'user_nickname' => 'johndoe',
            'user_phone' => '+1234567890',
            'user_role' => 'manager',
            'user_gender' => 'male',
            'user_dob' => '1990-01-01',
            'user_ic' => '123456789012',
            'user_bank_name' => 'Maybank',
            'user_bank_number' => '1234567890',
            'user_kwsp_number' => '1234567890',
            'user_employment_start_date' => '2024-01-15',
            'user_img' => 'https://example.com/image.jpg',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16'
payload = {
    "user_fullname": "John Doe",
    "user_nickname": "johndoe",
    "user_phone": "+1234567890",
    "user_role": "manager",
    "user_gender": "male",
    "user_dob": "1990-01-01",
    "user_ic": "123456789012",
    "user_bank_name": "Maybank",
    "user_bank_number": "1234567890",
    "user_kwsp_number": "1234567890",
    "user_employment_start_date": "2024-01-15",
    "user_img": "https:\/\/example.com\/image.jpg"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User updated successfully",
    "data": {
        "id": 5,
        "user_nickname": "johndoe",
        "user_fullname": "John Doe",
        "user_role": "manager",
        "user_img": "https://example.com/image.jpg",
        "user_phone": "+1234567890",
        "user_ic": "123456789012",
        "user_gender": "male",
        "user_dob": "1990-01-01",
        "user_bank_name": "Maybank",
        "user_bank_number": "1234567890",
        "user_kwsp_number": "1234567890",
        "user_employment_start_date": "2024-01-15"
    }
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can update other users"
}
 

Example response (404, User not found):


{
    "success": false,
    "message": "User not found"
}
 

Request      

POST api/v1/users/{user_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user to update. Example: 5

Body Parameters

user_fullname   string  optional    

nullable The user's full name. Example: John Doe

user_nickname   string  optional    

nullable The user's nickname (must be unique). Example: johndoe

user_phone   string  optional    

nullable The user's phone number. Example: +1234567890

user_role   string  optional    

nullable The user's role. One of: admin, manager, checker, mandor. Example: manager

user_gender   string  optional    

nullable The user's gender. One of: male, female. Example: male

user_dob   string  optional    

nullable The user's date of birth (YYYY-MM-DD). Example: 1990-01-01

user_ic   string  optional    

nullable The user's IC number (must be unique if provided). Example: 123456789012

user_bank_name   string  optional    

nullable The user's bank name. Example: Maybank

user_bank_number   string  optional    

nullable The user's bank account number. Example: 1234567890

user_kwsp_number   string  optional    

nullable The user's KWSP number. Example: 1234567890

user_employment_start_date   string  optional    

nullable The user's employment start date (YYYY-MM-DD). Example: 2024-01-15

user_img   string|file  optional    

nullable The user's profile image URL or file upload. Example: https://example.com/image.jpg

Admin Change Password

requires authentication

Allow an admin to reset the password for another user (manager, mandor, checker, etc).

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/users/16/change-password" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"password\": \"|]|{+-\",
    \"password_confirmation\": \"architecto\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16/change-password"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "password": "|]|{+-",
    "password_confirmation": "architecto"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16/change-password';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'password' => '|]|{+-',
            'password_confirmation' => 'architecto',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16/change-password'
payload = {
    "password": "|]|{+-",
    "password_confirmation": "architecto"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Password reset successfully"
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can reset user passwords"
}
 

Request      

POST api/v1/users/{user_id}/change-password

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user whose password is being reset. Example: 5

Body Parameters

password   string     

The new password. Must be confirmed. Example: |]|{+-

password_confirmation   string     

The new password confirmation. Example: architecto

Delete a user.

requires authentication

Permanently delete a user from the system. Only admins can delete users. Users cannot delete themselves. This will also delete related records such as claimed staff assignments, base salary, and API tokens.

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/users/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "User deleted successfully"
}
 

Example response (400, Cannot delete self):


{
    "success": false,
    "message": "You cannot delete your own account"
}
 

Example response (401, Unauthenticated):


{
    "success": false,
    "message": "Unauthorized"
}
 

Example response (403, Forbidden - Not Admin):


{
    "success": false,
    "message": "Only admins can delete users"
}
 

Example response (404, User not found):


{
    "success": false,
    "message": "User not found"
}
 

Request      

DELETE api/v1/users/{user_id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

user_id   integer     

The ID of the user. Example: 16

user   integer     

The ID of the user to delete. Example: 2

List Users and Staff

requires authentication

Returns a list of users and staff.

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/users-and-staff?search=john" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"search\": \"architecto\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/users-and-staff"
);

const params = {
    "search": "john",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "architecto"
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/users-and-staff';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'john',
        ],
        'json' => [
            'search' => 'architecto',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/users-and-staff'
payload = {
    "search": "architecto"
}
params = {
  'search': 'john',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, json=payload, params=params)
response.json()

Example response (200, Success):


{
  "success": true,
  "message": "Users and Staff retrieved successfully",
  "data": [
    {
      "user_id": 1,
      "fullname": "Manager Name",
      "role": "user",
      "img": null,
    },
    {
      "staff_id": 3,
      "fullname": "Staff Name",
      "role": "staff",
      "img": null,
    }
  ],
}
 

Request      

GET api/v1/users-and-staff

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

optional Search by fullname. Example: john

Body Parameters

search   string  optional    

Example: architecto

Vehicle Booking Management

Get all vehicle bookings.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/vehicle-bookings?search=Toyota&vehicle_id=1&user_id=1&staff_id=1&date_from=2025-01-01&date_to=2025-12-31&bookingFilter=booking-asc&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings"
);

const params = {
    "search": "Toyota",
    "vehicle_id": "1",
    "user_id": "1",
    "staff_id": "1",
    "date_from": "2025-01-01",
    "date_to": "2025-12-31",
    "bookingFilter": "booking-asc",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'Toyota',
            'vehicle_id' => '1',
            'user_id' => '1',
            'staff_id' => '1',
            'date_from' => '2025-01-01',
            'date_to' => '2025-12-31',
            'bookingFilter' => 'booking-asc',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings'
params = {
  'search': 'Toyota',
  'vehicle_id': '1',
  'user_id': '1',
  'staff_id': '1',
  'date_from': '2025-01-01',
  'date_to': '2025-12-31',
  'bookingFilter': 'booking-asc',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle bookings retrieved successfully",
    "data": [
        {
            "id": 1,
            "vehicle_id": 1,
            "datetime_booking": "2025-01-01 10:00:00",
            "datetime_return": "2025-01-01 18:00:00",
            "user_id": 1,
            "staff_id": null,
            "vehicle": {
                "id": 1,
                "vehicle_name": "Toyota Hilux"
            },
            "user": {
                "id": 1,
                "user_fullname": "John Doe"
            },
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/vehicle-bookings

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

optional Search across vehicle names, plate numbers, user names, staff names, and booking/return dates. Example: Toyota

vehicle_id   integer  optional    

optional Filter by vehicle ID. Example: 1

user_id   integer  optional    

optional Filter by user ID. Example: 1

staff_id   integer  optional    

optional Filter by staff ID. Example: 1

date_from   string  optional    

optional Filter bookings from this date (format: Y-m-d). Example: 2025-01-01

date_to   string  optional    

optional Filter bookings until this date (format: Y-m-d). Example: 2025-12-31

bookingFilter   string  optional    

optional Sort by date. Options: booking-asc, booking-desc, return-asc, return-desc. Defaults to booking-desc. Example: booking-asc

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Store a newly created vehicle booking.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"vehicle_id\": 1,
    \"datetime_booking\": \"2025-01-01 10:00:00\",
    \"datetime_return\": \"2025-01-01 18:00:00\",
    \"user_id\": 1,
    \"staff_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "vehicle_id": 1,
    "datetime_booking": "2025-01-01 10:00:00",
    "datetime_return": "2025-01-01 18:00:00",
    "user_id": 1,
    "staff_id": 1
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'vehicle_id' => 1,
            'datetime_booking' => '2025-01-01 10:00:00',
            'datetime_return' => '2025-01-01 18:00:00',
            'user_id' => 1,
            'staff_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings'
payload = {
    "vehicle_id": 1,
    "datetime_booking": "2025-01-01 10:00:00",
    "datetime_return": "2025-01-01 18:00:00",
    "user_id": 1,
    "staff_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Vehicle booking created successfully",
    "data": {
        "id": 1,
        "vehicle_id": 1,
        "datetime_booking": "2025-01-01 10:00:00",
        "datetime_return": null,
        "user_id": 1,
        "staff_id": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

POST api/v1/vehicle-bookings

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

vehicle_id   integer     

The vehicle ID. Example: 1

datetime_booking   string     

The booking datetime. Example: 2025-01-01 10:00:00

datetime_return   string  optional    

optional The return datetime. Example: 2025-01-01 18:00:00

user_id   integer  optional    

optional The user ID. Example: 1

staff_id   integer  optional    

optional The staff ID. Example: 1

Display the specified vehicle booking.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle booking retrieved successfully",
    "data": {
        "id": 1,
        "vehicle_id": 1,
        "datetime_booking": "2025-01-01 10:00:00",
        "datetime_return": "2025-01-01 18:00:00",
        "user_id": 1,
        "staff_id": null,
        "vehicle": {
            "id": 1,
            "vehicle_name": "Toyota Hilux"
        },
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

GET api/v1/vehicle-bookings/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the vehicle booking. Example: 16

booking   integer     

The ID of the booking. Example: 1

Update the specified vehicle booking.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"vehicle_id\": 1,
    \"datetime_booking\": \"2025-01-01 10:00:00\",
    \"datetime_return\": \"2025-01-01 18:00:00\",
    \"user_id\": 1,
    \"staff_id\": 1
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "vehicle_id": 1,
    "datetime_booking": "2025-01-01 10:00:00",
    "datetime_return": "2025-01-01 18:00:00",
    "user_id": 1,
    "staff_id": 1
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'vehicle_id' => 1,
            'datetime_booking' => '2025-01-01 10:00:00',
            'datetime_return' => '2025-01-01 18:00:00',
            'user_id' => 1,
            'staff_id' => 1,
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16'
payload = {
    "vehicle_id": 1,
    "datetime_booking": "2025-01-01 10:00:00",
    "datetime_return": "2025-01-01 18:00:00",
    "user_id": 1,
    "staff_id": 1
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle booking updated successfully",
    "data": {
        "id": 1,
        "vehicle_id": 1,
        "datetime_booking": "2025-01-01 10:00:00",
        "datetime_return": "2025-01-01 18:00:00",
        "user_id": 1,
        "staff_id": null,
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

PUT api/v1/vehicle-bookings/{id}

PATCH api/v1/vehicle-bookings/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the vehicle booking. Example: 16

booking   integer     

The ID of the booking. Example: 1

Body Parameters

vehicle_id   integer  optional    

optional The vehicle ID. Example: 1

datetime_booking   string  optional    

optional The booking datetime. Example: 2025-01-01 10:00:00

datetime_return   string  optional    

optional The return datetime. Example: 2025-01-01 18:00:00

user_id   integer  optional    

optional The user ID. Example: 1

staff_id   integer  optional    

optional The staff ID. Example: 1

Remove the specified vehicle booking.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicle-bookings/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle booking deleted successfully"
}
 

Request      

DELETE api/v1/vehicle-bookings/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the vehicle booking. Example: 16

booking   integer     

The ID of the booking. Example: 1

Vehicle Management

Get all vehicles.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/vehicles?search=ABC123&status=available&per_page=10" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicles"
);

const params = {
    "search": "ABC123",
    "status": "available",
    "per_page": "10",
};
Object.keys(params)
    .forEach(key => url.searchParams.append(key, params[key]));

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicles';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'query' => [
            'search' => 'ABC123',
            'status' => 'available',
            'per_page' => '10',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicles'
params = {
  'search': 'ABC123',
  'status': 'available',
  'per_page': '10',
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers, params=params)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicles retrieved successfully",
    "data": [
        {
            "id": 1,
            "vehicle_name": "Toyota Hilux",
            "plate_number": "ABC1234",
            "status": "available",
            "created_at": "2025-01-01T00:00:00.000000Z",
            "updated_at": "2025-01-01T00:00:00.000000Z"
        }
    ],
    "meta": {
        "current_page": 1,
        "per_page": 15,
        "total": 1,
        "last_page": 1
    }
}
 

Request      

GET api/v1/vehicles

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Query Parameters

search   string  optional    

optional Search by vehicle name or plate number. Example: ABC123

status   string  optional    

optional Filter by status. Example: available

per_page   integer  optional    

optional Items per page. Defaults to 15. Example: 10

Store a newly created vehicle.

requires authentication

Example request:
curl --request POST \
    "https://megacessdemo.megacess.com/api/v1/vehicles" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"vehicle_name\": \"Toyota Hilux\",
    \"plate_number\": \"ABC1234\",
    \"status\": \"available\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicles"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "vehicle_name": "Toyota Hilux",
    "plate_number": "ABC1234",
    "status": "available"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicles';
$response = $client->post(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'vehicle_name' => 'Toyota Hilux',
            'plate_number' => 'ABC1234',
            'status' => 'available',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicles'
payload = {
    "vehicle_name": "Toyota Hilux",
    "plate_number": "ABC1234",
    "status": "available"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('POST', url, headers=headers, json=payload)
response.json()

Example response (201, Success):


{
    "success": true,
    "message": "Vehicle created successfully",
    "data": {
        "id": 1,
        "vehicle_name": "Toyota Hilux",
        "plate_number": "ABC1234",
        "status": "available",
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

POST api/v1/vehicles

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

Body Parameters

vehicle_name   string     

The vehicle name. Example: Toyota Hilux

plate_number   string     

The plate number. Example: ABC1234

status   string     

The vehicle status. Example: available

Display the specified vehicle.

requires authentication

Example request:
curl --request GET \
    --get "https://megacessdemo.megacess.com/api/v1/vehicles/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicles/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicles/16';
$response = $client->get(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicles/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('GET', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle retrieved successfully",
    "data": {
        "id": 1,
        "vehicle_name": "Toyota Hilux",
        "plate_number": "ABC1234",
        "status": "available",
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

GET api/v1/vehicles/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the vehicle. Example: 16

vehicle   integer     

The ID of the vehicle. Example: 1

Update the specified vehicle.

requires authentication

Example request:
curl --request PUT \
    "https://megacessdemo.megacess.com/api/v1/vehicles/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"vehicle_name\": \"Toyota Hilux\",
    \"plate_number\": \"ABC1234\",
    \"status\": \"available\"
}"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicles/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "vehicle_name": "Toyota Hilux",
    "plate_number": "ABC1234",
    "status": "available"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicles/16';
$response = $client->put(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
        'json' => [
            'vehicle_name' => 'Toyota Hilux',
            'plate_number' => 'ABC1234',
            'status' => 'available',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicles/16'
payload = {
    "vehicle_name": "Toyota Hilux",
    "plate_number": "ABC1234",
    "status": "available"
}
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('PUT', url, headers=headers, json=payload)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle updated successfully",
    "data": {
        "id": 1,
        "vehicle_name": "Toyota Hilux",
        "plate_number": "ABC1234",
        "status": "available",
        "created_at": "2025-01-01T00:00:00.000000Z",
        "updated_at": "2025-01-01T00:00:00.000000Z"
    }
}
 

Request      

PUT api/v1/vehicles/{id}

PATCH api/v1/vehicles/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the vehicle. Example: 16

vehicle   integer     

The ID of the vehicle. Example: 1

Body Parameters

vehicle_name   string  optional    

optional The vehicle name. Example: Toyota Hilux

plate_number   string  optional    

optional The plate number. Example: ABC1234

status   string  optional    

optional The vehicle status. Example: available

Remove the specified vehicle.

requires authentication

Example request:
curl --request DELETE \
    "https://megacessdemo.megacess.com/api/v1/vehicles/16" \
    --header "Authorization: Bearer {YOUR_TOKEN}" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "https://megacessdemo.megacess.com/api/v1/vehicles/16"
);

const headers = {
    "Authorization": "Bearer {YOUR_TOKEN}",
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$url = 'https://megacessdemo.megacess.com/api/v1/vehicles/16';
$response = $client->delete(
    $url,
    [
        'headers' => [
            'Authorization' => 'Bearer {YOUR_TOKEN}',
            'Content-Type' => 'application/json',
            'Accept' => 'application/json',
        ],
    ]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
import requests
import json

url = 'https://megacessdemo.megacess.com/api/v1/vehicles/16'
headers = {
  'Authorization': 'Bearer {YOUR_TOKEN}',
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

response = requests.request('DELETE', url, headers=headers)
response.json()

Example response (200, Success):


{
    "success": true,
    "message": "Vehicle deleted successfully"
}
 

Request      

DELETE api/v1/vehicles/{id}

Headers

Authorization        

Example: Bearer {YOUR_TOKEN}

Content-Type        

Example: application/json

Accept        

Example: application/json

URL Parameters

id   integer     

The ID of the vehicle. Example: 16

vehicle   integer     

The ID of the vehicle. Example: 1