{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Quality Gate - Schema & Data QA",
    "description": "Validate Apify Datasets by pasted items, Dataset ID, or Run ID before delivery, automation, or AI/RAG ingestion. Catch schema drift, missing fields, duplicates, and bad URLs/emails/dates.",
    "version": "0.3",
    "x-build-id": "N0rzlJlvaH6hLn55t"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/jy-labs~dataset-quality-gate/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-jy-labs-dataset-quality-gate",
        "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/jy-labs~dataset-quality-gate/runs": {
      "post": {
        "operationId": "runs-sync-jy-labs-dataset-quality-gate",
        "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/jy-labs~dataset-quality-gate/run-sync": {
      "post": {
        "operationId": "run-sync-jy-labs-dataset-quality-gate",
        "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",
        "properties": {
          "reportName": {
            "title": "Report name",
            "type": "string",
            "description": "Name shown in the generated QA report. Use a customer, Actor, dataset, or pipeline name."
          },
          "datasetId": {
            "title": "Apify Dataset ID to validate",
            "type": "string",
            "description": "Optional. Paste an Apify Dataset ID to fetch and validate its items automatically. Leave empty when using Run ID or pasted items."
          },
          "runId": {
            "title": "Apify Run ID to validate",
            "type": "string",
            "description": "Optional. Paste an Actor run ID and this Actor will validate that run's default dataset. Leave empty when using Dataset ID or pasted items."
          },
          "maxItems": {
            "title": "Maximum items to check",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Safety cap for fetched dataset/run items. Default is 1000, maximum is 50000. Use with validateAllItems for full-dataset pagination up to this cap.",
            "default": 1000
          },
          "validateAllItems": {
            "title": "Paginate through the dataset",
            "type": "boolean",
            "description": "When true, fetch multiple pages until the dataset is exhausted or maxItems is reached. When false, only one sample page is checked.",
            "default": false
          },
          "itemOffset": {
            "title": "Item offset",
            "minimum": 0,
            "type": "integer",
            "description": "Number of dataset items to skip before validation. Use this to inspect a later sample page.",
            "default": 0
          },
          "itemOrder": {
            "title": "Item order",
            "enum": [
              "first",
              "last"
            ],
            "type": "string",
            "description": "Validate the first stored items or the latest stored items first.",
            "default": "first"
          },
          "failRunOnError": {
            "title": "Fail the run when the gate fails",
            "type": "boolean",
            "description": "Turn this on for CI/CD, webhooks, or scheduled automations where bad data must stop the next step. Leave off for audit/report-only mode.",
            "default": false
          },
          "items": {
            "title": "Dataset items to validate manually",
            "type": "array",
            "description": "Optional fallback for pasted/exported JSON items. If datasetId or runId is provided, this manual sample is ignored.",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "requiredFields": {
            "title": "Fields that must be present",
            "type": "array",
            "description": "Field names that must exist and be non-empty in every item, such as id, url, title, price, or email.",
            "items": {
              "type": "string"
            }
          },
          "expectedSchema": {
            "title": "Expected field types",
            "type": "object",
            "description": "Map field names to expected top-level JSON types. Supported values: string, number, boolean, object, array, null.",
            "additionalProperties": true
          },
          "uniqueFields": {
            "title": "Fields that must be unique",
            "type": "array",
            "description": "Field names where duplicate non-empty values should fail the quality gate, such as id, url, sku, email, or profileUrl.",
            "items": {
              "type": "string"
            }
          },
          "formatRules": {
            "title": "URL, email, and date checks",
            "type": "object",
            "description": "Map field names to format checks. Supported values: url, email, date.",
            "additionalProperties": true
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}