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): support deel API version 2026-01-01 (#113240)

Tom Owers7305941f3d6f
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.md
index 887af8dc0c2a..d26e785dd619 100644
--- a/.agents/skills/warehouse-source-new-version/SKILL.md
+++ b/.agents/skills/warehouse-source-new-version/SKILL.md
@@ -93,6 +93,7 @@ The opposite gap also occurs: a reference rendered from one version-blind OpenAP
- Credential-validation paths (`validate_credentials`, permission probes) run at creation time with no row pin; they may use the default/legacy version. Changing them is optional per version bump — verify the vendor accepts the validation calls under the new version before switching them.
- A passing credential probe is not evidence sync works — the probe hits one endpoint, `get_rows` hits the rest; when they diverge per version, the probe passes while every table 404s.
- Version → header/path maps must cover every supported label — a `.get()` fallthrough silently sends no version header (tracking "latest", the drift this framework prevents). Assert coverage or raise.
+- When a vendor dates each endpoint separately and rejects a date an endpoint was not published under, the source label is a baseline, not the header value. An endpoint published after the baseline sends its own published date under that pin, so store the selector per endpoint.
- A vendor alias that resolves to the newest version (`latest`, `current`, an undated `stable`) is not a version label. Never declare it in `supported_versions` or point `default_version` at it: a pin that moves under a running sync is the same drift, now written down as a supported choice.
- First-time versioning of a source that sends no version selector today: keep the pre-existing label (the `UNVERSIONED_API_VERSION` default) sending nothing, and add the selector only for the new dated label. That preserves already-pinned rows byte-for-byte, and pinning the new default is the point — the no-selector path was tracking the vendor account's configured version, which is the drift. This is not the fallthrough bug above: the empty selector here is deliberate and belongs to one specific legacy label, not a `.get()` miss.
- Parallel version-bump PRs grab the same next migration number; the second to merge becomes a conflicting leaf and `ci:preflight` blocks it. Check `max_migration.txt` and renumber.
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 e252b5cad9c7..efae53f0e109 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
@@ -2398,7 +2398,7 @@ Note: docs.decagon.ai is a fully client-rendered Mintlify site that returns the
## Deel — **thin**
-Today (23): `contracts`, `cost_centers`, `countries`, `currencies`, `departments`, `groups`, `invoice_adjustments`, `invoices`, `job_titles`, `legal_entities`, `offboarding_tracker`, `onboarding_tracker`, `payment_breakdowns`, `payments`, `payroll_cycles`, `payroll_gross_to_net`, `payroll_reports`, `people`, `seniorities`, `teams`, `time_off_events`, `time_offs`, `timesheets`
+Today (27): `contracts`, `cost_centers`, `countries`, `currencies`, `departments`, `equity_awards`, `groups`, `invoice_adjustments`, `invoices`, `it_clearance_requests`, `it_seats`, `job_titles`, `legal_entities`, `offboarding_tracker`, `onboarding_tracker`, `payment_breakdowns`, `payments`, `payroll_cycles`, `payroll_gross_to_net`, `payroll_reports`, `people`, `seniorities`, `teams`, `time_off_events`, `time_off_policies`, `time_offs`, `timesheets`
Diffed against: <https://api.letsdeel.com/openapi/rest/definitions>
@@ -2414,9 +2414,15 @@ Diffed against: <https://api.letsdeel.com/openapi/rest/definitions>
- [x] `/onboarding/tracker and /offboarding/tracker` — worker lifecycle state so joiner/leaver funnels can be measured (medium)
- [x] `/lookups/countries, /lookups/currencies, /lookups/job-titles, /lookups/seniorities, /lookups/time-off-types` — reference tables that decode the coded fields on contracts, people and time off (medium)
- [ ] `/ats/applications, /ats/candidates, /ats/job-postings` — recruiting funnel objects for orgs using Deel's ATS (low)
+- [x] `/it/seats` — seats of the organization's IT seat subscription and the worker holding each (medium)
+- [x] `/it/clearance-requests` — device clearance requests raised by the organization (low)
+- [x] `/time-offs/policy` — organization time-off policies, the configuration behind time-off requests (medium)
+- [x] `/equity-awards` — equity awards granted by the organization (medium)
+- [ ] `/ats/hires` — ATS applications mapped to the HRIS profiles they were hired into; Beta-only (needs `X-Beta: true`), revisit once Deel promotes it to stable (low)
Note: The public spec is served from api.letsdeel.com (linked from developer.deel.com); it has hundreds of paths across ATS, EOR, payroll, HRIS, time tracking and IT modules, so the synced tables still cover a small slice.
Sub-endpoints of the ticked lines that were deliberately not given their own table: `/contracts/{contract_id}/timesheets` returns the same rows as `/timesheets` filtered to one contract; `/time_offs/dailies` is a date-range query for holidays and work schedules with no row identity, whose absence dailies already arrive nested on `/time_offs` rows; and `/lookups/time-off-types` returns a bare array of enum strings with no object shape or row identity, and those same values already arrive on `/time_offs` rows.
+The four dated-endpoint tables (`it_seats`, `it_clearance_requests`, `time_off_policies`, `equity_awards`) are listed only on the `2026-01-01` pin: Deel documents them only under `/rest` with their own `X-Version` date, so sources pinned to `v2` do not list them.
The gross-to-net line added a third table, `payroll_cycles` (`/legal-entities/{id}/payroll-events`): the report is keyed by payroll cycle and cycles are only listed per legal entity, so the cycle listing is both the path to the report and the table that dates it.
## Deepgram — gaps
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/canonical_descriptions.py
index d15f796f56ce..3482e1a714fb 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/canonical_descriptions.py
@@ -341,4 +341,67 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"level": "Hierarchical level, where higher numbers mean greater seniority.",
},
},
+ "it_seats": {
+ "description": "A seat in the organization's Deel IT seat subscription, and the worker holding it.",
+ "docs_url": "https://developer.deel.com/api/reference/endpoints/it-seats/list-it-seats-v-2026-09-25",
+ "columns": {
+ "id": "Unique identifier of the seat.",
+ "status": "Current status of the seat (ACTIVE, ASSIGNED, INACTIVE, PENDING_APPROVAL).",
+ "active_on": "Day the seat's paid features started being used. Null while the seat is not in use.",
+ "created_at": "When the seat was created.",
+ "assigned_at": "When the seat was given to its worker. Null when the seat has never been assigned.",
+ "declined_at": "When the worker declined the seat. Null unless the worker declined it.",
+ "deactivated_on": "Day the seat was released. Null while the seat is still held.",
+ "assigned_hris_profile": "Worker holding the seat. Null when the seat is free or its worker has no Deel HRIS profile.",
+ },
+ },
+ "it_clearance_requests": {
+ "description": "A request the organization raised to retire a device for resale value or certified data erasure.",
+ "docs_url": "https://developer.deel.com/api/reference/endpoints/clearance-requests/list-clearance-requests-v-2026-09-16",
+ "columns": {
+ "id": "Unique identifier of the clearance request.",
+ "status": "Current state of the clearance request (e.g. PENDING_QUOTE, PENDING_DECISION, COMPLETED).",
+ "public_id": "Public identifier of the clearance request.",
+ "created_at": "Creation timestamp of the clearance request.",
+ "expires_at": "When the request expires and the manager can no longer act on it. Null when no deadline applies.",
+ "cancelled_reason": "Reason the clearance request was cancelled. Null unless the status is CANCELLED.",
+ },
+ },
+ "time_off_policies": {
+ "description": "A time-off policy configured for the organization, with its allowances and tracking rules.",
+ "docs_url": "https://developer.deel.com/api/reference/endpoints/time-off/get-policies-for-organization-v-2026-09-09",
+ "columns": {
+ "id": "Unique identifier of the policy.",
+ "name": "Policy name.",
+ "description": "Policy description.",
+ "created_at": "When the policy was created.",
+ "updated_at": "When the policy was last updated.",
+ "leave_type": "Short-term leave (e.g. PTO) or long-term leave (e.g. parental leave).",
+ "policy_type": "Details of the policy type associated with this policy.",
+ "payment_type": "Whether the time off is PAID, UNPAID or PARTIALLY_PAID.",
+ "policy_allowances": "Allowances granted under this policy.",
+ "tracking_cadence": "Whether tracking periods start on a fixed day, on the worker's start anniversary, or are not specified.",
+ "assigned_profiles_count": "Number of worker profiles assigned to this policy.",
+ },
+ },
+ "equity_awards": {
+ "description": "An equity award granted by the organization, as ingested from Shareworks.",
+ "docs_url": "https://developer.deel.com/api/reference/endpoints/equity-tokens/list-equity-awards-v-2026-09-09",
+ "columns": {
+ "id": "Unique identifier of the record.",
+ "employee_number": "Shareworks employee number, the intended join key for the record.",
+ "hris_profile_id": "Matched Deel HRIS profile id. Null when the employee number could not be resolved.",
+ "grant_name": "Grant name, as reported by the ingested file.",
+ "grant_date": "Date the grant was issued.",
+ "grant_quantity": "Number of shares or units granted.",
+ "grant_price": "Strike or grant price per unit.",
+ "total_fmv": "Total fair market value of the grant.",
+ "plan_name": "Equity plan name.",
+ "vesting_start_date": "Vesting start date.",
+ "occurrence_index": "Tells apart several records the source file reports for the same natural key, starting at 1.",
+ "row_hash": "Hash of the reported values on the record, for detecting a change between syncs.",
+ "created_at": "When the record was first ingested.",
+ "updated_at": "When the record was last upserted.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/deel.py b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/deel.py
index 258e456eb39a..e0fd59f8cf1a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/deel.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/deel.py
@@ -27,6 +27,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.deel.settings import (
+ DEEL_API_VERSION_2026_01_01,
+ DEEL_API_VERSION_V2,
DEEL_ENDPOINTS,
GROSS_TO_NET_ENDPOINT,
GROSS_TO_NET_PARENT,
@@ -36,17 +38,23 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.deel.setti
DeelEndpointConfig,
)
-DEEL_BASE_URL = "https://api.letsdeel.com/rest/v2"
+DEEL_BASE_URLS = {
+ DEEL_API_VERSION_V2: "https://api.letsdeel.com/rest/v2",
+ DEEL_API_VERSION_2026_01_01: "https://api.letsdeel.com/rest",
+}
REQUEST_TIMEOUT_SECONDS = 30
# Time-off rows carry absence reasons and family/medical event details, timesheets carry a
# free-text work description plus a reviewer's remarks, the trackers carry worker names and work
-# emails, and gross-to-net carries per-worker pay — none of it name-tagged in a way the
-# name-based sample scrubbers can spot.
+# emails, IT seats carry the holder's address and identity documents, and gross-to-net and equity
+# awards carry per-worker pay — none of it name-tagged in a way the name-based sample scrubbers can
+# spot.
_UNCAPTURED_ENDPOINTS = frozenset(
{
"time_offs",
TIME_OFF_EVENTS_ENDPOINT,
+ "it_seats",
+ "equity_awards",
"timesheets",
"onboarding_tracker",
"offboarding_tracker",
@@ -155,12 +163,29 @@ def _make_paginator(config: DeelEndpointConfig) -> BasePaginator:
return SinglePagePaginator()
-def _client_config(api_token: str, config: DeelEndpointConfig) -> ClientConfig:
+def _base_url(api_version: str) -> str:
+ base_url = DEEL_BASE_URLS.get(api_version)
+ if base_url is None:
+ raise ValueError(f"Unsupported Deel API version: {api_version}")
+ return base_url
+
+
+def _version_headers(api_version: str, config: DeelEndpointConfig) -> dict[str, str]:
+ # The legacy pin keeps sending no selector, so its requests stay exactly as they were.
+ if api_version == DEEL_API_VERSION_V2:
+ return {}
+ return {"X-Version": config.x_version}
+
+
+def _client_config(api_token: str, config: DeelEndpointConfig, api_version: str) -> ClientConfig:
client_config: ClientConfig = {
- "base_url": DEEL_BASE_URL,
+ "base_url": _base_url(api_version),
# Bearer auth via the framework so the token is redacted from logs.
"auth": {"type": "bearer", "token": api_token},
}
+ version_headers = _version_headers(api_version, config)
+ if version_headers:
+ client_config["headers"] = version_headers
if config.name in _UNCAPTURED_ENDPOINTS:
client_config["capture"] = False
return client_config
@@ -174,7 +199,7 @@ def _base_params(config: DeelEndpointConfig) -> dict[str, Any]:
return params
-def validate_credentials(api_token: str) -> tuple[bool, str | None]:
+def validate_credentials(api_token: str, api_version: str) -> tuple[bool, str | None]:
"""Confirm the API token is valid with a cheap one-person listing probe.
Scoped tokens may lack individual resource scopes (403); only 401 means the
@@ -182,8 +207,8 @@ def validate_credentials(api_token: str) -> tuple[bool, str | None]:
"could not reach Deel" error so it isn't mistaken for a bad token."""
_ok, status = validate_via_probe(
lambda: make_tracked_session(redact_values=(api_token,)),
- f"{DEEL_BASE_URL}/people?limit=1",
- headers={"Authorization": f"Bearer {api_token}"},
+ f"{_base_url(api_version)}/people?limit=1",
+ headers={"Authorization": f"Bearer {api_token}", **_version_headers(api_version, DEEL_ENDPOINTS["people"])},
)
if status is None:
@@ -200,6 +225,7 @@ def _top_level_items(
job_id: str,
resumable_source_manager: ResumableSourceManager[DeelResumeConfig],
db_incremental_field_last_value: Optional[Any],
+ api_version: str,
) -> Iterable[Any]:
resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
@@ -220,7 +246,7 @@ def _top_level_items(
elif config.pagination == "offset" and state.get("offset") is not None:
resumable_source_manager.save_state(DeelResumeConfig(offset=int(state["offset"])))
- client_config = _client_config(api_token, config)
+ client_config = _client_config(api_token, config, api_version)
client_config["paginator"] = _make_paginator(config)
rest_config: RESTAPIConfig = {
@@ -256,6 +282,7 @@ def _fanout_items(
job_id: str,
resumable_source_manager: ResumableSourceManager[DeelResumeConfig],
db_incremental_field_last_value: Optional[Any],
+ api_version: str,
) -> Iterable[Any]:
fanout = config.fanout
assert fanout is not None
@@ -295,7 +322,7 @@ def _fanout_items(
endpoint_configs=DEEL_ENDPOINTS,
child_endpoint=config.name,
fanout=fanout,
- client_config=_client_config(api_token, config),
+ client_config=_client_config(api_token, config, api_version),
path_format_values={},
team_id=team_id,
job_id=job_id,
@@ -316,6 +343,7 @@ def _time_off_event_items(
team_id: int,
job_id: str,
resumable_source_manager: ResumableSourceManager[DeelResumeConfig],
+ api_version: str,
) -> Iterator[list[dict[str, Any]]]:
"""Yield one batch of time-off event rows per page of people.
@@ -332,7 +360,7 @@ def _time_off_event_items(
if state and state.get("offset") is not None:
resumable_source_manager.save_state(DeelResumeConfig(offset=int(state["offset"])))
- parent_client_config = _client_config(api_token, parent_config)
+ parent_client_config = _client_config(api_token, parent_config, api_version)
parent_client_config["paginator"] = _make_paginator(parent_config)
parent_rest_config: RESTAPIConfig = {
@@ -359,7 +387,12 @@ def _time_off_event_items(
)
session = make_tracked_session(redact_values=(api_token,), capture=False)
- headers = {"Authorization": f"Bearer {api_token}", "Accept": "application/json"}
+ headers = {
+ "Authorization": f"Bearer {api_token}",
+ "Accept": "application/json",
+ **_version_headers(api_version, config),
+ }
+ base_url = _base_url(api_version)
for page in people:
rows: list[dict[str, Any]] = []
@@ -368,7 +401,7 @@ def _time_off_event_items(
if hris_profile_id is None:
continue
response = session.get(
- f"{DEEL_BASE_URL}{config.path}",
+ f"{base_url}{config.path}",
params={"hris_profile_id": str(hris_profile_id)},
headers=headers,
timeout=REQUEST_TIMEOUT_SECONDS,
@@ -426,6 +459,7 @@ def _gross_to_net_items(
config: DeelEndpointConfig,
api_token: str,
resumable_source_manager: ResumableSourceManager[DeelResumeConfig],
+ api_version: str,
) -> Iterator[list[dict[str, Any]]]:
"""Yield gross-to-net rows per payroll cycle.
@@ -444,15 +478,24 @@ def _gross_to_net_items(
done = set(completed)
session = make_tracked_session(redact_values=(api_token,), capture=False)
- headers = {"Authorization": f"Bearer {api_token}", "Accept": "application/json"}
+ base_url = _base_url(api_version)
+
+ def headers(config: DeelEndpointConfig) -> dict[str, str]:
+ return {
+ "Authorization": f"Bearer {api_token}",
+ "Accept": "application/json",
+ **_version_headers(api_version, config),
+ }
- for entity_page in _iter_cursor_pages(session, f"{DEEL_BASE_URL}{root_config.path}", root_config, headers):
+ for entity_page in _iter_cursor_pages(session, f"{base_url}{root_config.path}", root_config, headers(root_config)):
for entity in entity_page:
legal_entity_id = entity.get("id")
if legal_entity_id is None:
continue
- cycles_url = f"{DEEL_BASE_URL}{cycle_config.path.replace('{legal_entity_id}', str(legal_entity_id))}"
- for cycle_page in _iter_cursor_pages(session, cycles_url, cycle_config, headers, ignore_statuses=(404,)):
+ cycles_url = f"{base_url}{cycle_config.path.replace('{legal_entity_id}', str(legal_entity_id))}"
+ for cycle_page in _iter_cursor_pages(
+ session, cycles_url, cycle_config, headers(cycle_config), ignore_statuses=(404,)
+ ):
for cycle in cycle_page:
cycle_id = cycle.get("id")
if cycle_id is None:
@@ -461,8 +504,10 @@ def _gross_to_net_items(
# Deel only publishes a report for a cycle it flags; the rest 404.
if not cycle.get("has_g2n_report") or cycle_key in done:
continue
- report_url = f"{DEEL_BASE_URL}{config.path.replace('{cycle_id}', str(cycle_id))}"
- for rows in _iter_cursor_pages(session, report_url, config, headers, ignore_statuses=(404,)):
+ report_url = f"{base_url}{config.path.replace('{cycle_id}', str(cycle_id))}"
+ for rows in _iter_cursor_pages(
+ session, report_url, config, headers(config), ignore_statuses=(404,)
+ ):
yield [
{**row, "cycle_id": str(cycle_id), "legal_entity_id": str(legal_entity_id)} for row in rows
]
@@ -477,6 +522,7 @@ def deel_source(
team_id: int,
job_id: str,
resumable_source_manager: ResumableSourceManager[DeelResumeConfig],
+ api_version: str,
db_incremental_field_last_value: Optional[Any] = None,
) -> SourceResponse:
config = DEEL_ENDPOINTS[endpoint]
@@ -491,9 +537,10 @@ def deel_source(
team_id,
job_id,
resumable_source_manager,
+ api_version,
)
elif endpoint == GROSS_TO_NET_ENDPOINT:
- items = partial(_gross_to_net_items, config, api_token, resumable_source_manager)
+ items = partial(_gross_to_net_items, config, api_token, resumable_source_manager, api_version)
else:
builder = _fanout_items if config.fanout is not None else _top_level_items
resource = builder(
@@ -503,6 +550,7 @@ def deel_source(
job_id,
resumable_source_manager,
db_incremental_field_last_value,
+ api_version,
)
items = lambda: resource # noqa: E731
column_hints = getattr(resource, "column_hints", None)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/settings.py
index f568cfe3dedc..18ed0792a0de 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/settings.py
@@ -9,6 +9,11 @@ from products.warehouse_sources.backend.types import IncrementalField
# Several Deel endpoints cap `limit` below 100, so stay safely under every cap.
PAGE_SIZE = 50
+# `v2` is the `/rest/v2` path that sends no version header. `2026-01-01` is Deel's dated baseline,
+# selected per request with the `X-Version` header.
+DEEL_API_VERSION_V2 = "v2"
+DEEL_API_VERSION_2026_01_01 = "2026-01-01"
+
# Mutable by choice, not oversight: instances flow into `build_dependent_resource`'s
# `endpoint_configs: Mapping[str, FanoutEndpointLike]`, and mypy treats a frozen dataclass's fields
@@ -36,6 +41,12 @@ class DeelEndpointConfig:
# Extra query params sent on every request to this endpoint.
params: dict[str, Any] = field(default_factory=dict)
fanout: Optional[DependentEndpointConfig] = None
+ # `X-Version` sent under a dated pin. Deel versions each endpoint on its own date, and an endpoint
+ # published after the 2026-01-01 baseline rejects any date it was not published under.
+ x_version: str = DEEL_API_VERSION_2026_01_01
+ # Endpoints published after Deel moved to dated versions are documented only under `/rest`, so
+ # the legacy `v2` pin does not list them.
+ on_legacy_v2: bool = True
# Deel exposes no updated-since filter on the endpoints synced here, so both stay empty —
# `FanoutEndpointLike` requires them.
incremental_fields: list[IncrementalField] = field(default_factory=list)
@@ -257,6 +268,55 @@ DEEL_ENDPOINTS: dict[str, DeelEndpointConfig] = {
pagination="none",
page_size_param=None,
),
+ "it_seats": DeelEndpointConfig(
+ name="it_seats",
+ path="/it/seats",
+ pagination="cursor",
+ cursor_path=("next_cursor",),
+ cursor_param="cursor",
+ has_more_path=("has_more",),
+ # Deel documents a default of 20 and no maximum.
+ page_size=20,
+ partition_key="created_at",
+ x_version="2026-09-25",
+ on_legacy_v2=False,
+ ),
+ "it_clearance_requests": DeelEndpointConfig(
+ name="it_clearance_requests",
+ path="/it/clearance-requests",
+ pagination="cursor",
+ cursor_path=("next_cursor",),
+ cursor_param="cursor",
+ has_more_path=("has_more",),
+ # Deel documents a default of 20 and no maximum.
+ page_size=20,
+ partition_key="created_at",
+ x_version="2026-09-16",
+ on_legacy_v2=False,
+ ),
+ "time_off_policies": DeelEndpointConfig(
+ name="time_off_policies",
+ path="/time-offs/policy",
+ pagination="cursor",
+ cursor_path=("next",),
+ cursor_param="next",
+ has_more_path=("has_next_page",),
+ page_size_param="page_size",
+ partition_key="created_at",
+ x_version="2026-09-09",
+ on_legacy_v2=False,
+ ),
+ "equity_awards": DeelEndpointConfig(
+ name="equity_awards",
+ path="/equity-awards",
+ pagination="cursor",
+ cursor_path=("next_cursor",),
+ cursor_param="cursor",
+ has_more_path=("has_more",),
+ partition_key="created_at",
+ x_version="2026-09-09",
+ on_legacy_v2=False,
+ ),
}
# `/time_offs/time-off-events` takes its worker profile as a query param, which the shared fan-out
@@ -271,3 +331,11 @@ GROSS_TO_NET_PARENT = "payroll_cycles"
GROSS_TO_NET_ROOT = "legal_entities"
ENDPOINTS = tuple(DEEL_ENDPOINTS.keys())
+
+
+def endpoints_for_version(api_version: str) -> tuple[str, ...]:
+ if api_version == DEEL_API_VERSION_V2:
+ return tuple(name for name, config in DEEL_ENDPOINTS.items() if config.on_legacy_v2)
+ if api_version == DEEL_API_VERSION_2026_01_01:
+ return ENDPOINTS
+ raise ValueError(f"Unsupported Deel API version: {api_version}")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/source.py
index 7457182d68e7..05bd4731723b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/source.py
@@ -23,16 +23,20 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.deel.deel
deel_source,
validate_credentials as validate_deel_credentials,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.deel.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.deel.settings import (
+ DEEL_API_VERSION_2026_01_01,
+ DEEL_API_VERSION_V2,
+ endpoints_for_version,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.deel import DeelSourceConfig
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class DeelSource(ResumableSource[DeelSourceConfig, DeelResumeConfig]):
- supported_versions = ("v2",)
- default_version = "v2"
- api_docs_url = "https://developer.deel.com"
+ supported_versions = (DEEL_API_VERSION_V2, DEEL_API_VERSION_2026_01_01)
+ default_version = DEEL_API_VERSION_2026_01_01
+ api_docs_url = "https://developer.deel.com/api/api-versioning"
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@@ -44,6 +48,7 @@ class DeelSource(ResumableSource[DeelSourceConfig, DeelResumeConfig]):
return {
"401 Client Error: Unauthorized for url: https://api.letsdeel.com": "Deel authentication failed. Please check your API token.",
"403 Client Error: Forbidden for url: https://api.letsdeel.com": "Deel denied access. Please check that your API token has the read scope for this dataset.",
+ "410 Client Error: Gone for url: https://api.letsdeel.com": "Deel has retired the API version this source uses. Contact PostHog support to move the source to a supported version.",
}
@property
@@ -54,7 +59,7 @@ class DeelSource(ResumableSource[DeelSourceConfig, DeelResumeConfig]):
label="Deel",
caption="""Enter your Deel API token to pull your Deel workforce and payroll data into the PostHog Data warehouse.
-Create an organization token in [Deel](https://app.deel.com/developer-center) under More > Developer with read scopes for the data you want to sync (`people:read`, `contracts:read`, `accounting:read`, `timesheets:read`, `time-off:read`, `legal-entity:read`, `organizations:read`, `groups:read`, `global-payroll:read`, `payslips:read`). Prefer an organization token over a personal token — personal tokens stop working when the user leaves the organization.""",
+Create an organization token in [Deel](https://app.deel.com/developer-center) under More > Developer with read scopes for the data you want to sync (`people:read`, `contracts:read`, `accounting:read`, `timesheets:read`, `time-off:read`, `legal-entity:read`, `organizations:read`, `groups:read`, `global-payroll:read`, `payslips:read`, `it-seats:read`, `it-service-requests:read`, `equities:read`). Prefer an organization token over a personal token — personal tokens stop working when the user leaves the organization.""",
iconPath="/static/services/deel.png",
docsUrl="https://posthog.com/docs/cdp/sources/deel",
releaseStatus=ReleaseStatus.ALPHA,
@@ -91,12 +96,12 @@ Create an organization token in [Deel](https://app.deel.com/developer-center) un
) -> list[SourceSchema]:
# Core Deel objects have no updated-since filter, so every stream is an
# honest full refresh (no incremental fields).
- return build_endpoint_schemas(ENDPOINTS, {}, names)
+ return build_endpoint_schemas(endpoints_for_version(self.resolve_api_version(api_version)), {}, names)
def validate_credentials(
self, config: DeelSourceConfig, team_id: int, schema_name: Optional[str] = None, api_version: str | None = None
) -> tuple[bool, str | None]:
- return validate_deel_credentials(config.api_token)
+ return validate_deel_credentials(config.api_token, self.resolve_api_version(api_version))
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[DeelResumeConfig]:
return ResumableSourceManager[DeelResumeConfig](inputs, DeelResumeConfig)
@@ -113,5 +118,6 @@ Create an organization token in [Deel](https://app.deel.com/developer-center) un
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
+ api_version=self.resolve_api_version(inputs.api_version),
db_incremental_field_last_value=None, # every Deel endpoint is full refresh
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel.py b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel.py
index 0ff572a6160d..f0bd34dba4e0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel.py
@@ -13,6 +13,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.deel.deel
validate_credentials,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.deel.settings import (
+ DEEL_API_VERSION_2026_01_01,
+ DEEL_API_VERSION_V2,
DEEL_ENDPOINTS,
ENDPOINTS,
PAGE_SIZE,
@@ -23,6 +25,12 @@ CLIENT_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports
# validate_credentials builds its own tracked session in the deel module.
DEEL_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.deel.deel.make_tracked_session"
+# (pin, base URL, version headers): the legacy pin sends no selector, the dated pin sends X-Version.
+VERSION_WIRES = [
+ (DEEL_API_VERSION_V2, "https://api.letsdeel.com/rest/v2", {}),
+ (DEEL_API_VERSION_2026_01_01, "https://api.letsdeel.com/rest", {"X-Version": "2026-01-01"}),
+]
+
def _response(items: list[dict[str, Any]] | None, *, cursor: str | None = None, drop_data: bool = False) -> Response:
page: dict[str, Any] = {"total_rows": len(items or [])}
@@ -97,8 +105,10 @@ def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str,
return params
-def _source(endpoint: str, manager: mock.MagicMock):
- return deel_source("token", endpoint, team_id=1, job_id="j", resumable_source_manager=manager)
+def _source(endpoint: str, manager: mock.MagicMock, api_version: str = DEEL_API_VERSION_V2):
+ return deel_source(
+ "token", endpoint, team_id=1, job_id="j", resumable_source_manager=manager, api_version=api_version
+ )
def _rows(source_response) -> list[dict[str, Any]]:
@@ -121,13 +131,28 @@ class TestValidateCredentials:
response.status_code = status_code
mock_session.return_value.get.return_value = response
- assert validate_credentials("token") == expected
+ assert validate_credentials("token", DEEL_API_VERSION_V2) == expected
+
+ @pytest.mark.parametrize("api_version, base_url, version_headers", VERSION_WIRES)
+ @mock.patch(DEEL_SESSION_PATCH)
+ def test_validate_credentials_probes_on_the_pinned_version(
+ self, mock_session, api_version, base_url, version_headers
+ ):
+ response = mock.MagicMock()
+ response.status_code = 200
+ mock_session.return_value.get.return_value = response
+
+ validate_credentials("token", api_version)
+
+ call = mock_session.return_value.get.call_args
+ assert call.args[0] == f"{base_url}/people?limit=1"
+ assert call.kwargs["headers"] == {"Authorization": "Bearer token", **version_headers}
@mock.patch(DEEL_SESSION_PATCH)
def test_validate_credentials_reports_network_error_distinctly(self, mock_session):
# A transient network failure must not masquerade as a bad token.
mock_session.return_value.get.side_effect = requests.ConnectionError("boom")
- valid, error = validate_credentials("token")
+ valid, error = validate_credentials("token", DEEL_API_VERSION_V2)
assert valid is False
assert error is not None and error.startswith("Could not reach Deel")
@@ -402,9 +427,12 @@ class TestFanoutEndpoints:
class TestTimeOffEvents:
+ @pytest.mark.parametrize("api_version, base_url, version_headers", VERSION_WIRES)
@mock.patch(DEEL_SESSION_PATCH)
@mock.patch(CLIENT_SESSION_PATCH)
- def test_fans_out_over_people_by_query_param(self, MockClientSession, MockDeelSession):
+ def test_fans_out_over_people_by_query_param(
+ self, MockClientSession, MockDeelSession, api_version, base_url, version_headers
+ ):
_wire(MockClientSession.return_value, [_response([{"id": "prof_1"}, {"id": "prof_2"}])])
child_session = MockDeelSession.return_value
child_session.get.side_effect = [
@@ -412,11 +440,15 @@ class TestTimeOffEvents:
_wrapped_response({"data": [{"id": "ev_2"}]}),
]
- rows = _rows(_source("time_off_events", _make_manager()))
+ rows = _rows(_source("time_off_events", _make_manager(), api_version))
assert [call.args[0] for call in child_session.get.call_args_list] == [
- "https://api.letsdeel.com/rest/v2/time_offs/time-off-events"
+ f"{base_url}/time_offs/time-off-events"
] * 2
+ assert all(
+ call.kwargs["headers"].get("X-Version") == version_headers.get("X-Version")
+ for call in child_session.get.call_args_list
+ )
assert [call.kwargs["params"]["hris_profile_id"] for call in child_session.get.call_args_list] == [
"prof_1",
"prof_2",
@@ -491,21 +523,25 @@ class TestLookupEndpoints:
@pytest.mark.parametrize(
"endpoint, path",
[
- ("departments", "https://api.letsdeel.com/rest/v2/departments"),
- ("teams", "https://api.letsdeel.com/rest/v2/teams"),
- ("countries", "https://api.letsdeel.com/rest/v2/lookups/countries"),
- ("currencies", "https://api.letsdeel.com/rest/v2/lookups/currencies"),
- ("seniorities", "https://api.letsdeel.com/rest/v2/lookups/seniorities"),
+ ("departments", "/departments"),
+ ("teams", "/teams"),
+ ("countries", "/lookups/countries"),
+ ("currencies", "/lookups/currencies"),
+ ("seniorities", "/lookups/seniorities"),
],
)
+ @pytest.mark.parametrize("api_version, base_url, version_headers", VERSION_WIRES)
@mock.patch(CLIENT_SESSION_PATCH)
- def test_unpaginated_lookups_send_one_request_with_no_page_size(self, MockSession, endpoint, path):
+ def test_unpaginated_lookups_send_one_request_with_no_page_size(
+ self, MockSession, api_version, base_url, version_headers, endpoint, path
+ ):
session = MockSession.return_value
params, urls = _wire_capture(session, [_response([{"code": "US"}])])
- _rows(_source(endpoint, _make_manager()))
+ _rows(_source(endpoint, _make_manager(), api_version))
- assert urls == [path]
+ assert urls == [f"{base_url}{path}"]
+ assert session.headers == version_headers
assert params[0] == {}
assert session.send.call_count == 1
@@ -548,8 +584,9 @@ class TestPayrollEndpoints:
class TestGrossToNet:
+ @pytest.mark.parametrize("api_version, base_url, version_headers", VERSION_WIRES)
@mock.patch(DEEL_SESSION_PATCH)
- def test_walks_legal_entities_then_cycles_then_reports(self, MockSession):
+ def test_walks_legal_entities_then_cycles_then_reports(self, MockSession, api_version, base_url, version_headers):
session = MockSession.return_value
session.get.side_effect = [
_response([{"id": "le_1"}]),
@@ -558,14 +595,18 @@ class TestGrossToNet:
]
manager = _make_manager()
- rows = _rows(_source("payroll_gross_to_net", manager))
+ rows = _rows(_source("payroll_gross_to_net", manager, api_version))
assert [call.args[0] for call in session.get.call_args_list] == [
- "https://api.letsdeel.com/rest/v2/legal-entities",
- "https://api.letsdeel.com/rest/v2/legal-entities/le_1/payroll-events",
+ f"{base_url}/legal-entities",
+ f"{base_url}/legal-entities/le_1/payroll-events",
# cy_2 publishes no report, so it is never requested.
- "https://api.letsdeel.com/rest/v2/reports/payroll/cycles/cy_1/gross-to-net",
+ f"{base_url}/reports/payroll/cycles/cy_1/gross-to-net",
]
+ assert all(
+ call.kwargs["headers"].get("X-Version") == version_headers.get("X-Version")
+ for call in session.get.call_args_list
+ )
assert rows == [{"contract_oid": "con_1", "cycle_id": "cy_1", "legal_entity_id": "le_1"}]
assert rows[0]["legal_entity_id"] == "le_1"
# The cycle is checkpointed once its rows are out, so a resume skips it. A cycle id is
@@ -623,3 +664,59 @@ class TestGrossToNet:
assert [r["contract_oid"] for r in rows] == ["con_1", "con_1"]
assert session.get.call_count == 4
+
+
+class TestDatedVersionEndpoints:
+ @pytest.mark.parametrize(
+ "endpoint, path, x_version, cursor_key, cursor_param, page_size_param, page_size, has_more_key",
+ [
+ ("it_seats", "/it/seats", "2026-09-25", "next_cursor", "cursor", "limit", 20, "has_more"),
+ (
+ "it_clearance_requests",
+ "/it/clearance-requests",
+ "2026-09-16",
+ "next_cursor",
+ "cursor",
+ "limit",
+ 20,
+ "has_more",
+ ),
+ (
+ "time_off_policies",
+ "/time-offs/policy",
+ "2026-09-09",
+ "next",
+ "next",
+ "page_size",
+ PAGE_SIZE,
+ "has_next_page",
+ ),
+ ("equity_awards", "/equity-awards", "2026-09-09", "next_cursor", "cursor", "limit", PAGE_SIZE, "has_more"),
+ ],
+ )
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_walks_on_the_endpoints_own_published_version(
+ self, MockSession, endpoint, path, x_version, cursor_key, cursor_param, page_size_param, page_size, has_more_key
+ ):
+ # These endpoints were published after the 2026-01-01 baseline, and Deel rejects a date an
+ # endpoint was not published under, so each one must send its own date.
+ session = MockSession.return_value
+ params, urls = _wire_capture(
+ session,
+ [
+ _wrapped_response({"data": [{"id": "a"}], has_more_key: True, cursor_key: "cur_1"}),
+ _wrapped_response({"data": [{"id": "b"}], has_more_key: False, cursor_key: None}),
+ ],
+ )
+
+ rows = _rows(_source(endpoint, _make_manager(), DEEL_API_VERSION_2026_01_01))
+
+ assert [r["id"] for r in rows] == ["a", "b"]
+ assert urls == [f"https://api.letsdeel.com/rest{path}"] * 2
+ assert session.headers == {"X-Version": x_version}
+ assert params[0][page_size_param] == page_size
+ assert params[1][cursor_param] == "cur_1"
+
+ def test_an_undeclared_pin_fails_instead_of_sending_no_version(self):
+ with pytest.raises(ValueError, match="Unsupported Deel API version"):
+ _source("people", _make_manager(), "2099-01-01")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel_source.py
index 2e23a008d6b2..f5fb3716ef1a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/deel/tests/test_deel_source.py
@@ -16,6 +16,7 @@ class TestDeelSource:
[
"401 Client Error: Unauthorized for url: https://api.letsdeel.com/rest/v2/people?limit=50",
"403 Client Error: Forbidden for url: https://api.letsdeel.com/rest/v2/contracts",
+ "410 Client Error: Gone for url: https://api.letsdeel.com/rest/people?limit=50",
],
)
def test_non_retryable_errors_match_auth_failures(self, observed_error):
@@ -33,6 +34,22 @@ class TestDeelSource:
non_retryable_errors = self.source.get_non_retryable_errors()
assert not any(key in other_vendor_error for key in non_retryable_errors)
+ @pytest.mark.parametrize(
+ "api_version, dated_tables_listed",
+ [
+ ("v2", False),
+ ("2026-01-01", True),
+ # No pin is a source being created, which lands on the default version.
+ (None, True),
+ ],
+ )
+ def test_get_schemas_lists_dated_tables_only_on_the_dated_pin(self, api_version, dated_tables_listed):
+ dated_tables = {"it_seats", "it_clearance_requests", "time_off_policies", "equity_awards"}
+
+ names = {schema.name for schema in self.source.get_schemas(self.config, self.team_id, api_version=api_version)}
+
+ assert names == (set(ENDPOINTS) if dated_tables_listed else set(ENDPOINTS) - dated_tables)
+
def test_get_schemas_are_full_refresh_only(self):
schemas = self.source.get_schemas(self.config, self.team_id)