{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Output Acceptance Gate",
    "description": "Decide whether a dataset is safe to send downstream. Check schema, coverage, duplicates, currency, geography, canaries, and a saved baseline, then return accepted, partial, or rejected.",
    "version": "0.1",
    "x-build-id": "dYfriPhepAKCg7bEa"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/plusonets~dataset-output-acceptance-gate/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-plusonets-dataset-output-acceptance-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/plusonets~dataset-output-acceptance-gate/runs": {
      "post": {
        "operationId": "runs-sync-plusonets-dataset-output-acceptance-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/plusonets~dataset-output-acceptance-gate/run-sync": {
      "post": {
        "operationId": "run-sync-plusonets-dataset-output-acceptance-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": {
          "sourceType": {
            "title": "Source",
            "enum": [
              "bundledSample",
              "dataset",
              "run",
              "url",
              "inline"
            ],
            "type": "string",
            "description": "Where to read rows. Dataset and run use this run's token. A URL must be public JSON or CSV. Inline accepts pasted JSON or CSV. The bundled sample needs no token.",
            "default": "bundledSample"
          },
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "Dataset in your Apify account. Limited permissions grant read access only to the dataset you enter here."
          },
          "runId": {
            "title": "Run ID",
            "type": "string",
            "description": "Run in your account. The gate reads that run's default dataset and, when the token allows it, the run's usage. If run lookup is denied, paste the run's default dataset ID instead."
          },
          "sourceUrl": {
            "title": "Public JSON or CSV URL",
            "type": "string",
            "description": "http or https URL of a JSON array, JSON object with an items list, NDJSON, or CSV. Private networks, localhost, and link-local addresses are rejected."
          },
          "inlineData": {
            "title": "Pasted JSON or CSV",
            "type": "string",
            "description": "Raw JSON or CSV, up to 20 MB. Used when Source is Pasted JSON or CSV."
          },
          "inlineFormat": {
            "title": "Pasted format",
            "enum": [
              "json",
              "csv"
            ],
            "type": "string",
            "description": "Format of the pasted rows: JSON (an array of objects) or CSV with a header row.",
            "default": "json"
          },
          "preset": {
            "title": "Contract preset",
            "enum": [
              "products",
              "jobs",
              "places",
              "reviews",
              "custom"
            ],
            "type": "string",
            "description": "Starting contract. Jobs, products, places, and reviews fill identity keys, types, and coverage thresholds. Custom starts empty. Any field you set below overrides the preset.",
            "default": "products"
          },
          "identityMode": {
            "title": "Identity mode",
            "enum": [
              "alternate",
              "composite"
            ],
            "type": "string",
            "description": "Alternate uses the first identity field that is filled on at least half the business rows. Composite requires every identity field on a row.",
            "default": "alternate"
          },
          "identityKeys": {
            "title": "Identity keys",
            "type": "array",
            "description": "Fields that identify one business row, in priority order. Leave empty to keep the preset. Example: sku, productId, id.",
            "items": {
              "type": "string"
            }
          },
          "fieldTypes": {
            "title": "Field types",
            "type": "object",
            "description": "Expected type for each present value. Missing values are a coverage problem, not a type error. Types: string, number, integer, boolean, array, object, url, date, email.",
            "default": {}
          },
          "requiredFields": {
            "title": "Required fields",
            "type": "array",
            "description": "Leave empty to keep the preset. A type error on a required field rejects the dataset.",
            "items": {
              "type": "string"
            }
          },
          "coverageThresholds": {
            "title": "Coverage thresholds",
            "type": "object",
            "description": "Minimum share of business rows that must have each field, from 0 to 1. Example: {\"price\": 0.9, \"currency\": 0.99}.",
            "default": {}
          },
          "allowedValues": {
            "title": "Allowed values",
            "type": "object",
            "description": "Allow-list per field. Any other present value rejects the dataset. Example: {\"currency\": [\"USD\", \"EUR\"], \"country\": [\"US\", \"CA\"]}.",
            "default": {}
          },
          "numericRanges": {
            "title": "Numeric ranges",
            "type": "object",
            "description": "Inclusive min and max for numeric fields. The reviews preset already limits rating to 0-5. Example: {\"rating\": {\"min\": 1, \"max\": 5}}.",
            "default": {}
          },
          "minRows": {
            "title": "Minimum business rows",
            "minimum": 0,
            "type": "integer",
            "description": "Counted after status-only rows are removed. Use 0 when an empty table is acceptable on its own.",
            "default": 1
          },
          "maxRows": {
            "title": "Maximum business rows",
            "minimum": 0,
            "type": "integer",
            "description": "Reject when the business-row count is above this. Leave empty for no maximum."
          },
          "allowLegitimatelyEmpty": {
            "title": "Allow a legitimately empty result",
            "type": "boolean",
            "description": "Accept zero business rows when the dataset is empty, or when a status row says the source was empty (empty, no_results, legitimately_empty). Error statuses still reject.",
            "default": false
          },
          "canaryRecords": {
            "title": "Canary records",
            "type": "array",
            "description": "Objects that must match at least one business row. Example: [{\"sku\": \"OFC-1001\"}].",
            "default": []
          },
          "coverageCollapseRatio": {
            "title": "Coverage collapse ratio",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Reject when a critical field's coverage falls below this fraction of the baseline. Critical fields are identity, required fields, threshold fields, currency, and geography. Baseline coverage under 50% is ignored.",
            "default": 0.8
          },
          "maxDuplicateRatio": {
            "title": "Maximum duplicate ratio",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Extra copies divided by business rows. Above this rejects. Any duplicates at or below this make the verdict partial.",
            "default": 0.02
          },
          "shiftTolerance": {
            "title": "New currency or country tolerance",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Share of business rows that may carry a currency or country the baseline has never seen. Above this rejects. A dominant-value change inside the known set is partial.",
            "default": 0.05
          },
          "maxRowsToCheck": {
            "title": "Maximum rows to check",
            "minimum": 1,
            "maximum": 200000,
            "type": "integer",
            "description": "Stop after this many rows. The verdict is partial, and the baseline is not replaced, because the rest of the dataset was not seen.",
            "default": 50000
          },
          "baselineStoreName": {
            "title": "Baseline store",
            "type": "string",
            "description": "Named key-value store for accepted profiles. A rejected, partial, or failed run does not overwrite the last accepted profile.",
            "default": "acceptance-gate-baselines"
          },
          "baselineKey": {
            "title": "Baseline key",
            "type": "string",
            "description": "Stable name for this workflow, such as acme-products-daily. Empty uses the preset plus the dataset ID, upstream Actor ID, or URL."
          },
          "baselineDatasetId": {
            "title": "Baseline dataset ID",
            "type": "string",
            "description": "Optional previous dataset to compare for this run. When set, it is the comparison target instead of the stored profile. It is not billed as a second assessment."
          },
          "failOnRejection": {
            "title": "Fail the run when rejected",
            "type": "boolean",
            "description": "Exit with a failed run status after the report is written. Use this so a webhook or integration stops on rejection. Partial and accepted runs still succeed.",
            "default": false
          },
          "alertOnlyOnChange": {
            "title": "Dataset rows only when the profile changes",
            "type": "boolean",
            "description": "When the verdict is accepted and coverage, identity count, currency, and geography are close to the baseline, push only the verdict row. The HTML and JSON reports are still written. Rejected and partial runs always include the checks.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}