{
  "openapi": "3.1.0",
  "info": {
    "title": "PeptideBenchmark Public COA Evidence API",
    "version": "1.3.0",
    "summary": "Reusable public certificate evidence with source context intact.",
    "description": "A versioned, read-only API for source-linked peptide certificate evidence. Stable IDs, citation permalinks, exact product relationships, document fingerprints, provider health, and field-level provenance remain part of every record. Inclusion is not a blanket product-safety endorsement."
  },
  "servers": [
    {
      "url": "https://peptidebenchmark.com"
    }
  ],
  "externalDocs": {
    "description": "API guide, examples, reuse policy, and CSV documentation",
    "url": "https://peptidebenchmark.com/testing/coas/api/"
  },
  "tags": [
    {
      "name": "Certificates",
      "description": "Certificate records and filtered exports."
    },
    {
      "name": "Vendors",
      "description": "Vendor directory and vendor-specific evidence feeds."
    },
    {
      "name": "Compounds",
      "description": "Compound directory and compound-specific evidence feeds."
    },
    {
      "name": "Anomalies",
      "description": "Grouped, confidence-scored document-forensics review queue."
    }
  ],
  "paths": {
    "/api/v1/coas": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "listCertificates",
        "summary": "List, filter, or export certificate records",
        "parameters": [
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "$ref": "#/components/parameters/VendorFilter"
          },
          {
            "$ref": "#/components/parameters/CompoundFilter"
          },
          {
            "$ref": "#/components/parameters/LaboratoryFilter"
          },
          {
            "$ref": "#/components/parameters/PanelFilter"
          },
          {
            "$ref": "#/components/parameters/StatusFilter"
          },
          {
            "$ref": "#/components/parameters/EvidenceFilter"
          },
          {
            "$ref": "#/components/parameters/Sort"
          },
          {
            "$ref": "#/components/parameters/ExactProductFilter"
          },
          {
            "$ref": "#/components/parameters/Format"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated certificate evidence feed. Request text/csv or format=csv for a complete filtered CSV export.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              },
              "Link": {
                "description": "RFC 8288 next-page link when more records are available.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Record-Count": {
                "description": "Total filtered record count.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-PB-Next-Cursor": {
                "description": "Opaque next-page cursor when more records are available.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordList"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid pagination cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Pagination cursor belongs to an earlier dataset generation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "CSV export exceeds the 10,000-record limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/{record_id}": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "getCertificate",
        "summary": "Resolve one stable certificate record",
        "parameters": [
          {
            "$ref": "#/components/parameters/RecordId"
          }
        ],
        "responses": {
          "200": {
            "description": "One certificate evidence record.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Record not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/vendors": {
      "get": {
        "tags": [
          "Vendors"
        ],
        "operationId": "listVendors",
        "summary": "List vendor feed slugs and record counts",
        "responses": {
          "200": {
            "description": "Vendor evidence directory.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VendorDirectory"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/vendors/{vendor_slug}": {
      "get": {
        "tags": [
          "Vendors"
        ],
        "operationId": "getVendorFeed",
        "summary": "List or export one vendor’s certificate evidence",
        "parameters": [
          {
            "$ref": "#/components/parameters/VendorSlug"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "$ref": "#/components/parameters/CompoundFilter"
          },
          {
            "$ref": "#/components/parameters/LaboratoryFilter"
          },
          {
            "$ref": "#/components/parameters/PanelFilter"
          },
          {
            "$ref": "#/components/parameters/StatusFilter"
          },
          {
            "$ref": "#/components/parameters/EvidenceFilter"
          },
          {
            "$ref": "#/components/parameters/Sort"
          },
          {
            "$ref": "#/components/parameters/ExactProductFilter"
          },
          {
            "$ref": "#/components/parameters/Format"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated certificate evidence feed. Request text/csv or format=csv for a complete filtered CSV export.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              },
              "Link": {
                "description": "RFC 8288 next-page link when more records are available.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Record-Count": {
                "description": "Total filtered record count.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-PB-Next-Cursor": {
                "description": "Opaque next-page cursor when more records are available.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordList"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid pagination cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Vendor feed not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Pagination cursor belongs to an earlier dataset generation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "CSV export exceeds the 10,000-record limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/compounds": {
      "get": {
        "tags": [
          "Compounds"
        ],
        "operationId": "listCompounds",
        "summary": "List compound feed slugs and record counts",
        "responses": {
          "200": {
            "description": "Compound evidence directory.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompoundDirectory"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/compounds/{compound_slug}": {
      "get": {
        "tags": [
          "Compounds"
        ],
        "operationId": "getCompoundFeed",
        "summary": "List or export one compound’s certificate evidence",
        "parameters": [
          {
            "$ref": "#/components/parameters/CompoundSlug"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "$ref": "#/components/parameters/VendorFilter"
          },
          {
            "$ref": "#/components/parameters/LaboratoryFilter"
          },
          {
            "$ref": "#/components/parameters/PanelFilter"
          },
          {
            "$ref": "#/components/parameters/StatusFilter"
          },
          {
            "$ref": "#/components/parameters/EvidenceFilter"
          },
          {
            "$ref": "#/components/parameters/Sort"
          },
          {
            "$ref": "#/components/parameters/ExactProductFilter"
          },
          {
            "$ref": "#/components/parameters/Format"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated certificate evidence feed. Request text/csv or format=csv for a complete filtered CSV export.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              },
              "Link": {
                "description": "RFC 8288 next-page link when more records are available.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Record-Count": {
                "description": "Total filtered record count.",
                "schema": {
                  "type": "integer"
                }
              },
              "X-PB-Next-Cursor": {
                "description": "Opaque next-page cursor when more records are available.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecordList"
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid pagination cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Compound feed not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Pagination cursor belongs to an earlier dataset generation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "CSV export exceeds the 10,000-record limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/health": {
      "get": {
        "tags": [
          "Certificates"
        ],
        "operationId": "getEvidenceHealth",
        "summary": "Inspect the active evidence generation and rollback readiness",
        "responses": {
          "200": {
            "description": "Public, non-secret D1 projection health.",
            "headers": {
              "Cache-Control": {
                "description": "Health responses are never cached.",
                "schema": {
                  "const": "no-store"
                }
              },
              "X-PB-Data-Source": {
                "description": "Storage implementation serving the response.",
                "schema": {
                  "const": "cloudflare-d1"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/anomalies/facets": {
      "get": {
        "tags": [
          "Anomalies"
        ],
        "operationId": "getAnomalyFacets",
        "summary": "Per-rule anomaly counts under an active filter set",
        "description": "Returns the total and per-rule signal counts (with average confidence) for the grouped review queue under the requested filters. Used to render every group header with a live filtered count before paging each group.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "$ref": "#/components/parameters/AnomalyRuleFilter"
          },
          {
            "$ref": "#/components/parameters/VendorFilter"
          },
          {
            "$ref": "#/components/parameters/ConfidenceBandFilter"
          },
          {
            "$ref": "#/components/parameters/AnomalyStatusFilter"
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered per-rule anomaly facets.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnomalyFacets"
                }
              }
            }
          },
          "400": {
            "description": "Invalid filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/coas/anomalies": {
      "get": {
        "tags": [
          "Anomalies"
        ],
        "operationId": "listAnomalies",
        "summary": "Keyset page of one rule’s anomaly signals",
        "description": "Returns one rule’s anomaly signals in the compact review-queue wire shape (records dictionary, rule definitions, and compact anomaly objects), sorted by descending confidence then id for a stable keyset. rule is required.",
        "parameters": [
          {
            "$ref": "#/components/parameters/AnomalyRuleParam"
          },
          {
            "$ref": "#/components/parameters/Search"
          },
          {
            "$ref": "#/components/parameters/VendorFilter"
          },
          {
            "$ref": "#/components/parameters/ConfidenceBandFilter"
          },
          {
            "$ref": "#/components/parameters/AnomalyStatusFilter"
          },
          {
            "$ref": "#/components/parameters/AnomalyLimit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "One rule’s compact anomaly page.",
            "headers": {
              "ETag": {
                "description": "Representation validator for conditional requests.",
                "schema": {
                  "type": "string"
                }
              },
              "Last-Modified": {
                "description": "UTC generation time for the evidence source.",
                "schema": {
                  "type": "string"
                }
              },
              "X-PB-Cache": {
                "description": "Edge cache disposition.",
                "schema": {
                  "enum": [
                    "HIT",
                    "MISS"
                  ]
                }
              },
              "X-PB-Data-Source": {
                "description": "Public query plane serving this representation.",
                "schema": {
                  "enum": [
                    "cloudflare-d1"
                  ]
                }
              },
              "X-PB-Next-Cursor": {
                "description": "Opaque next-page cursor when more signals are available.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnomalyList"
                }
              }
            }
          },
          "400": {
            "description": "Missing rule, invalid filter, or invalid pagination cursor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Pagination cursor belongs to an earlier dataset generation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Per-client edge rate limit exceeded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Evidence source temporarily unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "RecordId": {
        "name": "record_id",
        "in": "path",
        "required": true,
        "description": "Stable 20-character content-derived certificate ID.",
        "schema": {
          "type": "string",
          "pattern": "^[a-f0-9]{20}$"
        }
      },
      "VendorSlug": {
        "name": "vendor_slug",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        }
      },
      "CompoundSlug": {
        "name": "compound_slug",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "pattern": "^[a-z0-9-]+$"
        }
      },
      "Search": {
        "name": "q",
        "in": "query",
        "description": "Case-insensitive text search across record, vendor, product, compound, lab, batch, and report fields.",
        "schema": {
          "type": "string",
          "maxLength": 200
        }
      },
      "VendorFilter": {
        "name": "vendor",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },
      "CompoundFilter": {
        "name": "compound",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },
      "LaboratoryFilter": {
        "name": "laboratory",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },
      "PanelFilter": {
        "name": "panel",
        "in": "query",
        "schema": {
          "type": "string"
        }
      },
      "StatusFilter": {
        "name": "status",
        "in": "query",
        "description": "Filter by document lifecycle state. Superseded citation-only aliases are excluded when this parameter is omitted.",
        "schema": {
          "type": "string",
          "enum": [
            "current",
            "retained",
            "disappeared",
            "superseded"
          ]
        }
      },
      "EvidenceFilter": {
        "name": "evidence",
        "in": "query",
        "description": "Filter by the available public evidence surface. Use superseded to retrieve stable citation aliases that default feeds omit.",
        "schema": {
          "type": "string",
          "enum": [
            "verified",
            "archived",
            "purity",
            "panels",
            "source-only",
            "disappeared",
            "superseded",
            "legacy"
          ]
        }
      },
      "Sort": {
        "name": "sort",
        "in": "query",
        "description": "Stable server-side result ordering.",
        "schema": {
          "type": "string",
          "enum": [
            "vendor",
            "product",
            "newest",
            "purity"
          ],
          "default": "vendor"
        }
      },
      "ExactProductFilter": {
        "name": "exact_product",
        "in": "query",
        "schema": {
          "type": "boolean"
        }
      },
      "Format": {
        "name": "format",
        "in": "query",
        "description": "Use csv for a complete filtered export rather than paginated JSON.",
        "schema": {
          "type": "string",
          "enum": [
            "json",
            "csv"
          ]
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 250,
          "default": 50
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "description": "Opaque, generation-bound keyset cursor returned in pagination.nextCursor, X-PB-Next-Cursor, or the Link header. Restart pagination after a 409 response.",
        "schema": {
          "type": "string"
        }
      },
      "AnomalyRuleParam": {
        "name": "rule",
        "in": "query",
        "required": true,
        "description": "Anomaly rule slug identifying the group to page.",
        "schema": {
          "type": "string"
        }
      },
      "AnomalyRuleFilter": {
        "name": "rule",
        "in": "query",
        "description": "Restrict facets to a single anomaly rule group.",
        "schema": {
          "type": "string"
        }
      },
      "ConfidenceBandFilter": {
        "name": "confidence",
        "in": "query",
        "description": "Filter by confidence band: high (≥0.85), medium (0.65–0.84), low (<0.65).",
        "schema": {
          "type": "string",
          "enum": [
            "high",
            "medium",
            "low"
          ]
        }
      },
      "AnomalyStatusFilter": {
        "name": "status",
        "in": "query",
        "description": "Filter by review disposition. Omit or leave blank for all states.",
        "schema": {
          "type": "string",
          "enum": [
            "unresolved",
            "reviewed",
            "confirmed",
            "dismissed"
          ]
        }
      },
      "AnomalyLimit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 250,
          "default": 8
        }
      }
    },
    "schemas": {
      "ProvenanceValue": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "value": {},
          "provenance": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "lab-verified",
              "document-extracted",
              "vendor-stated",
              "manual-review",
              null
            ]
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1
          }
        },
        "required": [
          "value",
          "provenance",
          "confidence"
        ]
      },
      "Panel": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "result": {},
          "provenance": {
            "type": [
              "string",
              "null"
            ]
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ],
            "minimum": 0,
            "maximum": 1
          }
        },
        "required": [
          "key",
          "result",
          "provenance",
          "confidence"
        ]
      },
      "ProviderHealth": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "state": {
            "type": [
              "string",
              "null"
            ]
          },
          "checkedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "httpStatus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "lastHealthyAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Verification": {
        "type": "object",
        "properties": {
          "providerSlug": {
            "type": [
              "string",
              "null"
            ]
          },
          "laboratory": {
            "type": [
              "string",
              "null"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "providerVerified": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "verified",
              "unresolved",
              "available"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "health": {
            "$ref": "#/components/schemas/ProviderHealth"
          }
        },
        "required": [
          "providerSlug",
          "laboratory",
          "url",
          "providerVerified",
          "status",
          "reason",
          "health"
        ]
      },
      "CertificateRecord": {
        "type": "object",
        "required": [
          "id",
          "permalink",
          "vendor",
          "product",
          "compound",
          "laboratory",
          "results",
          "identifiers",
          "dates",
          "document",
          "verification"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-f0-9]{20}$"
          },
          "permalink": {
            "type": "string",
            "format": "uri"
          },
          "vendor": {
            "type": "object",
            "required": [
              "slug",
              "name",
              "pbAffiliateRelationship",
              "disclosureUrl"
            ],
            "properties": {
              "slug": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "pbAffiliateRelationship": {
                "type": "boolean"
              },
              "disclosureUrl": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "product": {
            "type": "object",
            "required": [
              "slug",
              "name",
              "url",
              "exactMatch"
            ],
            "properties": {
              "slug": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "exactMatch": {
                "type": "boolean"
              }
            }
          },
          "compound": {
            "$ref": "#/components/schemas/ProvenanceValue"
          },
          "laboratory": {
            "$ref": "#/components/schemas/ProvenanceValue"
          },
          "results": {
            "type": "object",
            "required": [
              "purity",
              "labeledQuantity",
              "measuredQuantity",
              "panels"
            ],
            "properties": {
              "purity": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "puritySummaryType": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "purityMeasurements": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "labeledQuantity": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "measuredQuantity": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "measuredQuantitySummaryType": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "measuredQuantityMeasurements": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "vialsTested": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "panels": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Panel"
                }
              }
            }
          },
          "identifiers": {
            "type": "object",
            "properties": {
              "batch": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "report": {
                "$ref": "#/components/schemas/ProvenanceValue"
              }
            }
          },
          "dates": {
            "type": "object",
            "properties": {
              "testing": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "received": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "report": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "certificate": {
                "$ref": "#/components/schemas/ProvenanceValue"
              },
              "observed": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "disappeared": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "document": {
            "type": "object",
            "required": [
              "sourceUrl",
              "archiveUrl",
              "sha256",
              "status",
              "extractionStatus"
            ],
            "properties": {
              "type": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "sourceUrl": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "sourceHostname": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "archiveUrl": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri-reference"
              },
              "sha256": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[a-f0-9]{64}$"
              },
              "status": {
                "type": "string",
                "enum": [
                  "current",
                  "retained",
                  "disappeared",
                  "superseded"
                ]
              },
              "retentionReason": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Why a non-current citation record remains public. Optional for compatibility with older ready generations."
              },
              "sourceAliasOf": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri",
                "description": "Canonical source URL when this exact-byte source URL was superseded. Optional for compatibility with older ready generations."
              },
              "supersededByRecordId": {
                "type": [
                  "string",
                  "null"
                ],
                "pattern": "^[a-f0-9]{20}$",
                "description": "Canonical stable record ID for a superseded exact-byte alias. Optional for compatibility with older ready generations."
              },
              "attribution": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "extractionStatus": {
                "type": "string"
              },
              "artifactType": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "verification": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Verification"
            }
          }
        }
      },
      "Feed": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "vendor",
              "compound"
            ]
          },
          "slug": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "required": [
          "count",
          "total",
          "limit",
          "nextCursor"
        ],
        "properties": {
          "count": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RecordList": {
        "type": "object",
        "required": [
          "generatedAt",
          "schemaVersion",
          "feed",
          "policy",
          "pagination",
          "records"
        ],
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "schemaVersion": {
            "type": "integer"
          },
          "feed": {
            "$ref": "#/components/schemas/Feed"
          },
          "policy": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CertificateRecord"
            }
          }
        }
      },
      "RecordEnvelope": {
        "type": "object",
        "required": [
          "generatedAt",
          "schemaVersion",
          "record"
        ],
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "schemaVersion": {
            "type": "integer"
          },
          "record": {
            "$ref": "#/components/schemas/CertificateRecord"
          }
        }
      },
      "VendorEntry": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "recordCount": {
            "type": "integer"
          },
          "feed": {
            "type": "string"
          },
          "csv": {
            "type": "string"
          },
          "pbAffiliateRelationship": {
            "type": "boolean"
          },
          "disclosureUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "CompoundEntry": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "recordCount": {
            "type": "integer"
          },
          "feed": {
            "type": "string"
          },
          "csv": {
            "type": "string"
          }
        }
      },
      "VendorDirectory": {
        "type": "object",
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "schemaVersion": {
            "type": "integer"
          },
          "vendors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VendorEntry"
            }
          }
        }
      },
      "CompoundDirectory": {
        "type": "object",
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "schemaVersion": {
            "type": "integer"
          },
          "compounds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompoundEntry"
            }
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "dataSource",
          "checkedAt",
          "active",
          "rollback",
          "generations",
          "latestMigration"
        ],
        "properties": {
          "status": {
            "const": "ok"
          },
          "dataSource": {
            "const": "cloudflare-d1"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time"
          },
          "active": {
            "type": "object",
            "properties": {
              "generation": {
                "type": "string"
              },
              "generatedAt": {
                "type": "string",
                "format": "date-time"
              },
              "sourceSha256": {
                "type": "string"
              },
              "schemaVersion": {
                "type": "integer"
              },
              "ageSeconds": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "summary": {
                "type": "object"
              },
              "completedAt": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "rollback": {
            "type": "object",
            "properties": {
              "available": {
                "type": "boolean"
              },
              "generation": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "generations": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "latestMigration": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "AnomalyGroupFacet": {
        "type": "object",
        "required": [
          "rule",
          "title",
          "count",
          "avgConfidence"
        ],
        "properties": {
          "rule": {
            "type": "string"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "count": {
            "type": "integer"
          },
          "avgConfidence": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          }
        }
      },
      "AnomalyFacets": {
        "type": "object",
        "required": [
          "generatedAt",
          "total",
          "groups",
          "vendors"
        ],
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "total": {
            "type": "integer"
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnomalyGroupFacet"
            }
          },
          "vendors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "AnomalyRecordSummary": {
        "type": "object",
        "description": "Compact per-record label dictionary keyed by record id. v=vendor name, p=product name, s=vendor slug, l=laboratory (optional), c=compound (optional).",
        "required": [
          "v",
          "p",
          "s"
        ],
        "properties": {
          "v": {
            "type": [
              "string",
              "null"
            ]
          },
          "p": {
            "type": [
              "string",
              "null"
            ]
          },
          "s": {
            "type": [
              "string",
              "null"
            ]
          },
          "l": {
            "type": "string"
          },
          "c": {
            "type": "string"
          }
        }
      },
      "AnomalyRuleDefinition": {
        "type": "object",
        "required": [
          "t"
        ],
        "properties": {
          "t": {
            "type": [
              "string",
              "null"
            ]
          },
          "e": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "CompactAnomaly": {
        "type": "object",
        "description": "Compact wire anomaly. i=id, r=rule, s=severity, c=confidence, x=record ids, m=short-keyed metadata, t=review status (present only when not unresolved).",
        "required": [
          "i",
          "r",
          "s",
          "c",
          "x",
          "m"
        ],
        "properties": {
          "i": {
            "type": "string",
            "pattern": "^[a-f0-9]{20}$"
          },
          "r": {
            "type": "string"
          },
          "s": {
            "type": "string",
            "enum": [
              "high",
              "medium",
              "low"
            ]
          },
          "c": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "x": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "m": {
            "type": "object"
          },
          "t": {
            "type": "string",
            "enum": [
              "reviewed",
              "confirmed",
              "dismissed"
            ]
          }
        }
      },
      "AnomalyList": {
        "type": "object",
        "required": [
          "generatedAt",
          "records",
          "ruleDefinitions",
          "anomalies",
          "pagination"
        ],
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "records": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/AnomalyRecordSummary"
            }
          },
          "ruleDefinitions": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/AnomalyRuleDefinition"
            }
          },
          "anomalies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CompactAnomaly"
            }
          },
          "pagination": {
            "type": "object",
            "required": [
              "total",
              "nextCursor"
            ],
            "properties": {
              "total": {
                "type": "integer"
              },
              "nextCursor": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      }
    }
  }
}
