{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/citeladder-com/json-schema/citeladder-com-crawl-coverage-response-schema.json",
  "title": "CrawlCoverageResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/citeladder-com-ai-traffic-api-openapi.yml#/components/schemas/CrawlCoverageResponse",
  "type": "object",
  "properties": {
    "items": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "source_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "reporting_date": {
            "type": "string"
          },
          "reporting_timezone": {
            "type": "string"
          },
          "coverage": {
            "type": "string",
            "enum": [
              "complete",
              "declared_complete",
              "partial",
              "unknown"
            ]
          },
          "reason": {
            "type": "string"
          },
          "batch_count": {
            "type": "number"
          },
          "heartbeat_count": {
            "type": "number"
          },
          "max_gap_minutes": {
            "type": "number"
          }
        },
        "required": [
          "source_id",
          "reporting_date",
          "reporting_timezone",
          "coverage",
          "reason",
          "batch_count",
          "heartbeat_count",
          "max_gap_minutes"
        ],
        "additionalProperties": false
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CrawlSource"
      }
    },
    "next_cursor": {
      "type": [
        "string",
        "null"
      ]
    }
  },
  "required": [
    "items",
    "sources",
    "next_cursor"
  ],
  "additionalProperties": false,
  "$defs": {
    "CrawlSource": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        "kind": {
          "type": "string",
          "enum": [
            "webhook",
            "pull",
            "upload"
          ]
        },
        "setup": {
          "type": "string",
          "enum": [
            "cloudflare_worker",
            "cloudflare_logpush",
            "aws_firehose",
            "gcp_pubsub_pull",
            "custom",
            "upload"
          ]
        },
        "preset": {
          "type": "string"
        },
        "buffer_interval_seconds": {
          "type": [
            "number",
            "null"
          ]
        },
        "format": {
          "type": "string"
        },
        "collection_point": {
          "type": "string"
        },
        "sampling": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "none"
                }
              },
              "required": [
                "kind"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "sampled"
                },
                "rate": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 1
                }
              },
              "required": [
                "kind",
                "rate"
              ],
              "additionalProperties": false
            },
            {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "const": "filtered"
                },
                "description": {
                  "type": "string"
                }
              },
              "required": [
                "kind",
                "description"
              ],
              "additionalProperties": false
            }
          ]
        },
        "origin": {
          "type": "string"
        },
        "host": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "active",
            "revoked"
          ]
        },
        "state": {
          "type": "string",
          "enum": [
            "active",
            "awaiting_verification",
            "stalled",
            "revoked"
          ]
        },
        "stall_reason": {
          "anyOf": [
            {
              "$ref": "#/$defs/CrawlStallReason"
            },
            {
              "type": "null"
            }
          ]
        },
        "stalled_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "pull": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "subscription": {
                  "type": "string"
                },
                "verification_nonce": {
                  "type": "string"
                },
                "verified_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "verification_checked_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "verification_failure": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/CrawlVerificationFailure"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "filter_catalog_version": {
                  "type": "string"
                },
                "filter_confirmed_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "filter_current": {
                  "type": "boolean"
                },
                "declared_sample_rate": {
                  "type": "number"
                },
                "last_pull_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "last_drained_at": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "subscription",
                "verification_nonce",
                "verified_at",
                "verification_checked_at",
                "verification_failure",
                "filter_catalog_version",
                "filter_confirmed_at",
                "filter_current",
                "declared_sample_rate",
                "last_pull_at",
                "last_drained_at"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "token_prefix": {
          "type": [
            "string",
            "null"
          ]
        },
        "connection": {
          "type": "string",
          "enum": [
            "not_connected",
            "awaiting_data",
            "connected"
          ]
        },
        "last_accepted_batch": {
          "type": [
            "string",
            "null"
          ]
        },
        "last_processed_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "rejected_lines": {
          "type": "number"
        },
        "overlapping_lines": {
          "type": "number"
        },
        "unsupported_uploads": {
          "type": "number"
        },
        "unsupported_batches": {
          "type": "number"
        }
      },
      "required": [
        "id",
        "kind",
        "setup",
        "preset",
        "buffer_interval_seconds",
        "format",
        "collection_point",
        "sampling",
        "origin",
        "host",
        "status",
        "state",
        "stall_reason",
        "stalled_at",
        "pull",
        "token_prefix",
        "connection",
        "last_accepted_batch",
        "last_processed_at",
        "rejected_lines",
        "overlapping_lines",
        "unsupported_uploads",
        "unsupported_batches"
      ],
      "additionalProperties": false
    },
    "CrawlStallReason": {
      "type": "string",
      "enum": [
        "no_receipts",
        "not_in_plan",
        "oversize",
        "verification_failed"
      ]
    },
    "CrawlVerificationFailure": {
      "type": "string",
      "enum": [
        "label_mismatch",
        "push_subscription",
        "ack_deadline",
        "permission_denied",
        "not_found",
        "unavailable"
      ]
    }
  }
}