API and external integration
HRMS exposes small, focused API surfaces through the Frappe request layer. They support sign-in provider discovery, safe access to roster data and actions, and delivery of selected system and HR settings to clients. The Platform integration and operations page explains the wider platform role of these APIs.
API surface
The API surface uses whitelisted Frappe methods rather than a separate service boundary. Each method returns a narrow result for a client workflow, while Frappe authentication and document permissions protect signed-in operations.
| Capability | API entry point | Main consumer or use |
|---|---|---|
| OAuth provider discovery | hrms.api.oauth.oauth_providers | Login clients that show available external sign-in choices |
| System login policy | hrms.api.system_settings.get_user_pass_login_disabled | Login clients that decide whether password sign-in is available |
| HR client settings | hrms.api.get_hr_settings | Employee-facing clients that enable or disable selected HR features |
| Attendance calendar | hrms.api.get_attendance_calendar_events | Employee-facing clients that show attendance and holiday status by date |
| Roster context and filter access | hrms.api.roster.get_default_company, get_permitted_filter_doctypes | The roster client’s company context and available filter controls |
| Roster context and data | hrms.api.roster.get_default_company, hrms.api.roster.get_events | The roster client’s month view and filters |
| Roster actions | hrms.api.roster.insert_shift, break_shift, swap_shift, and schedule assignment methods | Users who create, change, or remove roster assignments |
The shared HRMS API module also supplies calendar context for an employee. Its holiday lookup honors holiday-list assignments that change during the requested date range, so attendance views use the holiday list that applies on each date rather than one list for the whole range.
OAuth provider discovery
OAuth provider discovery gives an unauthenticated login client the providers that an administrator has enabled and configured. The API checks the provider record and its stored credentials before it returns a provider name, icon, and authorization URL. This keeps incomplete provider setup out of the login screen.
The authorization URL points the user toward the Frappe OAuth flow with HRMS as the return target. The login view fetches this list when it loads, so the available choices follow current provider configuration rather than a fixed client list.
sequenceDiagram
participant C as Login client
participant H as HRMS API
participant F as Frappe provider setup
participant P as External identity provider
C->>H: Request oauth_providers
H->>F: Read enabled, complete providers
F-->>H: Provider details and authorization URLs
H-->>C: Usable provider list
C->>P: Open selected authorization URL
P-->>C: Return through the Frappe OAuth flow
References: hrms/…/oauth.py• L4-33 frontend/…/Login.vue• L191-194
System and HR settings
The settings APIs expose only the values that client behavior needs. The guest-callable system endpoint returns whether password login is disabled, while the signed-in HR endpoint returns the small set of HR flags used by the employee-facing client.
This boundary separates configuration used by the login screen from configuration used after sign-in. The HR settings endpoint does not act as a general settings export; its response is a deliberate client contract containing mobile check-in, geolocation, self-approval, and multi-currency expense behavior.
The HR Settings record also governs wider HR behavior, such as reminder timing, leave approval rules, and shift controls. Its validation protects changes to reminder frequency and can warn when a change would leave a gap between scheduled reminder jobs. Changes to that record can therefore affect both API results and the workflows that consume those settings. The Frappe extension lifecycle page covers the broader configuration and framework links.
References: hrms/…/system_settings.py• L4-6 hrms/…/__init__.py• L99-108 hrms/…/hr_settings.json• L36-47 hrms/…/hr_settings.json• L276-326 hrms/…/hr_settings.py• L60-135 frontend/…/settings.js• L1-6 frontend/…/Login.vue• L184-189
Roster access and actions
The roster API gives the separate roster client one integration surface for month data and schedule changes. It returns holidays, approved leave, and active shift assignments grouped by employee. Employee and shift filters are limited to known business fields before the query runs.
The roster client first learns which filter data it may list. The API returns only filter doctypes for which the current user has select permission, so the client does not offer controls that the user cannot use. The same surface then accepts only the supported employee and shift filter names.
The same surface supports the main roster actions. A client can add a shift, split an assignment from a date, move or exchange shifts, and create or remove a repeating schedule assignment. It can also read the repeat pattern for an existing schedule assignment. Mutation calls use POST requests and check employee and document permissions before they change records, so an API caller cannot use the roster surface to bypass normal HR access rules.
The roster client uses the read methods to build its month grid and uses the action methods after a dialog or drag-and-drop operation. After a successful action it fetches the event set again, which makes the API result the source of truth for the next view.
flowchart LR
R[Roster client] --> C[Context and permitted filter requests]
C --> E[get_default_company, get_permitted_filter_doctypes, and get_events]
E --> V[Employee month view]
V --> A[Roster action]
A --> M[Insert, break, swap, or schedule assignment]
M --> E
| Roster concern | API behavior |
|---|---|
| Context | Returns the signed-in user’s default company |
| Filter controls | Returns only filter doctypes that the user can select |
| Month view | Combines holidays, approved leave, and shifts for a date range |
| Filtering | Accepts selected employee and shift fields only |
| Single assignment | Inserts or breaks a shift assignment |
| Exchange | Moves a shift to another employee or swaps two shifts |
| Repeating work | Reads the repeat pattern and creates or deletes a shift schedule assignment |
The Roster scheduling page explains the product behavior behind these calls. The API page focuses on the boundary between that product and its client.
References: hrms/…/roster.py• L12-75 hrms/…/roster.py• L87-157 hrms/…/roster.py• L160-284 roster/…/MonthViewTable.vue• L387-435 roster/…/ShiftAssignmentDialog.vue• L421-520
Integration boundaries
The endpoints serve two different integration classes. Guest methods help a client establish the login path before a session exists. Authenticated methods expose HR data or actions only within the permissions of the current user.
| Boundary | Role | Trust model |
|---|---|---|
| Login discovery | Select an external identity provider and read the login policy | Guest-callable and limited to provider metadata or one policy flag |
| Employee client | Load feature settings for the signed-in user | Requires a Frappe session |
| Roster client | Read workforce events and change assignments | Requires a session plus object and employee permissions |
The separation matters for external consumers. A client can discover how to start authentication without receiving HR records, then use the same Frappe session for the protected roster and HR requests. Employee-scoped calls also check access to the requested employee before returning holiday or approval information. Other signed-in API calls check document access before they return protected data, such as files attached to a document.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the OAuth response fields aligned with the login view. A provider can be configured correctly but remain invisible if the returned name, label, icon, or authorization URL contract changes.
- Treat
get_hr_settingsas an allow-list contract. Add or remove a setting only with the matching client feature behavior, including multi-currency expense behavior. - Keep roster filter names aligned with both
ALLOWED_EMPLOYEE_FILTERSorALLOWED_SHIFT_FILTERSand the filter controls in the roster client. - Keep the permitted filter-doctype list aligned with the roster controls. A user must not see a filter whose source doctype they cannot select.
- Preserve the permission checks on roster mutations. A new action must enforce the permissions for every employee and document it can affect.
- Keep month event grouping stable. The roster client maps each employee’s holiday, leave, and shift records into calendar dates.
- Keep the login policy endpoint guest-callable if the login screen must decide whether to render password sign-in before authentication.
- Treat reminder-frequency changes as a scheduling contract. A change in the HR Settings frequency must keep the scheduled reminder jobs and the user confirmation flow aligned.
- Keep attachment reads behind document-level read permission. A caller must not gain access to attached files by knowing a file name or document name.
- Keep roster write methods restricted to POST requests. Clients must not be able to change assignments through a read-style request.
- Keep schedule assignment reads and writes aligned with the roster client’s repeat-pattern dialog. A change to the repeat fields can make an existing assignment appear with the wrong recurrence or prevent a new one from being created.
- Resolve attendance holidays by the employee’s assigned holiday-list ranges. A single holiday list must not stand in for the full requested date range when assignments change.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An enabled OAuth provider has no usable secret, client ID, base URL, or OAuth keys | The provider is omitted from the login choices | Complete and test the provider configuration before relying on it for sign-in |
| A roster user lacks select permission for a filter doctype | The matching filter control is not available in the roster client | Load filter controls from get_permitted_filter_doctypes rather than assuming all filters are usable |
| A roster request uses a field outside the supported employee or shift filter sets | The request fails with a permission error and the month view cannot load | Use the published filter names from the roster client and API contract |
| A roster mutation targets an employee or assignment outside the caller’s permissions | The action is rejected and no assignment change is made | Grant the needed HR and document permissions before calling the action |
| A schedule assignment covers more than 90 days | Shift creation is queued instead of completing in the request | Treat the action as asynchronous and refresh the roster after the queued work finishes |
A client expects settings not included by get_hr_settings | The client cannot infer that feature’s state from this endpoint | Read only the explicit settings contract or add a matching API field and client use |
| Reminder frequency changes leave the next scheduled run out of order | Users can miss holiday reminders during the gap | Review the warning and proceed only when the new schedule is intended |
| An employee-scoped call targets an employee the caller cannot read | The request is rejected instead of returning employee data | Check employee read permission before returning holiday or approval details |
| A caller reads an attachment without document read access | The file list is rejected instead of exposing attached file metadata | Check read permission on the attached document before returning files |
| A client sends a roster mutation with a non-POST request | The assignment change does not run | Send all roster writes as POST requests |
Key files
| File | Why to read it |
|---|---|
| hrms/…/oauth.py | Defines the guest-facing OAuth provider discovery contract. |
| hrms/…/system_settings.py | Defines the guest-facing password-login policy contract. |
| hrms/…/__init__.py | Defines signed-in HR settings, employee-scoped access checks, and shared protected data endpoints used by clients. |
| hrms/…/roster.py | Defines roster reads, permitted filter discovery, filters, permissions, schedule reads, and schedule actions. |
| hrms/…/holiday_list.py | Defines date-range holiday resolution when an employee’s holiday-list assignment changes. |
| frontend/…/Login.vue | Shows how the login experience consumes the OAuth and system policy APIs. |
| frontend/…/settings.js | Shows how the employee-facing client loads HR settings. |
| roster/…/MonthViewTable.vue | Shows how roster event reads and shift swaps connect to the month view. |
| roster/…/ShiftAssignmentDialog.vue | Shows how roster dialogs call assignment and schedule actions. |
| hrms/…/hr_settings.json | Defines the HR Settings contract and the broader HR controls behind selected API values. |
| hrms/…/hr_settings.py | Defines validation for HR Settings changes that affect reminder scheduling. |