{
  "openapi": "3.0.1",
  "info": {
    "title": "LakehouseFlow: Dataset to Medallion Parquet, CDC & dbt Engine",
    "description": "Transform web pages, APIs, or Apify Datasets into Zstd Medallion Parquet (Bronze/Silver/Gold), stateful SCD Type 2 CDC, MinHash deduplication, Schema Drift & Null-Spike Firewall with Dead-Letter Queue, PII masking, incremental RAG chunks, and Snowflake, Databricks DLT, DuckDB & dbt models.",
    "version": "0.0",
    "x-build-id": "KIf6Bv2aoQUWqsf1x"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/driftking-byte~apify-lakehouse-cdc-engine/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-driftking-byte-apify-lakehouse-cdc-engine",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/driftking-byte~apify-lakehouse-cdc-engine/runs": {
      "post": {
        "operationId": "runs-sync-driftking-byte-apify-lakehouse-cdc-engine",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/driftking-byte~apify-lakehouse-cdc-engine/run-sync": {
      "post": {
        "operationId": "run-sync-driftking-byte-apify-lakehouse-cdc-engine",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "sourceMode"
        ],
        "properties": {
          "sourceMode": {
            "title": "Source Ingestion Mode",
            "enum": [
              "rawRecords",
              "dataset",
              "webUrls",
              "restApi"
            ],
            "type": "string",
            "description": "Select how records are ingested into the Bronze layer: 'rawRecords' (inline JSON array or demo dataset), 'dataset' (upstream Apify Dataset ID), 'webUrls' (live web pages / HTML tables / JSON-LD / tech-stack / Markdown), or 'restApi' (JSON API endpoint with pagination).",
            "default": "rawRecords"
          },
          "datasetId": {
            "title": "Upstream Apify Dataset ID",
            "type": "string",
            "description": "When sourceMode is 'dataset' (or when chaining via Apify Webhook), provide the upstream Dataset ID (e.g. '{{resource.defaultDatasetId}}')."
          },
          "urls": {
            "title": "Target Web URLs or Sitemap URLs",
            "type": "array",
            "description": "When sourceMode is 'webUrls', list page URLs or XML sitemap URLs to crawl, extract structured JSON-LD/OpenGraph/HTML tables/tech stack, and chunk for RAG.",
            "items": {
              "type": "string"
            }
          },
          "apiEndpoint": {
            "title": "REST API / JSON Feed Endpoint URL",
            "type": "string",
            "description": "When sourceMode is 'restApi', the HTTP GET endpoint returning JSON records."
          },
          "apiRecordsPath": {
            "title": "API JSON Records Path (Optional)",
            "type": "string",
            "description": "Dot-separated path to the array of records in the API response (e.g., 'data.items'). Auto-detected if omitted."
          },
          "rawRecords": {
            "title": "Inline Raw JSON Records (Demo / Direct Input)",
            "type": "array",
            "description": "Inline array of JSON objects to process through the Medallion CDC & Parquet pipeline. Pre-filled with sample e-commerce & SaaS telemetry records so you can test with 1 click for $0."
          },
          "maxItems": {
            "title": "Max Items to Ingest",
            "minimum": 1,
            "type": "integer",
            "description": "Maximum number of records to ingest in a single run.",
            "default": 10000
          },
          "tableName": {
            "title": "Target Lakehouse Table Name",
            "type": "string",
            "description": "Logical table name used for Parquet artifacts, SQLite/DuckDB catalog tables, SCD2 state tracking, and generated Snowflake/Databricks/dbt models.",
            "default": "lakehouse_entities"
          },
          "primaryKey": {
            "title": "Primary Key Column(s)",
            "type": "array",
            "description": "One or more field names (supports nested dot paths like 'product_id' or 'url') forming the unique business key for CDC & SCD Type 2 tracking. Auto-inferred if empty.",
            "default": [
              "product_id"
            ],
            "items": {
              "type": "string"
            }
          },
          "cdcMode": {
            "title": "CDC & History Mode",
            "enum": [
              "scd2_history",
              "upsert_merge",
              "append_only"
            ],
            "type": "string",
            "description": "How state changes are tracked across runs: 'scd2_history' (full SCD Type 2 version history + CDC changelog), 'upsert_merge' (latest version per key + CDC changelog), or 'append_only' (stateless append).",
            "default": "scd2_history"
          },
          "detectDeletes": {
            "title": "Detect Soft Deletes on Missing Keys",
            "type": "boolean",
            "description": "When enabled in full-snapshot crawls, keys present in previous runs but absent in the current batch are emitted as CDC 'DELETE' operations and closed in SCD Type 2 history.",
            "default": false
          },
          "emitUnchangedToDataset": {
            "title": "Include UNCHANGED Records in Default Dataset Output",
            "type": "boolean",
            "description": "If false (recommended for incremental downstream pipelines), only INSERT, UPDATE, and DELETE delta records are pushed to the Apify Dataset while full tables remain in Parquet/SQLite.",
            "default": true
          },
          "enableNearDedup": {
            "title": "Enable MinHash Near-Duplicate Detection",
            "type": "boolean",
            "description": "Uses 64-permutation shingle MinHash Jaccard similarity to flag and filter near-duplicate records or boilerplate-heavy pages within the batch.",
            "default": true
          },
          "nearDedupThreshold": {
            "title": "Near-Duplicate Similarity Threshold (0.50 - 1.00)",
            "type": "number",
            "description": "Jaccard similarity threshold above which two distinct keys are flagged as near-duplicates.",
            "default": 0.92
          },
          "stateStoreName": {
            "title": "Persistent State Store Name",
            "type": "string",
            "description": "Named Apify Key-Value Store used to persist CDC hashes, SCD Type 2 active versions, and baseline schema snapshots across runs.",
            "default": "lakehouse-cdc-state"
          },
          "parquetCompression": {
            "title": "Apache Parquet Compression Codec",
            "enum": [
              "zstd",
              "snappy",
              "gzip",
              "none"
            ],
            "type": "string",
            "description": "Compression algorithm used by PyArrow when serializing Bronze, Silver, and Gold Parquet files.",
            "default": "zstd"
          },
          "piiPolicy": {
            "title": "PII Firewall Policy",
            "enum": [
              "mask_sha256",
              "redact",
              "flag_only",
              "disabled"
            ],
            "type": "string",
            "description": "Action when heuristic + regex + Luhn scanners detect PII (Email, Phone, SSN, Credit Card, IPv4, API Secret): 'mask_sha256' (deterministic SHA-256 hash preserving joinability), 'redact' (replace with [REDACTED_<TYPE>]), or 'flag_only' (audit without altering values).",
            "default": "mask_sha256"
          },
          "piiSalt": {
            "title": "PII Hashing Salt (Optional)",
            "type": "string",
            "description": "Optional secret salt added before SHA-256 PII masking to prevent rainbow-table reversal."
          },
          "requiredColumns": {
            "title": "Contract: Required Non-Null Columns",
            "type": "array",
            "description": "Records missing any of these columns (or having null/empty values) are routed to the Dead-Letter Queue (DLQ) instead of polluting Silver/Gold tables.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "failOnBreakingDrift": {
            "title": "Fail Run on Breaking Schema Drift",
            "type": "boolean",
            "description": "If true, raises an error when a previously seen column changes to an incompatible data type or disappears completely.",
            "default": false
          },
          "nullSpikeThresholdPct": {
            "title": "Null-Rate Spike Alert Threshold (%)",
            "type": "number",
            "description": "Triggers a Schema Drift Anomaly Alert if any column's null percentage increases by more than this amount compared to the baseline run (catches broken scraper selectors).",
            "default": 35
          },
          "enableRagChunking": {
            "title": "Generate Incremental Gold RAG Chunks",
            "type": "boolean",
            "description": "Creates a Gold-layer vector-ready Parquet & JSON table of token-bounded semantic chunks ONLY for INSERT/UPDATE records (saves 90%+ re-embedding cost).",
            "default": true
          },
          "ragChunkSizeTokens": {
            "title": "RAG Target Chunk Size (Tokens)",
            "minimum": 32,
            "maximum": 4096,
            "type": "integer",
            "description": "Approximate maximum token count per semantic text chunk.",
            "default": 256
          },
          "targetDatabase": {
            "title": "Warehouse Target Database / Catalog Name",
            "type": "string",
            "description": "Database or Unity Catalog name used in generated Snowflake, Databricks DLT, DuckDB, and dbt SQL artifacts.",
            "default": "LAKEHOUSE_PROD"
          },
          "targetSchema": {
            "title": "Warehouse Target Schema Name",
            "type": "string",
            "description": "Schema name used in generated Snowflake, Databricks DLT, DuckDB, and dbt SQL artifacts.",
            "default": "SILVER_CDC"
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}