Introducing a new way to review your PRs.

Read the announcement

frappe / hrms

Open Source HR and Payroll Software

View on GitHub

20 documents · Updated Nov 23, 2026

docs / api-and-external-integration

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.

CapabilityAPI entry pointMain consumer or use
OAuth provider discoveryhrms.api.oauth.oauth_providersLogin clients that show available external sign-in choices
System login policyhrms.api.system_settings.get_user_pass_login_disabledLogin clients that decide whether password sign-in is available
HR client settingshrms.api.get_hr_settingsEmployee-facing clients that enable or disable selected HR features
Attendance calendarhrms.api.get_attendance_calendar_eventsEmployee-facing clients that show attendance and holiday status by date
Roster context and filter accesshrms.api.roster.get_default_company, get_permitted_filter_doctypesThe roster client’s company context and available filter controls
Roster context and datahrms.api.roster.get_default_company, hrms.api.roster.get_eventsThe roster client’s month view and filters
Roster actionshrms.api.roster.insert_shift, break_shift, swap_shift, and schedule assignment methodsUsers 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 concernAPI behavior
ContextReturns the signed-in user’s default company
Filter controlsReturns only filter doctypes that the user can select
Month viewCombines holidays, approved leave, and shifts for a date range
FilteringAccepts selected employee and shift fields only
Single assignmentInserts or breaks a shift assignment
ExchangeMoves a shift to another employee or swaps two shifts
Repeating workReads 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.

BoundaryRoleTrust model
Login discoverySelect an external identity provider and read the login policyGuest-callable and limited to provider metadata or one policy flag
Employee clientLoad feature settings for the signed-in userRequires a Frappe session
Roster clientRead workforce events and change assignmentsRequires 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_settings as 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_FILTERS or ALLOWED_SHIFT_FILTERS and 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

TriggerConsequenceGuard
An enabled OAuth provider has no usable secret, client ID, base URL, or OAuth keysThe provider is omitted from the login choicesComplete and test the provider configuration before relying on it for sign-in
A roster user lacks select permission for a filter doctypeThe matching filter control is not available in the roster clientLoad 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 setsThe request fails with a permission error and the month view cannot loadUse the published filter names from the roster client and API contract
A roster mutation targets an employee or assignment outside the caller’s permissionsThe action is rejected and no assignment change is madeGrant the needed HR and document permissions before calling the action
A schedule assignment covers more than 90 daysShift creation is queued instead of completing in the requestTreat the action as asynchronous and refresh the roster after the queued work finishes
A client expects settings not included by get_hr_settingsThe client cannot infer that feature’s state from this endpointRead only the explicit settings contract or add a matching API field and client use
Reminder frequency changes leave the next scheduled run out of orderUsers can miss holiday reminders during the gapReview the warning and proceed only when the new schedule is intended
An employee-scoped call targets an employee the caller cannot readThe request is rejected instead of returning employee dataCheck employee read permission before returning holiday or approval details
A caller reads an attachment without document read accessThe file list is rejected instead of exposing attached file metadataCheck read permission on the attached document before returning files
A client sends a roster mutation with a non-POST requestThe assignment change does not runSend all roster writes as POST requests

Key files

FileWhy to read it
hrms/…/oauth.pyDefines the guest-facing OAuth provider discovery contract.
hrms/…/system_settings.pyDefines the guest-facing password-login policy contract.
hrms/…/__init__.pyDefines signed-in HR settings, employee-scoped access checks, and shared protected data endpoints used by clients.
hrms/…/roster.pyDefines roster reads, permitted filter discovery, filters, permissions, schedule reads, and schedule actions.
hrms/…/holiday_list.pyDefines date-range holiday resolution when an employee’s holiday-list assignment changes.
frontend/…/Login.vueShows how the login experience consumes the OAuth and system policy APIs.
frontend/…/settings.jsShows how the employee-facing client loads HR settings.
roster/…/MonthViewTable.vueShows how roster event reads and shift swaps connect to the month view.
roster/…/ShiftAssignmentDialog.vueShows how roster dialogs call assignment and schedule actions.
hrms/…/hr_settings.jsonDefines the HR Settings contract and the broader HR controls behind selected API values.
hrms/…/hr_settings.pyDefines validation for HR Settings changes that affect reminder scheduling.