{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "Proba Agent API",
    "version": "1.0.0",
    "description": "The implemented, organization-scoped launch surface. Configured credit-pack Checkout and webhook administration are REST-only and never MCP tools; raw pricing, provider credentials, storage references, and product caps are not exposed."
  },
  "servers": [{"url": "/"}],
  "security": [{"ProductApiKey": []}],
  "x-aurelius-blocked-operations": [
    {"operationId": "get_price_or_cap", "reason": "Production prices, credit conversion, and workload caps are unresolved STOP items."}
  ],
  "paths": {
    "/v1/models": {
      "get": {
        "operationId": "list_models",
        "summary": "List models in the active immutable catalog projection",
        "x-aurelius-scope": "read",
        "x-mcp-tool": true,
        "parameters": [
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "One snapshot-bound page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ModelPage"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/models/{id}/concepts": {
      "get": {
        "operationId": "list_model_concepts",
        "summary": "List readable coverage facts for one active-catalog model",
        "x-aurelius-scope": "read",
        "x-mcp-tool": true,
        "parameters": [
          {"$ref": "#/components/parameters/Id"},
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "One snapshot-bound page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ConceptPage"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/datasets": {
      "get": {
        "operationId": "list_datasets",
        "summary": "List datasets owned by the authenticated organization",
        "x-aurelius-scope": "read",
        "x-mcp-tool": false,
        "parameters": [
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "One snapshot-bound page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/DatasetPage"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      },
      "post": {
        "operationId": "create_dataset",
        "summary": "Create a direct dataset or a tenant-scoped signed-upload intent",
        "description": "Direct JSON Lines validate synchronously. A signed upload returns an exact PUT request and remains pending_upload until finalized.",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": true,
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateDatasetRequest"}}}},
        "responses": {
          "201": {"description": "Dataset created and validated", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Dataset"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/datasets/{id}": {
      "get": {
        "operationId": "get_dataset",
        "summary": "Get one organization-owned dataset",
        "x-aurelius-scope": "read",
        "x-mcp-tool": true,
        "parameters": [{"$ref": "#/components/parameters/Id"}],
        "responses": {
          "200": {"description": "Dataset", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Dataset"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/datasets/{id}/finalize": {
      "post": {
        "operationId": "finalize_dataset",
        "summary": "Verify a signed upload and idempotently enqueue validation",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": true,
        "parameters": [
          {"$ref": "#/components/parameters/Id"},
          {"$ref": "#/components/parameters/IdempotencyKey"}
        ],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": false}}}},
        "responses": {
          "200": {"description": "Upload accepted for asynchronous validation", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Dataset"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/jobs": {
      "get": {
        "operationId": "list_jobs",
        "summary": "List jobs owned by the authenticated organization",
        "x-aurelius-scope": "read",
        "x-mcp-tool": false,
        "parameters": [
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "One snapshot-bound page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/JobPage"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      },
      "post": {
        "operationId": "create_job",
        "summary": "Create a quote and immutable manifest for an evaluation job",
        "description": "Production quote price and workload caps remain disabled; the current implementation is explicitly fixture-gated.",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": true,
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateJobRequest"}}}},
        "responses": {
          "201": {"description": "Quoted job with frozen quote and manifest", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateJobResponse"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/jobs/{id}": {
      "get": {
        "operationId": "get_job",
        "summary": "Get one organization-owned job",
        "x-aurelius-scope": "read",
        "x-mcp-tool": true,
        "parameters": [{"$ref": "#/components/parameters/Id"}],
        "responses": {
          "200": {"description": "Job", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Job"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/jobs/{id}/confirm": {
      "post": {
        "operationId": "confirm_job",
        "summary": "Confirm a quoted job and dispatch it exactly once",
        "description": "This can spend only already-verified credits or an explicitly configured payment fallback; it never exposes purchase or credential operations.",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": true,
        "parameters": [
          {"$ref": "#/components/parameters/Id"},
          {"$ref": "#/components/parameters/IdempotencyKey"}
        ],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": false}}}},
        "responses": {
          "200": {"description": "Confirmed job", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ConfirmJobResponse"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/jobs/{id}/report": {
      "get": {
        "operationId": "get_report",
        "summary": "Get the immutable canonical report bytes for a succeeded job",
        "x-aurelius-scope": "read",
        "x-mcp-tool": true,
        "x-aurelius-canonical-bytes": true,
        "parameters": [{"$ref": "#/components/parameters/Id"}],
        "responses": {
          "200": {
            "description": "The stored App-F canonical report bytes; the server does not re-encode them",
            "headers": {
              "ETag": {"schema": {"type": "string"}},
              "Cache-Control": {"schema": {"type": "string", "const": "private, immutable"}}
            },
            "content": {"application/json": {"schema": {"type": "object"}}}
          },
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/jobs/{id}/artifacts": {
      "get": {
        "operationId": "get_job_artifacts",
        "summary": "Get short-lived tenant-checked URLs for a succeeded job's artifacts",
        "x-aurelius-scope": "read",
        "x-mcp-tool": false,
        "parameters": [{"$ref": "#/components/parameters/Id"}],
        "responses": {
          "200": {"description": "Signed artifact URLs", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/JobArtifacts"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/credits": {
      "get": {
        "operationId": "get_credits",
        "summary": "Get the organization credit balance and a snapshot-bound ledger page",
        "x-aurelius-scope": "read",
        "x-mcp-tool": true,
        "parameters": [
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "Credit balance and ledger page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Credits"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/credits/purchases": {
      "post": {
        "operationId": "purchase_credits",
        "summary": "Create Stripe Checkout for one explicitly configured credit-pack SKU",
        "description": "Credits are not granted by this response. They enter the append-only ledger only after a signature-verified, replay-protected provider webhook confirms this exact order.",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": false,
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreditPurchaseRequest"}}}},
        "responses": {
          "201": {"description": "Configured Checkout Session created", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreditPurchase"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/webhook_endpoints": {
      "get": {
        "operationId": "list_webhook_endpoints",
        "summary": "List organization-owned outbound webhook endpoints",
        "x-aurelius-scope": "read",
        "x-mcp-tool": false,
        "parameters": [
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "One snapshot-bound endpoint page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/WebhookEndpointPage"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      },
      "post": {
        "operationId": "create_webhook_endpoint",
        "summary": "Create an outbound webhook endpoint and issue its signing secret once",
        "description": "The raw secret is derived from the operator keyring and endpoint identity. It is returned only on the first successful call and is never persisted, including in the idempotency record.",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": false,
        "parameters": [{"$ref": "#/components/parameters/IdempotencyKey"}],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/CreateWebhookEndpointRequest"}}}},
        "responses": {
          "201": {"description": "Endpoint created; secret is present only when secret_returned is true", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/WebhookEndpoint"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/webhook_endpoints/{id}/disable": {
      "post": {
        "operationId": "disable_webhook_endpoint",
        "summary": "Disable an outbound webhook endpoint",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": false,
        "parameters": [
          {"$ref": "#/components/parameters/Id"},
          {"$ref": "#/components/parameters/IdempotencyKey"}
        ],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": false}}}},
        "responses": {
          "200": {"description": "Disabled endpoint", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/WebhookEndpoint"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/webhook_deliveries": {
      "get": {
        "operationId": "list_webhook_deliveries",
        "summary": "List delivery obligations and append-only attempt metadata",
        "x-aurelius-scope": "read",
        "x-mcp-tool": false,
        "parameters": [
          {"$ref": "#/components/parameters/Cursor"},
          {"$ref": "#/components/parameters/Limit"}
        ],
        "responses": {
          "200": {"description": "One snapshot-bound delivery page", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/WebhookDeliveryPage"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    },
    "/v1/webhook_deliveries/{id}/replay": {
      "post": {
        "operationId": "replay_webhook_delivery",
        "summary": "Create a new obligation for one dead-lettered delivery",
        "x-aurelius-scope": "jobs:write",
        "x-mcp-tool": false,
        "parameters": [
          {"$ref": "#/components/parameters/Id"},
          {"$ref": "#/components/parameters/IdempotencyKey"}
        ],
        "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": false}}}},
        "responses": {
          "201": {"description": "Replay obligation queued", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/WebhookDelivery"}}}},
          "default": {"$ref": "#/components/responses/Problem"}
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ProductApiKey": {"type": "http", "scheme": "bearer", "bearerFormat": "Aurelius organization API key"}
    },
    "parameters": {
      "Id": {"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}},
      "Cursor": {"name": "cursor", "in": "query", "required": false, "description": "Opaque, snapshot-bound cursor", "schema": {"type": "string"}},
      "Limit": {"name": "limit", "in": "query", "required": false, "description": "Page-size hint; the server may cap it", "schema": {"type": "integer", "minimum": 1}},
      "IdempotencyKey": {"name": "Idempotency-Key", "in": "header", "required": true, "schema": {"type": "string", "minLength": 1, "maxLength": 255}}
    },
    "responses": {
      "Problem": {"description": "C0 problem", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Problem"}}}}
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "additionalProperties": false,
        "required": ["type", "message", "remediation", "doc_url"],
        "properties": {
          "type": {"type": "string"},
          "message": {"type": "string"},
          "remediation": {"type": "string"},
          "doc_url": {"type": "string", "format": "uri"}
        }
      },
      "PageCursor": {"type": ["string", "null"], "description": "Opaque cursor or null at the end"},
      "Model": {
        "type": "object",
        "required": ["id", "model_ref", "revision", "display_name", "concept_count", "readable_concept_count", "primitive_count"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "model_ref": {"type": "string"},
          "revision": {"type": "string"},
          "display_name": {"type": "string"},
          "concept_count": {"type": "integer"},
          "readable_concept_count": {"type": "integer"},
          "primitive_count": {"type": "integer"}
        }
      },
      "ModelPage": {
        "type": "object",
        "required": ["catalog_version", "data", "next_cursor"],
        "properties": {"catalog_version": {"type": "string"}, "data": {"type": "array", "items": {"$ref": "#/components/schemas/Model"}}, "next_cursor": {"$ref": "#/components/schemas/PageCursor"}}
      },
      "ConceptPage": {
        "type": "object",
        "required": ["catalog_version", "model", "data", "next_cursor"],
        "additionalProperties": false,
        "properties": {"catalog_version": {"type": "string"}, "model": {"$ref": "#/components/schemas/ModelIdentity"}, "data": {"type": "array", "items": {"$ref": "#/components/schemas/ConceptCoverage"}}, "next_cursor": {"$ref": "#/components/schemas/PageCursor"}}
      },
      "ConceptCoverage": {
        "type": "object",
        "additionalProperties": false,
        "required": ["concept_id", "display_name", "description", "calibration_tier", "status", "primitive_count", "method_family_counts", "provenance_counts", "primitive_result_refs", "quality_floor"],
        "properties": {
          "concept_id": {"type": "string", "minLength": 1},
          "display_name": {"type": "string", "minLength": 1},
          "description": {"type": "string", "minLength": 1},
          "calibration_tier": {"type": "string", "enum": ["unrated", "tier_a", "tier_b", "tier_c"]},
          "status": {"type": "string", "enum": ["readable", "unreadable"]},
          "primitive_count": {"type": "integer", "minimum": 0},
          "method_family_counts": {"$ref": "#/components/schemas/StringCounts"},
          "provenance_counts": {"$ref": "#/components/schemas/ProvenanceCounts"},
          "primitive_result_refs": {"type": "array", "items": {"type": "string", "pattern": "^res_[0-9a-f]{64}$"}, "uniqueItems": true},
          "quality_floor": {"$ref": "#/components/schemas/QualityFloor"}
        }
      },
      "StringCounts": {
        "type": "object",
        "additionalProperties": {"type": "integer", "minimum": 0}
      },
      "ProvenanceCounts": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "operator_curated": {"type": "integer", "minimum": 0},
          "subnet_validated": {"type": "integer", "minimum": 0}
        }
      },
      "QualityFloor": {
        "type": "object",
        "additionalProperties": false,
        "required": ["intrinsic", "consumption_contract"],
        "properties": {
          "intrinsic": {"type": ["string", "null"], "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"},
          "consumption_contract": {"type": ["string", "null"], "pattern": "^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"}
        }
      },
      "ModelIdentity": {
        "type": "object",
        "required": ["id", "model_ref", "revision", "display_name"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "model_ref": {"type": "string"},
          "revision": {"type": "string"},
          "display_name": {"type": "string"}
        }
      },
      "CreateDatasetRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "jsonl": {"type": "string", "description": "UTF-8 C0 preference rows as JSON Lines"},
          "upload": {"$ref": "#/components/schemas/DatasetUploadIntent"}
        },
        "oneOf": [
          {"required": ["jsonl"]},
          {"required": ["upload"]}
        ]
      },
      "DatasetUploadIntent": {
        "type": "object",
        "additionalProperties": false,
        "required": ["byte_count", "sha256", "content_type", "ttl_seconds"],
        "properties": {
          "byte_count": {"type": "integer", "minimum": 1},
          "sha256": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
          "content_type": {"type": "string", "const": "application/x-ndjson"},
          "ttl_seconds": {"type": "integer", "minimum": 1}
        }
      },
      "SignedUpload": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url", "method", "headers", "expires_at", "byte_count", "sha256"],
        "properties": {
          "url": {"type": "string", "format": "uri"},
          "method": {"type": "string", "const": "PUT"},
          "headers": {"type": "object", "additionalProperties": {"type": "string"}},
          "expires_at": {"type": "string", "format": "date-time"},
          "byte_count": {"type": "integer", "minimum": 1},
          "sha256": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
        }
      },
      "Dataset": {
        "type": "object",
        "required": ["id", "status", "canonical_pair_count", "validation_report_ref", "validation_report"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "status": {"type": "string", "enum": ["pending_upload", "processing", "valid", "invalid"]},
          "content_hash": {"type": ["string", "null"]},
          "canonical_pair_count": {"type": "integer"},
          "validation_report_ref": {"type": "string"},
          "validation_report": {"type": ["object", "null"]},
          "upload": {"$ref": "#/components/schemas/SignedUpload"}
        }
      },
      "DatasetPage": {
        "type": "object",
        "required": ["data", "next_cursor"],
        "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Dataset"}}, "next_cursor": {"$ref": "#/components/schemas/PageCursor"}}
      },
      "ModelSelection": {
        "type": "object",
        "additionalProperties": false,
        "required": ["model_ref", "revision"],
        "properties": {"model_ref": {"type": "string"}, "revision": {"type": "string"}}
      },
      "CreateJobRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["dataset_id", "model", "concept_set"],
        "properties": {
          "dataset_id": {"type": "string", "format": "uuid"},
          "model": {"$ref": "#/components/schemas/ModelSelection"},
          "concept_set": {"type": "array", "minItems": 1, "items": {"type": "string"}},
          "options": {"type": "object"}
        }
      },
      "Job": {
        "type": "object",
        "required": ["id", "status", "dataset_id", "model", "concept_set", "mode"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "status": {"type": "string", "enum": ["draft", "validating", "quoted", "confirmed", "queued", "running", "succeeded", "failed", "canceled"]},
          "dataset_id": {"type": "string", "format": "uuid"},
          "model": {"$ref": "#/components/schemas/ModelSelection"},
          "concept_set": {"type": "array", "items": {"type": "string"}},
          "mode": {"type": "string", "const": "operator_side"},
          "payment_method": {"type": ["string", "null"]},
          "failure_type": {"type": ["string", "null"]}
        }
      },
      "JobPage": {
        "type": "object",
        "required": ["data", "next_cursor"],
        "properties": {"data": {"type": "array", "items": {"$ref": "#/components/schemas/Job"}}, "next_cursor": {"$ref": "#/components/schemas/PageCursor"}}
      },
      "CreateJobResponse": {
        "type": "object",
        "required": ["job", "quote", "manifest"],
        "properties": {"job": {"$ref": "#/components/schemas/Job"}, "quote": {"type": "object"}, "manifest": {"type": "object"}}
      },
      "ConfirmJobResponse": {
        "type": "object",
        "required": ["job", "payment"],
        "properties": {"job": {"$ref": "#/components/schemas/Job"}, "payment": {"type": "object"}}
      },
      "SignedArtifact": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url", "method", "headers", "expires_at", "byte_count", "sha256", "content_type"],
        "properties": {
          "url": {"type": "string", "format": "uri"},
          "method": {"type": "string", "const": "GET"},
          "headers": {"type": "object", "additionalProperties": {"type": "string"}},
          "expires_at": {"type": "string", "format": "date-time"},
          "byte_count": {"type": "integer", "minimum": 0},
          "sha256": {"type": ["string", "null"]},
          "content_type": {"type": ["string", "null"]}
        }
      },
      "JobArtifacts": {
        "type": "object",
        "additionalProperties": false,
        "required": ["delta_matrix"],
        "properties": {"delta_matrix": {"$ref": "#/components/schemas/SignedArtifact"}}
      },
      "LedgerEntry": {
        "type": "object",
        "required": ["id", "event_type", "amount_delta", "balance_after"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "event_type": {"type": "string"},
          "amount_delta": {"type": "string"},
          "balance_after": {"type": "string"},
          "job_id": {"type": ["string", "null"]},
          "provider_event_id": {"type": ["string", "null"]}
        }
      },
      "Credits": {
        "type": "object",
        "required": ["balance", "ledger", "next_cursor"],
        "properties": {"balance": {"type": "string"}, "ledger": {"type": "array", "items": {"$ref": "#/components/schemas/LedgerEntry"}}, "next_cursor": {"$ref": "#/components/schemas/PageCursor"}}
      },
      "CreditPurchaseRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sku"],
        "properties": {"sku": {"type": "string", "minLength": 1, "maxLength": 128}}
      },
      "CreditPurchase": {
        "type": "object",
        "additionalProperties": false,
        "required": ["order_id", "status", "sku", "credits", "checkout_url", "expires_at"],
        "properties": {
          "order_id": {"type": "string", "format": "uuid"},
          "status": {"type": "string", "enum": ["provider_created", "paid"]},
          "sku": {"type": "string"},
          "credits": {"type": "string", "pattern": "^(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?$"},
          "checkout_url": {"type": "string", "format": "uri"},
          "expires_at": {"type": ["integer", "null"]}
        }
      },
      "CreateWebhookEndpointRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["url", "event_types"],
        "properties": {
          "url": {"type": "string", "format": "uri", "maxLength": 2048},
          "event_types": {
            "type": "array",
            "minItems": 1,
            "maxItems": 3,
            "uniqueItems": true,
            "items": {"type": "string", "enum": ["job.*", "dataset.validated", "credits.low"]}
          }
        }
      },
      "WebhookEndpoint": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "url", "event_types", "active", "key_id", "key_fingerprint", "disabled_at", "created_at"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "url": {"type": "string", "format": "uri"},
          "event_types": {"type": "array", "items": {"type": "string"}},
          "active": {"type": "boolean"},
          "key_id": {"type": "string"},
          "key_fingerprint": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
          "disabled_at": {"type": ["string", "null"], "format": "date-time"},
          "created_at": {"type": "string", "format": "date-time"},
          "secret": {"type": "string", "description": "Present only on the first successful endpoint creation response"},
          "secret_returned": {"type": "boolean"}
        }
      },
      "WebhookEndpointPage": {
        "type": "object",
        "required": ["data", "next_cursor"],
        "properties": {
          "data": {"type": "array", "items": {"$ref": "#/components/schemas/WebhookEndpoint"}},
          "next_cursor": {"$ref": "#/components/schemas/PageCursor"}
        }
      },
      "WebhookDeliveryAttempt": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "attempt_number", "resolved_ip", "outcome", "status_code", "response_byte_count", "error_code", "duration_ms", "created_at"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "attempt_number": {"type": "integer", "minimum": 1},
          "resolved_ip": {"type": ["string", "null"]},
          "outcome": {"type": "string", "enum": ["delivered", "retry_scheduled", "dead_lettered"]},
          "status_code": {"type": ["integer", "null"], "minimum": 100, "maximum": 599},
          "response_byte_count": {"type": "integer", "minimum": 0},
          "error_code": {"type": ["string", "null"]},
          "duration_ms": {"type": "integer", "minimum": 0},
          "created_at": {"type": "string", "format": "date-time"}
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "endpoint_id", "event_id", "event_type", "state", "attempt_count", "replay_sequence", "replayed_from_id", "next_attempt_at", "delivered_at", "dead_lettered_at", "last_error_code", "created_at", "attempts"],
        "properties": {
          "id": {"type": "string", "format": "uuid"},
          "endpoint_id": {"type": "string", "format": "uuid"},
          "event_id": {"type": "string", "format": "uuid"},
          "event_type": {"type": "string"},
          "state": {"type": "string", "enum": ["pending", "delivering", "delivered", "dead_letter"]},
          "attempt_count": {"type": "integer", "minimum": 0},
          "replay_sequence": {"type": "integer", "minimum": 0},
          "replayed_from_id": {"type": ["string", "null"], "format": "uuid"},
          "next_attempt_at": {"type": ["string", "null"], "format": "date-time"},
          "delivered_at": {"type": ["string", "null"], "format": "date-time"},
          "dead_lettered_at": {"type": ["string", "null"], "format": "date-time"},
          "last_error_code": {"type": ["string", "null"]},
          "created_at": {"type": "string", "format": "date-time"},
          "attempts": {"type": "array", "items": {"$ref": "#/components/schemas/WebhookDeliveryAttempt"}}
        }
      },
      "WebhookDeliveryPage": {
        "type": "object",
        "required": ["data", "next_cursor"],
        "properties": {
          "data": {"type": "array", "items": {"$ref": "#/components/schemas/WebhookDelivery"}},
          "next_cursor": {"$ref": "#/components/schemas/PageCursor"}
        }
      }
    }
  }
}
