{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/snaplab-dev/json-schema/snaplab-dev-capture-schema.json",
  "title": "Capture",
  "x-generated": "2026-10-31",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/snaplab-dev-openapi.json#/components/schemas/Capture",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "userId": {
      "type": "string"
    },
    "apiKeyId": {
      "type": [
        "string",
        "null"
      ]
    },
    "url": {
      "type": "string"
    },
    "title": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "processing",
        "completed",
        "failed"
      ]
    },
    "format": {
      "type": "string"
    },
    "selector": {
      "type": [
        "string",
        "null"
      ]
    },
    "fullPage": {
      "type": "boolean"
    },
    "width": {
      "type": "integer"
    },
    "height": {
      "type": "integer"
    },
    "deviceScaleFactor": {
      "type": "integer"
    },
    "darkMode": {
      "type": "boolean"
    },
    "fileKey": {
      "type": [
        "string",
        "null"
      ]
    },
    "fileSize": {
      "type": [
        "integer",
        "null"
      ]
    },
    "fingerprint": {
      "type": [
        "string",
        "null"
      ]
    },
    "error": {
      "type": [
        "string",
        "null"
      ]
    },
    "durationMs": {
      "type": [
        "integer",
        "null"
      ]
    },
    "cacheHit": {
      "type": "boolean"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "completedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "webhook": {
      "$ref": "#/$defs/CaptureWebhook",
      "description": "Only on `GET /api/captures/{id}`, and only when a callback was set."
    }
  },
  "$defs": {
    "CaptureWebhook": {
      "type": "object",
      "description": "Present on `GET /api/captures/{id}` only when a callback was set.",
      "properties": {
        "url": {
          "type": "string",
          "format": "uri"
        },
        "deliveries": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/WebhookDelivery"
          }
        }
      }
    },
    "WebhookDelivery": {
      "type": "object",
      "description": "One delivery attempt of a capture callback. Attempts run at 0s, 30s, 5min and 30min; after the fourth the row is `gave_up`.",
      "properties": {
        "id": {
          "type": "string"
        },
        "attempt": {
          "type": "integer",
          "description": "Attempts made so far, 1-4."
        },
        "status": {
          "type": "string",
          "enum": [
            "pending",
            "ok",
            "failed",
            "gave_up"
          ]
        },
        "lastStatusCode": {
          "type": [
            "integer",
            "null"
          ],
          "description": "HTTP status of the last attempt; null if the request never completed."
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  }
}