REST API for Cloud Installations
This guide covers using the IceHrm REST API with cloud installations.
Authentication
IceHrm uses OAuth 2.0 bearer authentication. Each API request must include the bearer token in the Authorization header.
Obtaining Your API Token
- Log in to your IceHrm Cloud instance
- Navigate to Basic Information -> Personal Information
- Click the Api Access tab
- Copy your API token
Using the Bearer Token
Include the token in the Authorization header of all API requests:
Authorization: Bearer [your-token]
Enabling the REST API
- Log in as an administrator
- Navigate to Settings -> Other
- Find Enable REST API and set it to Yes
- Save the settings
Cloud API URL Structure
For a cloud instance named test1 (accessible at https://test1.icehrm.com), the API base URL is:
https://icehrm.com/api/test1
Example Requests
Retrieve Current User Data
curl -i https://icehrm.com/api/test1/employees/me \
-H "Authorization: Bearer [TOKEN]"
Create New Employee
curl -X POST \
-H "Authorization: Bearer [TOKEN]" \
-H "Content-Type: application/json" \
-d '{
"employee_id": "EMP003",
"first_name": "John",
"last_name": "Doe",
"nationality": "35",
"birthday": "1990-05-15",
"gender": "Male",
"employment_status": "1",
"job_title": "8",
"department": "2",
"supervisor": "1"
}' \
"https://icehrm.com/api/test1/employees"
Key Fields for Employee Creation
When creating employees, common fields include:
employee_id: Unique employee identifierfirst_name: Employee's first namelast_name: Employee's last namenationality: Nationality IDbirthday: Date of birth (YYYY-MM-DD)gender: Male/Femaleemployment_status: Employment status IDjob_title: Job title IDdepartment: Department IDsupervisor: Supervisor employee IDwork_email: Work email addressmobile_phone: Mobile phone number
API Documentation
For complete API documentation including all available endpoints, see the API Docs section.