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 Klaviyo custom object records table (#90082)

Tom Owers73ad667e8375
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 dfe94292b409..db6479595b51 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
@@ -4617,6 +4617,16 @@ Diffed against: <https://pub.klausapp.com/public-export-api.swagger.json>
Note: Now branded Zendesk QA. pub.klausapp.com hosts two Swagger 2.0 specs; the relevant one is public-export-api.swagger.json (18 paths) — the sibling public-import-api.swagger.json is write-only ingestion and irrelevant here. PostHog's 10 tables map 1:1 onto the workspace-scoped export endpoints; the only genuine holes are the quiz sub-resources and the POST-based conversation search (which needs a request body, so it is more work than the plain GET exports).
+## Klaviyo — adequate
+
+Today (33): `accounts`, `campaign_values_reports`, `catalog_categories`, `catalog_items`, `catalog_variants`, `coupon_codes`, `coupons`, `custom_metrics`, `custom_object_records`, `data_sources`, `email_campaigns`, `events`, `flow_actions`, `flow_messages`, `flow_values_reports`, `flows`, `forms`, `images`, `list_profiles`, `lists`, `metrics`, `object_types`, `profiles`, `push_tokens`, `reviews`, `segment_profiles`, `segments`, `sms_campaigns`, `tag_groups`, `tags`, `templates`, `web_feeds`, `webhooks`
+
+Diffed against: <https://developers.klaviyo.com/en/reference/custom_objects_api_overview>
+
+- [x] `custom-object-records (GET /api/object-types/{id}/object-records)` — the actual records of each custom object type, fanned out over the `object_types` we already sync; the only Custom Objects data table, GA in the 2026-07-15 revision (high)
+
+Note: The Custom Objects API is GA at revision 2026-07-15, which the source already pins. `object-records` has no timestamp filter or sort, so it is full refresh only; its parent `/object-types` exposes no page[size] param, so the fan-out pages it by cursor links alone. The remaining write/admin paths in the Custom Objects API (create object type, source mappings, bulk create/delete jobs, schema relationships) are ingestion and management, not warehouse tables.
+
## Knock — gaps
Today (4): `messages`, `tenants`, `users`, `workflow_recipient_runs`
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/canonical_descriptions.py
index 436d4d28e744..37e21f0167ef 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/canonical_descriptions.py
@@ -435,6 +435,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "Time at which the object type was last updated.",
},
},
+ "custom_object_records": {
+ "description": "A single record of a custom object type, holding structured data synced into Klaviyo and linked to profiles.",
+ "docs_url": "https://developers.klaviyo.com/en/reference/get_records_for_object_type",
+ "columns": {
+ "id": "Unique identifier for the record, in the form object_type_id:::record_id.",
+ "object_type_id": "ID of the object type this record belongs to.",
+ "record_properties": "The record's properties, as defined by the object type's schema.",
+ },
+ },
"push_tokens": {
"description": "A push notification token registered against a profile's device.",
"docs_url": "https://developers.klaviyo.com/en/reference/get_push_tokens",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/klaviyo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/klaviyo.py
index 373d2fc57a64..bdd3ddee3482 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/klaviyo.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/klaviyo.py
@@ -282,7 +282,10 @@ def _iter_resource_ids(
page_size: int,
) -> Iterator[str]:
"""Page through a Klaviyo collection and yield each row's id, following the cursor links."""
- url = _build_url(f"{KLAVIYO_BASE_URL}{path}", {"page[size]": page_size})
+ # Some collections (e.g. /object-types) reject page[size]; page_size <= 0 means "omit it and
+ # page by cursor links alone", mirroring _build_initial_params for top-level endpoints.
+ params = {"page[size]": page_size} if page_size > 0 else {}
+ url = _build_url(f"{KLAVIYO_BASE_URL}{path}", params)
while True:
data = _fetch_page(session, url, headers, logger)
for item in data.get("data", []):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/settings.py
index a3404eec59ab..7946f2ac5808 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/settings.py
@@ -652,6 +652,23 @@ KLAVIYO_ENDPOINTS: dict[str, KlaviyoEndpointConfig] = {
page_size=0,
incremental_fields=[],
),
+ # Custom object records only exist per object type, so fan out over /object-types and pull each
+ # type's records. The endpoint exposes no timestamp filter or sort, so it is full refresh only.
+ # Klaviyo's compound record id (object_type_id:::record_id) is globally unique, so the default
+ # ["id"] primary key holds table-wide; object_type_id rides along as its own column for joins.
+ "custom_object_records": KlaviyoEndpointConfig(
+ name="custom_object_records",
+ path="/object-types/{object_type_id}/object-records",
+ page_size=100, # object-records caps page[size] at 100
+ incremental_fields=[],
+ fan_out=KlaviyoFanOutConfig(
+ # /object-types exposes no page[size] param; parent_page_size=0 pages it by cursor alone.
+ parent_path="/object-types",
+ parent_page_size=0,
+ parent_id_column="object_type_id",
+ ),
+ description="One row per custom object record, carrying the object_type_id it belongs to",
+ ),
}
ENDPOINTS = tuple(KLAVIYO_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/test_klaviyo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/test_klaviyo.py
index 68bb2106eb8e..71769d6b4021 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/test_klaviyo.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/klaviyo/test_klaviyo.py
@@ -693,6 +693,38 @@ class TestGeneralizedFanOut:
}
]
+ def test_custom_object_records_fan_out_over_object_types_without_a_parent_page_size(self, monkeypatch: Any) -> None:
+ # /object-types rejects page[size], so the parent must be enumerated by cursor links alone
+ # (no ?page[size] on its URL); each record carries its object_type_id and flattens
+ # record_properties onto the row. Fixtures key by exact URL, so a stray page[size] KeyErrors.
+ pages = {
+ "https://a.klaviyo.com/api/object-types": {
+ "data": [{"id": "OT1"}],
+ "links": {"next": None},
+ },
+ "https://a.klaviyo.com/api/object-types/OT1/object-records?page[size]=100": {
+ "data": [
+ {
+ "type": "object-record",
+ "id": "OT1:::rec-1",
+ "attributes": {"record_properties": {"name": "Fluffy"}},
+ }
+ ],
+ "links": {"next": None},
+ },
+ }
+ rows = _collect_rows("custom_object_records", monkeypatch, pages)
+ # The batcher serializes the nested record_properties object to a JSON string in the arrow
+ # table, which is how it lands in the warehouse column.
+ assert rows == [
+ {
+ "type": "object-record",
+ "id": "OT1:::rec-1",
+ "record_properties": '{"name":"Fluffy"}',
+ "object_type_id": "OT1",
+ }
+ ]
+
def test_flow_messages_walk_flows_then_actions_and_carry_both_ancestors(self, monkeypatch: Any) -> None:
# Two-level fan-out: the intermediate path must be formatted with the grandparent id, and
# each row must carry both ancestors or the flow -> action -> message chain can't be rebuilt.