: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from dataclasses import dataclass, field
from typing import Optional
from products.warehouse_sources.sources.sdk import DependentEndpointConfig, IncrementalField, IncrementalFieldType
# Zylo Enterprise (v2) API base URL. Every endpoint path below is relative to this.
ZYLO_BASE_URL = "https://api.zylo.com"
# Zylo list endpoints cap `limit` at 1000 (default 50 if unset); we always pass the max.
PAGE_LIMIT = 1000
# Every Zylo resource carries these two system timestamps and both accept the same
# `field=value,operator` filter syntax (see https://developer.zylo.com/reference/filtering),
# so both are safe, genuine server-side incremental cursors.
_SYSTEM_INCREMENTAL_FIELDS: list[IncrementalField] = [
{
"label": "zylo_created_at",
"type": IncrementalFieldType.DateTime,
"field": "zylo_created_at",
"field_type": IncrementalFieldType.DateTime,
},
{
"label": "zylo_modified_at",
"type": IncrementalFieldType.DateTime,
"field": "zylo_modified_at",
"field_type": IncrementalFieldType.DateTime,
},
]
@dataclass(frozen=True)
class ZyloEndpointConfig:
name: str
path: str
table_name: str
primary_keys: list[str] = field(default_factory=lambda: ["id"])
# Advertised incremental cursor options. Empty => full refresh only.
incremental_fields: list[IncrementalField] = field(default_factory=lambda: list(_SYSTEM_INCREMENTAL_FIELDS))
# Stable, never-updated datetime field used for partitioning. `zylo_created_at` is set once at
# record creation and never changes, unlike `zylo_modified_at`.
partition_key: Optional[str] = "zylo_created_at"
default_incremental_field: Optional[str] = "zylo_created_at"
page_size: int = PAGE_LIMIT
fanout: Optional[DependentEndpointConfig] = None
# Executions are only listable per automation, so they fan out over `/v2/automations`. Execution
# rows already carry `automation_id`, so nothing needs copying from the parent.
AUTOMATION_FANOUT = DependentEndpointConfig(
parent_name="Automations",
resolve_param="automationId",
resolve_field="id",
include_from_parent=[],
parent_params={"sort": "+zylo_created_at"},
)
# Every resource except AutomationExecutions is a top-level list endpoint.
ZYLO_ENDPOINTS: dict[str, ZyloEndpointConfig] = {
"Applications": ZyloEndpointConfig(
name="Applications",
path="/v2/applications",
table_name="applications",
),
"ApplicationLicenses": ZyloEndpointConfig(
name="ApplicationLicenses",
path="/v2/applicationLicenses",
table_name="application_licenses",
),
"ApplicationUsers": ZyloEndpointConfig(
name="ApplicationUsers",
path="/v2/applicationUsers",
table_name="application_users",
),
"Contracts": ZyloEndpointConfig(
name="Contracts",
path="/v2/contracts",
table_name="contracts",
),
"ContractLineItems": ZyloEndpointConfig(
name="ContractLineItems",
path="/v2/contractLineItems",
table_name="contract_line_items",
),
"Payments": ZyloEndpointConfig(
name="Payments",
path="/v2/payments",
table_name="payments",
),
# Premium feature — requires `applications:read` and `spend:read` scopes; a key without them
# gets a 403 for this endpoint only (see ZyloSource.get_endpoint_permissions).
"PurchaseOrders": ZyloEndpointConfig(
name="PurchaseOrders",
path="/v2/purchaseOrders",
table_name="purchase_orders",
),
"POLineItems": ZyloEndpointConfig(
name="POLineItems",
path="/v2/poLineItems",
table_name="po_line_items",
),
"Suppliers": ZyloEndpointConfig(
name="Suppliers",
path="/v2/suppliers",
table_name="suppliers",
),
"SavingsEvents": ZyloEndpointConfig(
name="SavingsEvents",
path="/v2/savingsEvents",
table_name="savings_events",
),
# No `id` field — one row per application per fiscal year, so the pair is the natural key.
"ApplicationBudgets": ZyloEndpointConfig(
name="ApplicationBudgets",
path="/v2/applicationBudgets",
table_name="application_budgets",
primary_keys=["application_id", "year"],
),
"ActivityHistory": ZyloEndpointConfig(
name="ActivityHistory",
path="/v2/activityHistory",
table_name="activity_history",
),
# Requires a token created with the automation role (`automations`).
"Automations": ZyloEndpointConfig(
name="Automations",
path="/v2/automations",
table_name="automations",
),
# Execution ids are global (Zylo serves `/v2/automations/executions/{executionId}`), so `id`
# alone stays unique across every parent automation.
"AutomationExecutions": ZyloEndpointConfig(
name="AutomationExecutions",
path="/v2/automations/{automationId}/executions",
table_name="automation_executions",
fanout=AUTOMATION_FANOUT,
),
}
ENDPOINTS = tuple(ZYLO_ENDPOINTS.keys())