{
  "openapi": "3.1.0",
  "info": {
    "title": "EvidencePack REST twin",
    "version": "0.1.0",
    "description": "Same handlers and authorisation as MCP. Not OAuth. Method limitations are returned in results."
  },
  "servers": [
    {
      "url": "https://mcp.evidencepack.cfoth.ai"
    }
  ],
  "components": {
    "securitySchemes": {
      "TenantKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "EvidencePack API key"
      }
    }
  },
  "security": [
    {
      "TenantKey": []
    }
  ],
  "paths": {
    "/v1/tools/cbam.scope_check": {
      "post": {
        "operationId": "cbam_scope_check",
        "summary": "Screen an original CN8 against the bundled Annex I family map and destination/date coverage; never a complete legal determination.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cn_code": {
                    "type": "string",
                    "pattern": "^[0-9]{8}$",
                    "minLength": 8,
                    "maxLength": 8,
                    "description": "Original eight-digit EU CN code; never repaired or padded."
                  },
                  "destination": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "pattern": "^[\\p{L}\\p{M} ,. ’'()&-]+$",
                    "description": "Country name in English or ISO alpha-2; never a URL."
                  },
                  "import_date": {
                    "type": "string",
                    "format": "date",
                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
                  }
                },
                "required": [
                  "cn_code",
                  "destination",
                  "import_date"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/cbam.default_value": {
      "post": {
        "operationId": "cbam_default_value",
        "summary": "Look up EU compiled defaults and calculate the import-year mark-up with explicit country fallback, route ambiguity and provenance.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cn_code": {
                    "type": "string",
                    "pattern": "^[0-9]{8}$",
                    "minLength": 8,
                    "maxLength": 8,
                    "description": "Original eight-digit EU CN code; never repaired or padded."
                  },
                  "origin": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "pattern": "^[\\p{L}\\p{M} ,. ’'()&-]+$",
                    "description": "Country name in English or ISO alpha-2; never a URL."
                  },
                  "year": {
                    "type": "integer",
                    "minimum": 2026,
                    "maximum": 2100
                  }
                },
                "required": [
                  "cn_code",
                  "origin",
                  "year"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/cbam.field_checklist": {
      "post": {
        "operationId": "cbam_field_checklist",
        "summary": "Return all source fields for the full operator report (Annex IV 1.1) or importer summary (1.2); no completeness claim.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "report_type": {
                    "type": "string",
                    "enum": [
                      "full",
                      "summary"
                    ]
                  },
                  "installation_profile": {
                    "type": "object",
                    "properties": {
                      "plan_date": {
                        "type": "string",
                        "format": "date",
                        "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
                      },
                      "plan_version": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "installation_name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "installation_description": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 8000
                      },
                      "address": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 1000
                      },
                      "country": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80,
                        "pattern": "^[\\p{L}\\p{M} ,. ’'()&-]+$",
                        "description": "Country name in English or ISO alpha-2; never a URL."
                      },
                      "production_processes": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        },
                        "maxItems": 100
                      },
                      "goods": {
                        "type": "array",
                        "maxItems": 100,
                        "items": {
                          "type": "object",
                          "properties": {
                            "cn_code": {
                              "type": "string",
                              "pattern": "^[0-9]{8}$",
                              "minLength": 8,
                              "maxLength": 8,
                              "description": "Original eight-digit EU CN code; never repaired or padded."
                            },
                            "description": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1000
                            },
                            "functional_unit": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            },
                            "composition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1000
                            }
                          },
                          "required": [
                            "cn_code",
                            "functional_unit"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "element_notes": {
                        "type": "object",
                        "properties": {
                          "1": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "2": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "3": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "4": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "5": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "6": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "7": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "8": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "9": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "10": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "11": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "12": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "13": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "14": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "15": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "16": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "17": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "18": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "19": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "20": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "21": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "22": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          }
                        },
                        "required": [],
                        "additionalProperties": false,
                        "description": "Supplier text by Annex II A.5 element number (1–22). Not independently assessed."
                      }
                    },
                    "required": [],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "report_type"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/cbam.monitoring_plan_draft": {
      "post": {
        "operationId": "cbam_monitoring_plan_draft",
        "summary": "Create a 22-element monitoring-plan draft from supplied profile fields and notes only; retain all missing items for review.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "installation_profile": {
                    "type": "object",
                    "properties": {
                      "plan_date": {
                        "type": "string",
                        "format": "date",
                        "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
                      },
                      "plan_version": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80
                      },
                      "installation_name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 300
                      },
                      "installation_description": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 8000
                      },
                      "address": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 1000
                      },
                      "country": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80,
                        "pattern": "^[\\p{L}\\p{M} ,. ’'()&-]+$",
                        "description": "Country name in English or ISO alpha-2; never a URL."
                      },
                      "production_processes": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        },
                        "maxItems": 100
                      },
                      "goods": {
                        "type": "array",
                        "maxItems": 100,
                        "items": {
                          "type": "object",
                          "properties": {
                            "cn_code": {
                              "type": "string",
                              "pattern": "^[0-9]{8}$",
                              "minLength": 8,
                              "maxLength": 8,
                              "description": "Original eight-digit EU CN code; never repaired or padded."
                            },
                            "description": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1000
                            },
                            "functional_unit": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            },
                            "composition": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 1000
                            }
                          },
                          "required": [
                            "cn_code",
                            "functional_unit"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "element_notes": {
                        "type": "object",
                        "properties": {
                          "1": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "2": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "3": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "4": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "5": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "6": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "7": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "8": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "9": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "10": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "11": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "12": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "13": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "14": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "15": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "16": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "17": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "18": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "19": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "20": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "21": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          },
                          "22": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 8000
                          }
                        },
                        "required": [],
                        "additionalProperties": false,
                        "description": "Supplier text by Annex II A.5 element number (1–22). Not independently assessed."
                      }
                    },
                    "required": [],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "installation_profile"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/verifier.directory": {
      "post": {
        "operationId": "verifier_directory",
        "summary": "Read the dated third-party verifier directory. Country filters the accreditation body; sector is the exact Annex I Roman activity-group identifier.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "country": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "pattern": "^[\\p{L}\\p{M} ,. ’'()&-]+$",
                    "description": "Country name in English or ISO alpha-2; never a URL."
                  },
                  "sector": {
                    "type": "string",
                    "enum": [
                      "I",
                      "II",
                      "III",
                      "IV",
                      "V",
                      "VI",
                      "VII",
                      "VIII",
                      "L",
                      "LI",
                      "LII"
                    ]
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/news.latest": {
      "post": {
        "operationId": "news_latest",
        "summary": "Read newest published entries from the local editorial news snapshot; optional exact tag and inclusive ISO date filter, no live feed.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "tag": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "since": {
                    "type": "string",
                    "format": "date",
                    "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
                  }
                },
                "required": [],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/learn.glossary": {
      "post": {
        "operationId": "learn_glossary",
        "summary": "Find bilingual glossary terms, preferring an exact term then substring matches; return editorial rule references and snapshot provenance.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "term": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "term"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/cbam.calculate_see": {
      "post": {
        "operationId": "cbam_calculate_see",
        "summary": "Calculate bounded shared-app SEE for gas, electricity and precursors; lists unsupported-method gaps.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "installation_profile": {
                    "type": "object",
                    "properties": {
                      "quantity_t": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1000000000000000,
                        "exclusiveMinimum": 0
                      },
                      "cn_code": {
                        "type": "string",
                        "pattern": "^\\d{8}$"
                      },
                      "year": {
                        "type": "integer",
                        "minimum": 2026,
                        "maximum": 2100
                      },
                      "electricity_basis": {
                        "enum": [
                          "metered",
                          "allocated"
                        ]
                      },
                      "allocation_fraction": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                      },
                      "allow_demo_exempt_origin_zero": {
                        "type": "boolean"
                      }
                    },
                    "required": [
                      "quantity_t",
                      "cn_code",
                      "year"
                    ],
                    "additionalProperties": false
                  },
                  "source_streams": {
                    "type": "array",
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "properties": {
                        "kind": {
                          "enum": [
                            "natural_gas",
                            "electricity"
                          ]
                        },
                        "quantity": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000000000000
                        },
                        "unit": {
                          "enum": [
                            "Nm3",
                            "kWh"
                          ]
                        },
                        "emission_factor_kgCO2e_per_unit": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000000000000
                        },
                        "source_ref": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        }
                      },
                      "required": [
                        "kind",
                        "quantity",
                        "unit"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "precursors": {
                    "type": "array",
                    "maxItems": 100,
                    "items": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        },
                        "origin": {
                          "type": "string",
                          "minLength": 2,
                          "maxLength": 80
                        },
                        "quantity": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000000000000
                        },
                        "direct": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000000000000
                        },
                        "indirect": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000000000000
                        },
                        "actual": {
                          "enum": [
                            "yes",
                            "no"
                          ]
                        },
                        "defaultValue": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1000000000000000
                        },
                        "source_ref": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 2000
                        }
                      },
                      "required": [
                        "origin",
                        "quantity",
                        "actual"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "installation_profile",
                  "source_streams"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/cbam.compare_default_vs_actual": {
      "post": {
        "operationId": "cbam_compare_default_vs_actual",
        "summary": "Compare supplied actual SEE against a selected default row with the year mark-up; not a liability calculation.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "cn_code": {
                    "type": "string",
                    "pattern": "^\\d{8}$"
                  },
                  "origin": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "year": {
                    "type": "integer",
                    "minimum": 2026,
                    "maximum": 2100
                  },
                  "actual_direct_see": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1000000000000000
                  },
                  "actual_indirect_see": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1000000000000000
                  }
                },
                "required": [
                  "cn_code",
                  "origin",
                  "year",
                  "actual_direct_see",
                  "actual_indirect_see"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/evidence.ocr_thai_bill": {
      "post": {
        "operationId": "evidence_ocr_thai_bill",
        "summary": "Opt-in server-side CPU OCR of a Thai bill; suggestions and model confidence require human review.",
        "x-required-scope": "optin",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "image_base64": {
                    "type": "string",
                    "maxLength": 5592408
                  },
                  "opt_in": {
                    "const": true
                  }
                },
                "required": [
                  "image_base64",
                  "opt_in"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/evidence.import_records": {
      "post": {
        "operationId": "evidence_import_records",
        "summary": "Parse CSV/XLSX in memory with shared app unit checks, duplicate warnings and missing data gaps.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "csv_or_xlsx_base64": {
                    "type": "string",
                    "maxLength": 5592408
                  },
                  "format": {
                    "enum": [
                      "csv",
                      "xlsx"
                    ]
                  },
                  "mapping": {
                    "type": "object",
                    "maxProperties": 100,
                    "additionalProperties": {
                      "type": "string",
                      "maxLength": 100
                    }
                  }
                },
                "required": [
                  "csv_or_xlsx_base64",
                  "format"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/evidence.build_pack": {
      "post": {
        "operationId": "evidence_build_pack",
        "summary": "Generate PDF/XLSX/JSON, SHA-256 manifest and calendar receipt; requires write scope and explicit short retention consent.",
        "x-required-scope": "write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "payload": {
                    "type": "object",
                    "maxProperties": 100,
                    "additionalProperties": true
                  },
                  "request_id": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{32}$"
                  },
                  "retention_consent": {
                    "const": true
                  }
                },
                "required": [
                  "retention_consent"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/evidence.supplier_request_letter": {
      "post": {
        "operationId": "evidence_supplier_request_letter",
        "summary": "Draft a Thai or English missing-evidence request in TXT form; no message is sent.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "gap": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "language": {
                    "enum": [
                      "th",
                      "en"
                    ]
                  }
                },
                "required": [
                  "gap",
                  "language"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/trace.lookup": {
      "post": {
        "operationId": "trace_lookup",
        "summary": "Read tenant-authorised EPCIS events by lot or heat using the hosted TRACE read API.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lot_or_heat": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_-]{1,40}$"
                  }
                },
                "required": [
                  "lot_or_heat"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    },
    "/v1/tools/trace.verify_credential": {
      "post": {
        "operationId": "trace_verify_credential",
        "summary": "Check supported did:key eddsa-jcs-2022 signature integrity, not emissions truth or accreditation.",
        "x-required-scope": "read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "vc_json": {
                    "anyOf": [
                      {
                        "type": "object",
                        "additionalProperties": true
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "vc_json"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Source-linked result"
          },
          "400": {
            "description": "Invalid arguments"
          },
          "401": {
            "description": "Missing or invalid key"
          },
          "403": {
            "description": "Scope or consent denied"
          },
          "422": {
            "description": "Unsupported data/method"
          },
          "429": {
            "description": "Rate limit"
          },
          "503": {
            "description": "Dependency not configured"
          }
        }
      }
    }
  }
}