Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(warehouse_sources): add HiBob time off changes, named lists, and applications tables (#111883)

Tom Owers9afd93b12a7e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index c9d71be8a525..e9f328ce88a0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -4043,7 +4043,7 @@ Note: learn.hex.tech renders the reference client-side from Docusaurus; the oper
## HiBob — **thin**
-Today (7): `candidates`, `employee_employment`, `employee_lifecycle`, `employee_salaries`, `employees`, `tasks`, `time_off_calendars`
+Today (10): `applications`, `candidates`, `employee_employment`, `employee_lifecycle`, `employee_salaries`, `employees`, `named_lists`, `tasks`, `time_off_calendars`, `time_off_request_changes`
Diffed against: <https://apidocs.hibob.com/reference/get_tasks>
@@ -4051,11 +4051,11 @@ Diffed against: <https://apidocs.hibob.com/reference/get_tasks>
- [x] `GET /bulk/people/lifecycle` — employee lifecycle state transitions (hire, promotion, termination) — the core HR history table (high)
- [x] `GET /bulk/people/employment` — employment history rows per employee (contract, manager, site changes) rather than only current state (high)
- [x] `GET /bulk/people/salaries` — compensation history, the headline HR analytics dataset (high)
-- [ ] `GET /timeoff/requests/changes` — time off request event stream plus GET /timeoff/employees/{id}/balance for balances (high)
-- [ ] `POST /attendance/entries/search` — clock in/out entries; also /attendance/daily-breakdown/search and /attendance/summaries/search for rollups (high)
-- [ ] `GET /company/named-lists` — lookup table resolving the list-value field ids stored on every employee record (high)
+- [x] `GET /timeoff/requests/changes` — time off request event stream plus GET /timeoff/employees/{id}/balance for balances (high). Added as `time_off_request_changes`, a full refresh of the last 180 days because the API rejects a `since` older than six months and rows carry no per-change timestamp. The balance endpoint is skipped: it is a point lookup per employee, policy type, and date, not a collection.
+- [ ] `POST /attendance/entries/search` — clock in/out entries; also /attendance/daily-breakdown/search and /attendance/summaries/search for rollups (high). Skipped: the Public API only exposes entries in running (unsubmitted) timesheet cycles, so no stable history can be synced. Each search also needs an employee filter and a date range of at most 33 days, and the module is a paid add-on.
+- [x] `GET /company/named-lists` — lookup table resolving the list-value field ids stored on every employee record (high). Added as `named_lists`, one row per list item (nested children flattened with `parentId`), archived items included.
- [x] `POST /hiring/candidates/search` — recruiting pipeline entities, unreachable today (high)
-- [ ] `POST /hiring/applications/search` — application rows joining candidates to job openings — the recruiting funnel fact table (high)
+- [x] `POST /hiring/applications/search` — application rows joining candidates to job openings — the recruiting funnel fact table (high). Added as `applications`.
- [ ] `GET /job-catalog/job-roles and /job-catalog/job-families` — lookup tables resolving role and family ids carried on employee records (high)
- [ ] `GET /payroll/history` — payroll runs over time, plus POST /people/actual-payments/search (medium)
- [ ] `POST /goals/goals/search` — goals and key results with progress, including /goals/goals/key-results/search (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/canonical_descriptions.py
index 04af8d305f4c..14f6f2f341a8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/canonical_descriptions.py
@@ -138,4 +138,54 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"modificationDate": "Timestamp of the last modification to this candidate record.",
},
},
+ "applications": {
+ "description": "An application in Bob Hiring, linking a candidate to a job opening with its pipeline stage, status, and source.",
+ "docs_url": "https://apidocs.hibob.com/reference/post_hiring-applications-search",
+ "columns": {
+ "id": "Unique identifier for the application.",
+ "status": "Current status of the application: in_progress, withdrawn, rejected, pending_rejection, pending_hire, or hired.",
+ "candidateId": "Identifier of the candidate who applied.",
+ "jobOpeningId": "Identifier of the job opening the application is for.",
+ "stageId": "Identifier of the pipeline stage the application is in.",
+ "sourceType": "The type of source the application came from (e.g. referral, agency, job board).",
+ "dateApplied": "Date the candidate applied.",
+ "createdAt": "Timestamp the application was created.",
+ "lastActivityTimestamp": "Timestamp of the latest activity on the application.",
+ "timeToHire": "Time it took to hire the candidate for this application.",
+ "hasOffer": "Whether the application has an offer.",
+ "modificationDate": "Timestamp of the last modification to this application.",
+ },
+ },
+ "time_off_request_changes": {
+ "description": "Changes to time off requests over the last 180 days, each a snapshot of the request at the time of the change. HiBob only serves changes from the last six months, so older changes drop out of the table.",
+ "docs_url": "https://apidocs.hibob.com/reference/get_timeoff-requests-changes",
+ "columns": {
+ "employeeId": "Identifier of the employee the request belongs to.",
+ "employeeDisplayName": "Display name of the employee.",
+ "policyTypeDisplayName": "Display name of the time off policy type.",
+ "changeType": "Type of change: Created, Canceled, Deleted, or Pending.",
+ "requestId": "Identifier of the time off request.",
+ "originalRequestId": "Identifier of the original request, when this request replaced an edited one.",
+ "previousRequestId": "Identifier of the previous version of the request, when it was edited.",
+ "createdOn": "Timestamp the request was created.",
+ "durationUnit": "Unit of the request duration: days or hours.",
+ "totalDuration": "Total duration of the request, in durationUnit.",
+ "totalCost": "Amount deducted from the balance for the whole request.",
+ "type": "How the request duration is expressed (e.g. days, hours, portionOnRange).",
+ "startDate": "First day of the time off.",
+ "endDate": "Last day of the time off.",
+ },
+ },
+ "named_lists": {
+ "description": "One row per item in each company list, the lookup table that resolves list values stored on employee records.",
+ "docs_url": "https://apidocs.hibob.com/reference/get_company-named-lists",
+ "columns": {
+ "listName": "Name of the company list the item belongs to.",
+ "id": "Internal identifier of the item.",
+ "value": "Value of the item.",
+ "name": "Display name of the item.",
+ "archived": "Whether the item is archived and no longer available for selection.",
+ "parentId": "Identifier of the parent item in a nested list, or null for a top-level item.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/hibob.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/hibob.py
index ba8c91e281ad..5355bfc6c125 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/hibob.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/hibob.py
@@ -1,4 +1,5 @@
from collections.abc import Callable, Iterable, Iterator
+from datetime import UTC, datetime, timedelta
from typing import Any
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
@@ -15,6 +16,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.hibob.settings import (
HIBOB_ENDPOINTS,
+ NAMED_LISTS,
TIME_OFF_CALENDARS,
HiBobEndpointConfig,
)
@@ -151,6 +153,42 @@ def _time_off_calendars_rows(
session.close()
+def _flatten_list_items(list_name: str, items: list[dict[str, Any]], parent_id: Any = None) -> Iterator[dict[str, Any]]:
+ for item in items:
+ children = item.get("children") or []
+ yield {
+ **{key: value for key, value in item.items() if key != "children"},
+ "listName": list_name,
+ "parentId": parent_id,
+ }
+ yield from _flatten_list_items(list_name, children, item.get("id"))
+
+
+def _named_lists_rows(
+ service_user_id: str, service_user_token: str, config: HiBobEndpointConfig
+) -> Iterator[list[dict[str, Any]]]:
+ session = make_tracked_session(redact_values=(service_user_token,))
+ session.auth = (service_user_id, service_user_token)
+ try:
+ response = session.get(f"{HIBOB_BASE_URL}{config.path}", params=config.params, timeout=REQUEST_TIMEOUT_SECONDS)
+ response.raise_for_status()
+ data = response.json()
+ finally:
+ session.close()
+
+ # Accept the documented array of lists and an object keyed by list name, the shape older Bob docs show.
+ named_lists = data.values() if isinstance(data, dict) else data
+ rows: list[dict[str, Any]] = []
+ for named_list in named_lists:
+ rows.extend(_flatten_list_items(named_list.get("name"), named_list.get(config.data_key) or []))
+ if rows:
+ yield rows
+
+
+def _since(days_ago: int) -> str:
+ return (datetime.now(UTC) - timedelta(days=days_ago)).isoformat(timespec="milliseconds").replace("+00:00", "Z")
+
+
def hibob_source(
service_user_id: str,
service_user_token: str,
@@ -170,6 +208,16 @@ def hibob_source(
sort_mode="asc",
)
+ if endpoint == NAMED_LISTS:
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: _named_lists_rows(service_user_id, service_user_token, config),
+ primary_keys=list(config.primary_keys),
+ partition_count=1,
+ partition_size=1,
+ sort_mode="asc",
+ )
+
# Basic auth carries the token; supplying it via the framework auth config redacts the
# token from any raised error. Repeated 401/403s trip HiBob's WAF, so auth errors must
# fail loud (raise_for_status) rather than retry — the client only retries 429/5xx.
@@ -183,8 +231,11 @@ def hibob_source(
if config.body is not None:
# Copy, because the cursor paginator writes the cursor into the request body.
api_endpoint["json"] = {**config.body}
- if config.params is not None:
- api_endpoint["params"] = config.params
+ params = {**(config.params or {})}
+ if config.since_days_ago is not None:
+ params["since"] = _since(config.since_days_ago)
+ if params:
+ api_endpoint["params"] = params
rest_config: RESTAPIConfig = {
"client": {
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/settings.py
index e55d1ec4498f..3dbb9e9ea949 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/settings.py
@@ -20,6 +20,8 @@ class HiBobEndpointConfig:
# "employee_history": rows are nested per employee under `values` and need flattening.
# "pointer_keys": rows are keyed by JSON pointers (e.g. `/candidate/id`) and need leaf keys.
row_shape: Literal["flat", "employee_history", "pointer_keys"] = "flat"
+ # Sent as a `since` query param set this many days before the sync starts.
+ since_days_ago: Optional[int] = None
# Max page size the cursor-paginated bulk tables and hiring searches accept.
@@ -76,18 +78,79 @@ CANDIDATE_FIELDS = (
"/candidate/modificationDate",
)
+APPLICATION_FIELDS = (
+ "/application/id",
+ "/application/status",
+ "/application/candidateId",
+ "/application/jobOpeningId",
+ "/application/stageId",
+ "/application/sourcedBy",
+ "/application/sourceInstanceId",
+ "/application/sourceType",
+ "/application/sourceInternalId",
+ "/application/sourcedByNameResolved",
+ "/application/dateApplied",
+ "/application/createdAt",
+ "/application/lastActivityTimestamp",
+ "/application/initialConsentDueDate",
+ "/application/timeToHire",
+ "/application/referredBy",
+ "/application/evaluationScore",
+ "/application/evaluationRecommendation",
+ "/application/evaluationCount",
+ "/application/evaluations",
+ "/application/jobAdId",
+ "/application/agencyId",
+ "/application/agencyReferenceId",
+ "/application/agencyNote",
+ "/application/agencyContactFirstName",
+ "/application/agencyContactLastName",
+ "/application/agencyContactEmail",
+ "/application/desiredSalary",
+ "/application/education",
+ "/application/experience",
+ "/application/volunteerExperience",
+ "/application/professionalAssociationsMemberships",
+ "/application/qualificationsLicenses",
+ "/application/initialConsentRequestedAt",
+ "/application/offlineConsentMessage",
+ "/application/offlineConsentGivenBy",
+ "/application/dateAvailable",
+ "/application/lastEmployment",
+ "/application/automaticRejectionEmailMessageId",
+ "/application/importResumeFileName",
+ "/application/hasOffer",
+ "/application/workspaceType",
+ "/application/siteId",
+ "/application/interviewAlert",
+ "/application/referralSource",
+ "/application/referralNotes",
+ "/application/cvSummaryDetails",
+ "/application/aiMatchingScore",
+ "/application/files",
+ "/application/modificationDate",
+)
+
+# The time off changes endpoint rejects a `since` older than six months; 180 days
+# always falls inside that.
+TIME_OFF_CHANGES_LOOKBACK_DAYS = 180
+
# Name of the employee time-off calendars stream. It fans out over employee ids
# (the search endpoint resolves the holiday calendar per employee), so it needs
# bespoke transport rather than the shared single-page path — routed by name in
# hibob.py.
TIME_OFF_CALENDARS = "time_off_calendars"
+# Company lists come back nested (lists hold items, items can hold children), so
+# they are flattened by bespoke transport — routed by name in hibob.py.
+NAMED_LISTS = "named_lists"
+
# HiBob has no updated-at filter on employees (Airbyte is full-refresh only and
# Fivetran re-imports most tables every sync), so every stream is an honest
# full refresh. The time off changes endpoint has a `since` param but its rows
-# carry no verifiable per-change timestamp to use as a watermark — deferred.
-# Candidates search accepts a `modificationDate` filter, but neither its value
-# format nor the result order is documented — deferred.
+# carry no per-change timestamp to use as a watermark, so it re-reads a rolling
+# window instead. Candidates and applications search accept a `modificationDate`
+# filter, but neither its value format nor the result order is documented — deferred.
HIBOB_ENDPOINTS: dict[str, HiBobEndpointConfig] = {
"employees": HiBobEndpointConfig(
name="employees",
@@ -148,6 +211,34 @@ HIBOB_ENDPOINTS: dict[str, HiBobEndpointConfig] = {
cursor_location="json",
row_shape="pointer_keys",
),
+ "applications": HiBobEndpointConfig(
+ name="applications",
+ path="/v1/hiring/applications/search",
+ data_key="items",
+ method="POST",
+ # The search returns only the fields requested, so ask for every documented application field.
+ body={"fields": list(APPLICATION_FIELDS), "filters": [], "limit": BULK_PAGE_LIMIT},
+ cursor_location="json",
+ row_shape="pointer_keys",
+ ),
+ "time_off_request_changes": HiBobEndpointConfig(
+ name="time_off_request_changes",
+ path="/v1/timeoff/requests/changes",
+ data_key="changes",
+ params={"includePending": "true"},
+ # An edited request gets a new requestId, so one id carries at most one change of each type.
+ primary_keys=("requestId", "changeType"),
+ since_days_ago=TIME_OFF_CHANGES_LOOKBACK_DAYS,
+ ),
+ NAMED_LISTS: HiBobEndpointConfig(
+ name=NAMED_LISTS,
+ path="/v1/company/named-lists",
+ data_key="items",
+ # Archived items stay referenced by older employee records.
+ params={"includeArchived": "true"},
+ # Item ids are only documented as internal ids, so scope them to their list.
+ primary_keys=("listName", "id"),
+ ),
}
ENDPOINTS = tuple(HIBOB_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/tests/test_hibob.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/tests/test_hibob.py
index a44085809764..d808bd60fc4a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/tests/test_hibob.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hibob/tests/test_hibob.py
@@ -2,6 +2,7 @@ import json
from typing import Any
import pytest
+import time_machine
from unittest import mock
from requests import Response
@@ -210,37 +211,130 @@ class TestEmployeeHistoryTables:
_rows(hibob_source("service-id", "token", "employee_lifecycle", team_id=1, job_id="j"))
-class TestCandidates:
+class TestHiringSearches:
+ @pytest.mark.parametrize(
+ "endpoint, path, prefix",
+ [
+ ("candidates", "/v1/hiring/candidates/search", "/candidate"),
+ ("applications", "/v1/hiring/applications/search", "/application"),
+ ],
+ )
@mock.patch(CLIENT_SESSION_PATCH)
- def test_posts_body_cursor_and_normalizes_pointer_keys(self, MockSession) -> None:
+ def test_posts_body_cursor_and_normalizes_pointer_keys(self, MockSession, endpoint, path, prefix) -> None:
session = MockSession.return_value
captured = _wire(
session,
[
_response(
{
- "items": [{"/candidate/id": 7, "/candidate/firstName": "Ada"}],
+ "items": [{f"{prefix}/id": 7, f"{prefix}/status": "active"}],
"response_metadata": {"next_cursor": "c2"},
}
),
- _response({"items": [{"/candidate/id": 8}], "response_metadata": {"next_cursor": None}}),
+ _response({"items": [{f"{prefix}/id": 8}], "response_metadata": {"next_cursor": None}}),
],
)
- rows = _rows(hibob_source("service-id", "token", "candidates", team_id=1, job_id="j"))
+ rows = _rows(hibob_source("service-id", "token", endpoint, team_id=1, job_id="j"))
- assert rows == [{"id": 7, "firstName": "Ada"}, {"id": 8}]
- assert [(c["method"], c["url"]) for c in captured] == [
- ("POST", "https://api.hibob.com/v1/hiring/candidates/search")
- ] * 2
+ assert rows == [{"id": 7, "status": "active"}, {"id": 8}]
+ assert [(c["method"], c["url"]) for c in captured] == [("POST", f"https://api.hibob.com{path}")] * 2
assert "cursor" not in captured[0]["json"]
- assert "/candidate/modificationDate" in captured[0]["json"]["fields"]
+ assert f"{prefix}/modificationDate" in captured[0]["json"]["fields"]
+ # HiBob rejects a search asking for more than 50 fields.
+ assert len(captured[0]["json"]["fields"]) <= 50
assert captured[1]["json"]["cursor"] == "c2"
# The next sync must not start from the previous sync's cursor.
- body = HIBOB_ENDPOINTS["candidates"].body
+ body = HIBOB_ENDPOINTS[endpoint].body
assert body is not None and "cursor" not in body
+class TestTimeOffRequestChanges:
+ @time_machine.travel("2026-07-01T12:00:00Z", tick=False)
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_requests_rolling_window_within_six_months(self, MockSession) -> None:
+ session = MockSession.return_value
+ change = {"requestId": 11, "changeType": "Created", "employeeId": "e1", "type": "days"}
+ captured = _wire(session, [_response({"changes": [change]})])
+
+ response = hibob_source("service-id", "token", "time_off_request_changes", team_id=1, job_id="j")
+ rows = _rows(response)
+
+ assert rows == [change]
+ assert response.primary_keys == ["requestId", "changeType"]
+ assert session.send.call_count == 1
+ assert (captured[0]["method"], captured[0]["url"]) == (
+ "GET",
+ "https://api.hibob.com/v1/timeoff/requests/changes",
+ )
+ assert captured[0]["params"] == {"includePending": "true", "since": "2026-01-02T12:00:00.000Z"}
+
+
+class TestNamedLists:
+ @pytest.mark.parametrize(
+ "payload",
+ [
+ [
+ {"name": "department", "items": [{"id": 1, "value": "Eng", "name": "Eng", "archived": False}]},
+ {
+ "name": "site",
+ "items": [
+ {
+ "id": 2,
+ "value": "UK",
+ "name": "UK",
+ "archived": True,
+ "children": [{"id": 3, "value": "London", "name": "London", "archived": False}],
+ }
+ ],
+ },
+ ],
+ {
+ "department": {
+ "name": "department",
+ "items": [{"id": 1, "value": "Eng", "name": "Eng", "archived": False, "children": []}],
+ },
+ "site": {
+ "name": "site",
+ "items": [
+ {
+ "id": 2,
+ "value": "UK",
+ "name": "UK",
+ "archived": True,
+ "children": [{"id": 3, "value": "London", "name": "London", "archived": False}],
+ }
+ ],
+ },
+ },
+ ],
+ ids=["documented_array", "keyed_by_list_name"],
+ )
+ @mock.patch(HIBOB_SESSION_PATCH)
+ def test_flattens_nested_items_with_list_name_and_parent(self, mock_make_session, payload) -> None:
+ session = mock_make_session.return_value
+ session.get.return_value = _response(payload)
+
+ response = hibob_source("service-id", "token", "named_lists", team_id=1, job_id="j")
+ rows = _rows(response)
+
+ assert rows == [
+ {"id": 1, "value": "Eng", "name": "Eng", "archived": False, "listName": "department", "parentId": None},
+ {"id": 2, "value": "UK", "name": "UK", "archived": True, "listName": "site", "parentId": None},
+ {"id": 3, "value": "London", "name": "London", "archived": False, "listName": "site", "parentId": 2},
+ ]
+ assert response.primary_keys == ["listName", "id"]
+ assert session.get.call_args.args[0] == "https://api.hibob.com/v1/company/named-lists"
+ assert session.get.call_args.kwargs["params"] == {"includeArchived": "true"}
+
+ @mock.patch(HIBOB_SESSION_PATCH)
+ def test_auth_error_fails_loud(self, mock_make_session) -> None:
+ mock_make_session.return_value.get.return_value = _response({"error": "unauthorized"}, status=401)
+
+ with pytest.raises(Exception):
+ _rows(hibob_source("service-id", "token", "named_lists", team_id=1, job_id="j"))
+
+
class TestTimeOffCalendars:
"""The calendars stream fans out over employee ids (POST search), so it hand-rolls its own
session.post calls rather than riding the shared rest_client."""