{
  "openapi": "3.1.0",
  "info": {
    "title": "ComplianceCN Market Access API",
    "version": "0.3.0",
    "description": "Free public beta API for bilingual cross-border product market-access readiness checks for seller agents. Live modules cover battery electronics, connected toys, cosmetics and food-contact goods with per-record and per-rule review status; verify primary sources before acting."
  },
  "servers": [
    {
      "url": "https://compliancecn.netlify.app"
    }
  ],
  "paths": {
    "/healthz": {
      "get": {
        "summary": "Service health",
        "responses": {
          "200": {
            "description": "Healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        },
        "operationId": "get_healthz"
      }
    },
    "/api/v1/meta": {
      "get": {
        "summary": "Dataset version and editorial methodology",
        "responses": {
          "200": {
            "description": "Dataset metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Metadata"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_meta"
      }
    },
    "/api/v1/changelog": {
      "get": {
        "summary": "Versioned dataset changelog: regulatory amendments, verification passes and corrections, with an RSS feed at /changelog.rss",
        "responses": {
          "200": {
            "description": "Changelog versions, newest first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "dataset_versions",
                    "versions"
                  ],
                  "properties": {
                    "dataset_versions": {
                      "type": "object"
                    },
                    "rss": {
                      "type": "string"
                    },
                    "versions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "version",
                          "published_at",
                          "changes"
                        ],
                        "properties": {
                          "version": {
                            "type": "string"
                          },
                          "published_at": {
                            "type": "string",
                            "format": "date"
                          },
                          "changes": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_changelog"
      }
    },
    "/api/v1/benchmark": {
      "get": {
        "summary": "20 hard cross-border compliance questions with cited answer keys, trap types, and deterministic scoring assertions",
        "responses": {
          "200": {
            "description": "Benchmark questions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "version",
                    "count",
                    "questions"
                  ],
                  "properties": {
                    "version": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "purpose_en": {
                      "type": "string"
                    },
                    "scoring": {
                      "type": "string"
                    },
                    "questions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "id",
                          "question_en",
                          "correct_answer_en",
                          "must_include",
                          "grounding"
                        ],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "trap_type": {
                            "type": "string"
                          },
                          "question_en": {
                            "type": "string"
                          },
                          "correct_answer_en": {
                            "type": "string"
                          },
                          "must_include": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "grounding": {
                            "type": "object"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_benchmark"
      }
    },
    "/api/v1/requirements": {
      "get": {
        "summary": "List compliance requirement records",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "toys",
                "battery-electronics",
                "cosmetics",
                "food-contact"
              ]
            }
          },
          {
            "name": "market",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "EU",
                "US",
                "UK",
                "AU"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching records",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequirementList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        },
        "operationId": "get_api_v1_requirements"
      }
    },
    "/api/v1/requirements/{id}": {
      "get": {
        "summary": "Fetch one compliance record",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Record",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequirementItem"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        },
        "operationId": "get_api_v1_requirements_id"
      }
    },
    "/api/v1/preflight": {
      "post": {
        "summary": "Stage 1: run the automated market-access preflight of a ComplianceCN Check",
        "description": "Stage 1 of the same ComplianceCN market-access check. Returns missing product facts, applicable evidence, gaps, next actions and a trust envelope. Run this before Stage 2 next-step pack. It never returns a compliance approval.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PreflightRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Market-access readiness preflight",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreflightResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "413": {
            "description": "Request body exceeds 32 KB"
          },
          "415": {
            "description": "Content-Type must be application/json"
          }
        },
        "operationId": "post_api_v1_preflight"
      }
    },
    "/api/v1/next-step-pack": {
      "post": {
        "summary": "Stage 2: generate the next-step pack for a ComplianceCN Check",
        "description": "Stage 2 of the same ComplianceCN market-access check. Run after Stage 1 preflight. Drafts supplier evidence requests, supplier questions, lab quote requests, marketplace response text, a document index, official/standardised form-field drafts and a human-review brief from the same product profile used for preflight. The pack is operational drafting only, not certification, legal advice, product approval, or marketplace approval.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NextStepPackRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated next-step draft pack",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NextStepPackResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "413": {
            "description": "Request body exceeds 32 KB"
          },
          "415": {
            "description": "Content-Type must be application/json"
          }
        },
        "operationId": "post_api_v1_next_step_pack"
      }
    },
    "/api/consultancy/next-step-pack": {
      "get": {
        "summary": "Describe the editable next-step pack endpoint",
        "responses": {
          "200": {
            "description": "Endpoint description",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        },
        "operationId": "get_api_consultancy_next_step_pack"
      },
      "post": {
        "summary": "Generate an editable market-access next-step evidence/form pack",
        "description": "Website/reviewer pack surface. Returns route, editable_fields, Chinese/English draft text, checklist and official_form_drafts. Can optionally create a human-review lead when request_human_review/store_for_human_review is true and contact consent is supplied.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "product_intake"
                ],
                "properties": {
                  "product_intake": {
                    "$ref": "#/components/schemas/PreflightRequest"
                  },
                  "preflight_result": {
                    "type": "object"
                  },
                  "human_review": {
                    "type": "object"
                  },
                  "request_human_review": {
                    "type": "boolean",
                    "default": false
                  },
                  "store_for_human_review": {
                    "type": "boolean",
                    "default": false
                  },
                  "client_email": {
                    "type": "string",
                    "format": "email"
                  },
                  "consent_to_contact": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Editable pack generated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EditableNextStepPackResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        },
        "operationId": "post_api_consultancy_next_step_pack"
      }
    },
    "/api/consultancy/leads": {
      "post": {
        "summary": "Continue a ComplianceCN market-access check into human review",
        "description": "Public agent-safe handoff from automated preflight to human review inside the same ComplianceCN market-access check process. Use only when the seller/user explicitly wants ComplianceCN to contact them about document evidence review. This creates a private lead, not a compliance approval, certification, or legal-advice request.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HumanReviewLeadRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted for human-review follow-up",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HumanReviewLeadResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "503": {
            "description": "Human review requests are not configured"
          }
        },
        "operationId": "post_api_consultancy_leads"
      }
    },
    "/api/v1/outcomes": {
      "get": {
        "summary": "List editorially reviewed compliance outcomes",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "toys",
                "battery-electronics",
                "cosmetics",
                "food-contact"
              ]
            }
          },
          {
            "name": "market",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "EU",
                "US",
                "UK",
                "AU"
              ]
            }
          },
          {
            "name": "checkpoint",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "marketplace_listing",
                "customs",
                "testing_lab",
                "local_representative",
                "regulator",
                "logistics"
              ]
            }
          },
          {
            "name": "result",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "accepted",
                "rejected",
                "conditional",
                "withdrawn"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published outcomes",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutcomeList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        },
        "operationId": "get_api_v1_outcomes"
      }
    },
    "/api/v1/outcomes/summary": {
      "get": {
        "summary": "Aggregate published outcomes",
        "responses": {
          "200": {
            "description": "Outcome aggregates",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutcomeSummary"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_outcomes_summary"
      }
    },
    "/api/v1/outcome-graph": {
      "get": {
        "summary": "Weighted compliance outcome graph",
        "responses": {
          "200": {
            "description": "Graph nodes and edges",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutcomeGraph"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_outcome_graph"
      }
    },
    "/api/v1/outcome-submissions": {
      "post": {
        "summary": "Submit an anonymous outcome for private editorial review",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OutcomeSubmission"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted for private review"
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "503": {
            "description": "Intake is disabled"
          }
        },
        "operationId": "post_api_v1_outcome_submissions"
      }
    },
    "/api/v1/timeline": {
      "get": {
        "summary": "Regulatory milestone timeline (EU Battery Regulation) with per-milestone verification status",
        "responses": {
          "200": {
            "description": "Milestones",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Timeline"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_timeline"
      }
    },
    "/api/v1/toys-timeline": {
      "get": {
        "summary": "Regulatory milestone timeline (EU Toy Safety Regulation 2025/2509) with per-milestone verification status",
        "responses": {
          "200": {
            "description": "Milestones",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Timeline"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_toys_timeline"
      }
    },
    "/api/v1/rules": {
      "get": {
        "summary": "Attribute-conditional decision rules with tri-state evaluation semantics (applies / not applicable / needs answer)",
        "responses": {
          "200": {
            "description": "Rules",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RuleList"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_rules"
      }
    },
    "/api/v1/categories": {
      "get": {
        "summary": "List categories",
        "responses": {
          "200": {
            "description": "Categories",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnumList"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_categories"
      }
    },
    "/api/v1/markets": {
      "get": {
        "summary": "List markets",
        "responses": {
          "200": {
            "description": "Markets",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnumList"
                }
              }
            }
          }
        },
        "operationId": "get_api_v1_markets"
      }
    }
  },
  "components": {
    "responses": {
      "BadRequest": {
        "description": "Invalid query parameter",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "Unknown resource",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Health": {
        "type": "object",
        "required": [
          "status",
          "dataset_version"
        ],
        "properties": {
          "status": {
            "const": "ok"
          },
          "dataset_version": {
            "type": "string"
          }
        }
      },
      "Metadata": {
        "type": "object",
        "required": [
          "dataset",
          "version",
          "schema_version",
          "published_at",
          "record_count",
          "methodology"
        ],
        "properties": {
          "dataset": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "schema_version": {
            "type": "string",
            "format": "date"
          },
          "published_at": {
            "type": "string",
            "format": "date"
          },
          "record_count": {
            "type": "integer"
          },
          "methodology": {
            "type": "object"
          },
          "preflight": {
            "type": "object"
          }
        }
      },
      "EnumItem": {
        "type": "object",
        "required": [
          "id",
          "count"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "EnumList": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnumItem"
            }
          }
        }
      },
      "Source": {
        "type": "object",
        "required": [
          "id",
          "title",
          "authority",
          "url",
          "source_type",
          "checked_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "authority": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "source_type": {
            "const": "primary"
          },
          "checked_at": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "Claim": {
        "type": "object",
        "required": [
          "id",
          "topic",
          "classification",
          "mandatory",
          "conditions",
          "evidence",
          "evidence_status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "topic": {
            "type": "string"
          },
          "text_en": {
            "type": [
              "string",
              "null"
            ]
          },
          "text_zh": {
            "type": [
              "string",
              "null"
            ]
          },
          "classification": {
            "type": "string",
            "enum": [
              "legal_summary",
              "legal_requirement",
              "compliance_measure",
              "platform_policy",
              "practical_guidance"
            ]
          },
          "mandatory": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "conditions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_status": {
            "type": "string",
            "enum": [
              "record_source_set",
              "editorial_source_needed"
            ]
          }
        }
      },
      "Provenance": {
        "type": "object",
        "required": [
          "schema_version",
          "review_status",
          "verified_at",
          "verified_by",
          "source_count",
          "sources"
        ],
        "properties": {
          "schema_version": {
            "type": "string"
          },
          "review_status": {
            "type": "string",
            "enum": [
              "source_checked",
              "partially_checked",
              "unverified_demo"
            ],
            "description": "Whether this record has actually been checked against its cited primary sources"
          },
          "review_note": {
            "type": [
              "string",
              "null"
            ],
            "description": "What was checked, when, and any gaps"
          },
          "verified_at": {
            "type": "string",
            "format": "date"
          },
          "verified_by": {
            "type": "string"
          },
          "source_count": {
            "type": "integer"
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Source"
            }
          }
        }
      },
      "Requirement": {
        "type": "object",
        "required": [
          "id",
          "category",
          "market",
          "risk_level",
          "review_status",
          "summary_en",
          "summary_zh",
          "jurisdiction_scope",
          "applicability",
          "legal_status",
          "provenance",
          "claims"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "toys",
              "battery-electronics",
              "cosmetics",
              "food-contact"
            ]
          },
          "market": {
            "type": "string",
            "enum": [
              "EU",
              "US",
              "UK",
              "AU"
            ]
          },
          "risk_level": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ]
          },
          "review_status": {
            "type": "string",
            "enum": [
              "source_checked",
              "partially_checked",
              "unverified_demo"
            ]
          },
          "summary_en": {
            "type": "string"
          },
          "summary_zh": {
            "type": "string"
          },
          "required_marks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "regulations": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "testing_certification": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "labelling": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "local_representative": {
            "type": "object"
          },
          "pitfalls_zh": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "last_verified": {
            "type": "string",
            "format": "date"
          },
          "jurisdiction_scope": {
            "type": "string"
          },
          "applicability": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "legal_status": {
            "type": "string",
            "enum": [
              "in_force",
              "transition"
            ]
          },
          "provenance": {
            "$ref": "#/components/schemas/Provenance"
          },
          "claims": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Claim"
            }
          }
        }
      },
      "RequirementList": {
        "type": "object",
        "required": [
          "dataset_version",
          "schema_version",
          "disclaimer_en",
          "disclaimer_zh",
          "count",
          "total_count",
          "limit",
          "offset",
          "records"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "schema_version": {
            "type": "string"
          },
          "disclaimer_en": {
            "type": "string"
          },
          "disclaimer_zh": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "total_count": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Requirement"
            }
          }
        }
      },
      "RequirementItem": {
        "type": "object",
        "required": [
          "dataset_version",
          "schema_version",
          "disclaimer_en",
          "disclaimer_zh",
          "record"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "schema_version": {
            "type": "string"
          },
          "disclaimer_en": {
            "type": "string"
          },
          "disclaimer_zh": {
            "type": "string"
          },
          "record": {
            "$ref": "#/components/schemas/Requirement"
          }
        }
      },
      "PreflightRequest": {
        "type": "object",
        "required": [
          "category",
          "markets"
        ],
        "properties": {
          "product_name": {
            "type": "string",
            "maxLength": 160
          },
          "category": {
            "type": "string",
            "enum": [
              "battery-electronics",
              "toys",
              "cosmetics",
              "food-contact"
            ]
          },
          "markets": {
            "type": "array",
            "minItems": 1,
            "maxItems": 4,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "EU",
                "US",
                "UK",
                "AU"
              ]
            }
          },
          "language": {
            "type": "string",
            "enum": [
              "zh",
              "en"
            ],
            "default": "zh"
          },
          "battery_type": {
            "type": "string",
            "enum": [
              "button_coin",
              "lithium_ion",
              "other",
              "none",
              "unknown"
            ]
          },
          "has_battery": {
            "type": "boolean"
          },
          "has_radio": {
            "type": "boolean"
          },
          "includes_mains_charger": {
            "type": "boolean"
          },
          "age_group": {
            "type": "string",
            "enum": [
              "under_3",
              "3_to_13",
              "14_plus",
              "unknown"
            ]
          },
          "accessible_small_parts": {
            "type": "boolean"
          },
          "battery_compartment_security": {
            "type": "string",
            "enum": [
              "tool_required",
              "two_independent_actions",
              "other_secured",
              "unsecured",
              "unknown"
            ]
          },
          "toy_chemical_assessment_complete": {
            "type": "boolean"
          },
          "eu_destination": {
            "type": "string",
            "enum": [
              "DE",
              "other_eu",
              "unknown"
            ]
          },
          "supply_chain_role": {
            "type": "string",
            "enum": [
              "manufacturer",
              "importer",
              "distributor",
              "marketplace_seller",
              "unknown"
            ]
          },
          "sales_channel": {
            "type": "string",
            "enum": [
              "amazon",
              "other_marketplace",
              "own_site",
              "unknown"
            ]
          },
          "sells_in_california": {
            "type": "boolean"
          },
          "evidence_held": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string"
            }
          },
          "evidence_inventory_complete": {
            "type": "boolean",
            "default": false
          },
          "verified_only": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "PreflightResponse": {
        "type": "object",
        "required": [
          "ok",
          "preflight_status",
          "decision",
          "evidence_summary",
          "evidence_checklist",
          "suggested_evidence_testing_route",
          "next_actions",
          "trust",
          "limitation"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "product_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": "string",
            "enum": [
              "battery-electronics",
              "toys",
              "cosmetics",
              "food-contact"
            ]
          },
          "markets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "preflight_status": {
            "type": "string",
            "enum": [
              "needs_product_information",
              "evidence_gaps_identified",
              "evidence_inventory_needed",
              "ready_for_expert_review"
            ]
          },
          "decision": {
            "const": "readiness_screening_only_not_a_compliance_approval"
          },
          "missing_product_information": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_summary": {
            "type": "object"
          },
          "evidence_checklist": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "suggested_evidence_testing_route": {
            "type": "object",
            "description": "Non-binding evidence/testing-route discussion suggestions generated from product facts and the evidence checklist. These are not additional legal requirements or compliance conclusions."
          },
          "next_actions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "trust": {
            "type": "object"
          },
          "assessment": {
            "type": "object"
          },
          "limitation": {
            "type": "string"
          }
        }
      },
      "NextStepPackRequest": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/PreflightRequest"
          },
          {
            "type": "object",
            "required": [
              "product_profile"
            ],
            "properties": {
              "product_profile": {
                "$ref": "#/components/schemas/PreflightRequest"
              },
              "preflight_result": {
                "type": "object",
                "description": "Optional caller-side preflight context; the server recomputes preflight before generating the pack."
              }
            }
          }
        ]
      },
      "NextStepPackResponse": {
        "type": "object",
        "required": [
          "ok",
          "pack_status",
          "decision",
          "post_review_route",
          "route_outputs",
          "pack",
          "human_review",
          "next_actions",
          "limitation"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "pack_status": {
            "const": "generated_draft_templates"
          },
          "decision": {
            "const": "next_step_templates_only_not_a_compliance_approval"
          },
          "post_review_route": {
            "type": "object",
            "required": [
              "id",
              "status",
              "status_en",
              "status_zh",
              "reasons"
            ],
            "properties": {
              "id": {
                "type": "string",
                "enum": [
                  "missing_supplier_evidence",
                  "lab_testing_route_needed",
                  "marketplace_submission_pack",
                  "specialist_referral_needed"
                ]
              },
              "status": {
                "type": "string"
              },
              "status_en": {
                "type": "string"
              },
              "status_zh": {
                "type": "string"
              },
              "reasons": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "product_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": "string",
            "enum": [
              "battery-electronics",
              "toys",
              "cosmetics",
              "food-contact"
            ]
          },
          "markets": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "preflight_status": {
            "type": "string"
          },
          "evidence_summary": {
            "type": "object"
          },
          "human_review": {
            "type": "object"
          },
          "route_outputs": {
            "type": "object",
            "description": "The four post-review routes: missing supplier evidence, lab/testing route, marketplace submission pack and specialist referral."
          },
          "pack": {
            "type": "object",
            "required": [
              "supplier_evidence_request",
              "supplier_questions",
              "lab_quote_request",
              "marketplace_response_draft",
              "document_index",
              "human_review_brief",
              "official_forms_and_templates",
              "official_form_drafts",
              "suggested_evidence_testing_route",
              "copy_ready_markdown"
            ],
            "properties": {
              "supplier_evidence_request": {
                "type": "object"
              },
              "supplier_evidence_request_zh": {
                "type": "object"
              },
              "supplier_evidence_request_en": {
                "type": "object"
              },
              "supplier_questions": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "lab_quote_request": {
                "type": "object"
              },
              "marketplace_response_draft": {
                "type": "object"
              },
              "document_index": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "human_review_brief": {
                "type": "object"
              },
              "official_forms_and_templates": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "official_form_drafts": {
                "type": "array",
                "description": "Prefillable official/standardised form or portal workflow field drafts, with missing required fields. Drafts only; not issued documents.",
                "items": {
                  "type": "object"
                }
              },
              "suggested_evidence_testing_route": {
                "type": "object"
              },
              "copy_ready_markdown": {
                "type": "string"
              }
            }
          },
          "next_actions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "trust": {
            "type": "object"
          },
          "preflight": {
            "type": "object"
          },
          "limitation": {
            "type": "string"
          }
        }
      },
      "EditableNextStepPackResponse": {
        "type": "object",
        "required": [
          "ok",
          "pack"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "pack": {
            "type": "object",
            "required": [
              "route",
              "title",
              "summary",
              "editable_fields",
              "checklist",
              "limitation"
            ],
            "properties": {
              "route": {
                "type": "string",
                "enum": [
                  "supplier_evidence_required",
                  "lab_route_needed",
                  "marketplace_submission_review",
                  "specialist_review_needed"
                ]
              },
              "title": {
                "type": "string"
              },
              "summary": {
                "type": "string"
              },
              "editable_fields": {
                "type": "object"
              },
              "chinese_text": {
                "type": "string"
              },
              "english_text": {
                "type": "string"
              },
              "checklist": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "official_form_drafts": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "limitation": {
                "type": "string"
              }
            }
          },
          "human_review": {
            "type": [
              "object",
              "null"
            ]
          }
        }
      },
      "HumanReviewLeadRequest": {
        "type": "object",
        "required": [
          "client_email",
          "consent_to_contact",
          "product_profile"
        ],
        "properties": {
          "client_email": {
            "type": "string",
            "format": "email",
            "description": "Seller contact email. Required because this creates a human follow-up lead."
          },
          "client_ref": {
            "type": "string",
            "maxLength": 160,
            "description": "Optional seller SKU, listing reference, or case reference."
          },
          "consent_to_contact": {
            "const": true,
            "description": "Must be true; agents should only send this after explicit user consent."
          },
          "source": {
            "type": "string",
            "maxLength": 120,
            "description": "Optional source label, e.g. agent_preflight_handoff."
          },
          "message": {
            "type": "string",
            "maxLength": 2000,
            "description": "Optional seller context for the reviewer."
          },
          "product_profile": {
            "$ref": "#/components/schemas/PreflightRequest"
          },
          "website": {
            "type": "string",
            "description": "Honeypot field; agents should omit it."
          }
        }
      },
      "HumanReviewLeadResponse": {
        "type": "object",
        "required": [
          "ok",
          "lead_id",
          "preflight_status",
          "evidence_summary",
          "review_gates",
          "next_step"
        ],
        "properties": {
          "ok": {
            "const": true
          },
          "lead_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "preflight_status": {
            "type": "string",
            "enum": [
              "needs_product_information",
              "evidence_gaps_identified",
              "evidence_inventory_needed",
              "ready_for_expert_review"
            ]
          },
          "evidence_summary": {
            "type": "object"
          },
          "review_gates": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "next_step": {
            "type": "string"
          }
        }
      },
      "Outcome": {
        "type": "object",
        "required": [
          "id",
          "requirement_id",
          "category",
          "market",
          "checkpoint",
          "event_type",
          "evidence_requested",
          "evidence_provided",
          "result",
          "occurred_on",
          "verification_level",
          "published_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "requirement_id": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "toys",
              "battery-electronics",
              "cosmetics",
              "food-contact"
            ]
          },
          "market": {
            "type": "string",
            "enum": [
              "EU",
              "US",
              "UK",
              "AU"
            ]
          },
          "checkpoint": {
            "type": "string",
            "enum": [
              "marketplace_listing",
              "customs",
              "testing_lab",
              "local_representative",
              "regulator",
              "logistics"
            ]
          },
          "event_type": {
            "type": "string"
          },
          "evidence_requested": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_provided": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "result": {
            "type": "string",
            "enum": [
              "accepted",
              "rejected",
              "conditional",
              "withdrawn"
            ]
          },
          "reason_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider_country": {
            "type": [
              "string",
              "null"
            ]
          },
          "cost": {
            "type": [
              "object",
              "null"
            ]
          },
          "lead_time_days": {
            "type": [
              "integer",
              "null"
            ]
          },
          "occurred_on": {
            "type": "string",
            "format": "date"
          },
          "verification_level": {
            "type": "string"
          },
          "evidence_fingerprint": {
            "type": [
              "string",
              "null"
            ]
          },
          "editorial_note_en": {
            "type": [
              "string",
              "null"
            ]
          },
          "editorial_note_zh": {
            "type": [
              "string",
              "null"
            ]
          },
          "published_at": {
            "type": "string",
            "format": "date"
          }
        }
      },
      "OutcomeList": {
        "type": "object",
        "required": [
          "dataset_version",
          "count",
          "total_count",
          "limit",
          "offset",
          "records"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "total_count": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "records": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Outcome"
            }
          }
        }
      },
      "OutcomeSummary": {
        "type": "object",
        "required": [
          "dataset_version",
          "summary"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "summary": {
            "type": "object"
          }
        }
      },
      "OutcomeGraph": {
        "type": "object",
        "required": [
          "dataset_version",
          "observation_count",
          "nodes",
          "edges"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "observation_count": {
            "type": "integer"
          },
          "nodes": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "edges": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "OutcomeSubmission": {
        "type": "object",
        "required": [
          "category",
          "market",
          "checkpoint",
          "event_type",
          "evidence_requested",
          "evidence_provided",
          "result",
          "occurred_on",
          "consent_to_anonymous_review"
        ],
        "properties": {
          "category": {
            "type": "string",
            "enum": [
              "toys",
              "battery-electronics",
              "cosmetics",
              "food-contact"
            ]
          },
          "market": {
            "type": "string",
            "enum": [
              "EU",
              "US",
              "UK",
              "AU"
            ]
          },
          "checkpoint": {
            "type": "string",
            "enum": [
              "marketplace_listing",
              "customs",
              "testing_lab",
              "local_representative",
              "regulator",
              "logistics"
            ]
          },
          "event_type": {
            "type": "string"
          },
          "evidence_requested": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "evidence_provided": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "result": {
            "type": "string",
            "enum": [
              "accepted",
              "rejected",
              "conditional",
              "withdrawn"
            ]
          },
          "occurred_on": {
            "type": "string",
            "format": "date"
          },
          "consent_to_anonymous_review": {
            "const": true
          }
        }
      },
      "Rule": {
        "type": "object",
        "required": [
          "id",
          "category",
          "markets",
          "when",
          "adds",
          "not_applicable",
          "sources",
          "review_status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "toys",
              "battery-electronics",
              "cosmetics",
              "food-contact"
            ]
          },
          "markets": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "EU",
                "US",
                "UK",
                "AU"
              ]
            }
          },
          "when": {
            "type": "object",
            "description": "ANDed profile conditions; a missing/unknown field makes the rule indeterminate, never silently applied"
          },
          "adds": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "not_applicable": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "review_status": {
            "type": "string",
            "enum": [
              "source_checked",
              "partially_checked",
              "unverified_demo"
            ]
          },
          "review_note": {
            "type": "string"
          }
        }
      },
      "RuleList": {
        "type": "object",
        "required": [
          "dataset_version",
          "semantics",
          "count",
          "rules"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "semantics": {
            "type": "string"
          },
          "disclaimer_en": {
            "type": "string"
          },
          "disclaimer_zh": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Rule"
            }
          }
        }
      },
      "Milestone": {
        "type": "object",
        "required": [
          "id",
          "date",
          "market",
          "article",
          "applies_to",
          "obligation_en",
          "obligation_zh",
          "review_status"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "format": "date"
          },
          "market": {
            "type": "string"
          },
          "article": {
            "type": "string"
          },
          "applies_to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "explicitly_excluded": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "obligation_en": {
            "type": "string"
          },
          "obligation_zh": {
            "type": "string"
          },
          "review_status": {
            "type": "string",
            "enum": [
              "source_checked",
              "partially_checked",
              "unverified_demo"
            ]
          },
          "review_note": {
            "type": "string"
          }
        }
      },
      "Timeline": {
        "type": "object",
        "required": [
          "dataset_version",
          "instrument",
          "count",
          "milestones"
        ],
        "properties": {
          "dataset_version": {
            "type": "string"
          },
          "instrument": {
            "type": "object"
          },
          "passport_scope_note_en": {
            "type": "string"
          },
          "passport_scope_note_zh": {
            "type": "string"
          },
          "disclaimer_en": {
            "type": "string"
          },
          "disclaimer_zh": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "milestones": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Milestone"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}