{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/usewrit-app/json-schema/usewrit-app-dataset-records-schema.json",
  "title": "DatasetRecords",
  "description": "`GET /v1/datasets/{id}/records` with `format=json` — a page of the dataset's records. Reuses the workflow-data row shape.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/usewrit-app-datasets-api-openapi.yml#/components/schemas/DatasetRecords",
  "type": "object",
  "required": [
    "dataset",
    "columns",
    "declared",
    "records",
    "total",
    "scanned_runs",
    "truncated",
    "limit",
    "offset"
  ],
  "properties": {
    "dataset": {
      "$ref": "#/$defs/DatasetRef"
    },
    "columns": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "declared": {
      "type": "boolean",
      "description": "The columns come from the workflow's declared output fields."
    },
    "records": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DataTableRow"
      }
    },
    "total": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Matching records before pagination."
    },
    "scanned_runs": {
      "type": [
        "integer",
        "null"
      ]
    },
    "truncated": {
      "type": "boolean"
    },
    "limit": {
      "type": [
        "integer",
        "null"
      ]
    },
    "offset": {
      "type": [
        "integer",
        "null"
      ]
    }
  },
  "$defs": {
    "DataTableRow": {
      "type": "object",
      "description": "One table row: run-meta at the top level, data columns nested under `fields`. Lens views (`view=latest|run`) add a `lineage` sibling (`uid`, `change`, `changed_fields` — present only when change is `changed` —, `changed_leaf_count`, `first_seen_at`, `last_seen_at`, `versions`, `source`, and `prev_run_id` on run views).",
      "required": [
        "run_id",
        "run_at",
        "status",
        "record_index",
        "fields"
      ],
      "properties": {
        "run_id": {
          "type": "integer",
          "format": "int64"
        },
        "run_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "status": {
          "type": [
            "string",
            "null"
          ]
        },
        "record_index": {
          "type": "integer"
        },
        "fields": {
          "type": "object",
          "description": "The extracted data columns (redacted; a column absent for a row is null).",
          "additionalProperties": true
        },
        "lineage": {
          "type": "object",
          "description": "Lens views only.",
          "additionalProperties": true
        }
      }
    },
    "DatasetRef": {
      "type": "object",
      "description": "The dataset a record page or search hit belongs to.",
      "required": [
        "id",
        "name",
        "source_type"
      ],
      "properties": {
        "id": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int64"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_type": {
          "type": "string",
          "enum": [
            "crawl",
            "workflow"
          ]
        }
      }
    }
  }
}