{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tale-dev/json-schema/tale-dev-website-schema.json",
  "title": "Website",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tale-dev-websites-api-openapi.yml#/components/schemas/Website",
  "type": "object",
  "required": [
    "id",
    "organizationId",
    "domain",
    "scanInterval",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "organizationId": {
      "type": "string"
    },
    "domain": {
      "type": "string"
    },
    "kind": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "site",
        "list",
        null
      ]
    },
    "title": {
      "type": [
        "string",
        "null"
      ]
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "scanInterval": {
      "type": "string"
    },
    "lastScannedAt": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "description": "When the last scan ENDED, epoch ms; `null` until the first scan finishes — `status: \"scanning\"` is the in-flight signal, and the page counts move while it runs"
    },
    "status": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "scanning",
        "active",
        "error",
        "deleting",
        null
      ],
      "description": "The SCAN’s lifecycle, not the content’s health: `scanning` — in flight (a registered site starts here); `active` — the last scan finished and stored at least one page; `error` — the last scan failed or stored no page (`metadata.lastSyncError` says why; a domain that does not resolve or an expired certificate lands here, never on `active`); `deleting` — mid removal. The obvious health check is `status === \"active\"`; `crawledPageCount - failedPageCount` says how many pages it holds."
    },
    "pageCount": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Pages the crawler knows on this site, as of the last corpus → row sync (`metadata.lastStatusSyncAt` says when): during a scan the sync runs after discovery and after every stored batch, at each link’s end and at the scan’s end, and `POST /api/v1/websites/{id}/sync` forces one"
    },
    "crawledPageCount": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Pages the crawler ATTEMPTED in its scans so far — stored or not; a page whose every attempt failed counts here too (see `failedPageCount`), and `indexed` per page is on `GET /api/v1/websites/{id}/pages`. Stamped by the corpus → row sync like `pageCount`"
    },
    "failedPageCount": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Pages whose LAST attempt failed — each carries its `lastError` in the pages list. A page the crawler skipped on purpose (`lastErrorKind` `robots_noindex`, `unsupported_content` or `host_not_allowed`) keeps its reason but is not counted here; `null` until the next corpus → row sync stamps the row"
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "createdAt": {
      "type": "integer",
      "minimum": 0,
      "description": "Epoch milliseconds"
    },
    "updatedAt": {
      "type": "integer",
      "minimum": 0,
      "description": "Epoch milliseconds"
    }
  }
}