Every rule we run before generating a single document
Klervex applies deterministic validation to every shipment — schema constraints, mathematical consistency, tariff lookups against real customs databases, sanctions screening, and country-specific compliance — before producing a single PDF.
No probabilistic AI guessing. Every rule is rule-based and explainable. If validation fails, you get a specific error message and the exact field that failed.
10 categories of rules
Skip to a category below, or scroll for the full reference.
Required Fields
Mandatory fields per shipment and per requested document type. If any are missing, generation is blocked before customs sees an incomplete declaration.
Exporter identity required
Check: Exporter name, full address, and ISO 3166-1 alpha-2 country code must all be present
Why it matters: Customs cannot process a declaration without an identifiable shipper
Importer identity required
Check: Importer name, full address, and ISO 3166-1 alpha-2 country code must all be present
Why it matters: Customs cannot process a declaration without an identifiable consignee
At least one line item
Check: goods.line_items must contain one or more entries
Why it matters: A shipment with zero items is structurally invalid
Route fully declared
Check: Origin country, destination country, and transport mode (sea, air, road, rail, multimodal) must all be present
Why it matters: Mode-specific document rules cannot be applied otherwise
Currency declared
Check: Currency must be a valid ISO 4217 three-letter code (USD, EUR, GBP, etc.)
Why it matters: Customs valuation requires an unambiguous currency declaration
Mathematical Consistency
Cross-field math checks. These catch the silent errors that pass field-level validation but fail at the customs window.
Positive total value
Check: goods.total_value must be greater than zero
Why it matters: Prevents negative or zero declared value, which is rejected by customs
Positive line item quantities
Check: Every line_items[i].quantity must be greater than zero
Why it matters: Catches data entry errors and broken extraction
Positive unit prices
Check: Every line_items[i].unit_price must be greater than zero
Why it matters: Customs requires a positive declared unit value for duty calculation
Total reconciles with line items
Check: goods.total_value must equal sum(line_items, quantity × unit_price)
Why it matters: Top-level total mismatched with line items is the most common reason for customs holds
Gross weight ≥ net weight per item
Check: For each line item with both weights declared, gross must be greater than or equal to net
Why it matters: Net heavier than gross indicates a data error and triggers physical inspection
HS Code Validation
Every line item HS code is checked against the destination country's actual tariff schedule. Klervex maintains synced lookup tables for US HTS, EU TARIC, UK Trade Tariff, and India Customs Tariff.
HS code format
Check: Must be a valid 6-10 digit Harmonized System code
Why it matters: Customs systems reject malformed codes outright
HS code exists in destination tariff
Check: Code must exist in the destination country's tariff schedule (US HTS, EU TARIC, UK, IN)
Why it matters: AI extraction can hallucinate plausible-looking codes that do not exist in the actual schedule
HS code length matches destination
Check: US imports: 10 digits. EU: 10 digits. UK: 10 digits. India: 8 digits
Why it matters: Each jurisdiction has its own tariff structure; using the wrong granularity causes immediate rejection
Country of origin declared per line item
Check: Each line item must have a valid origin_country (ISO 3166-1 alpha-2)
Why it matters: Required for duty rate determination and preferential trade claims
Party & Sanctions Screening
Every party named on a shipment is screened against the OFAC Specially Designated Nationals (SDN) list. Sanctioned parties block document generation.
Exporter not on OFAC SDN list
Check: Exporter name and address are checked against the active OFAC SDN database
Why it matters: Doing business with sanctioned parties is a federal violation
Importer not on OFAC SDN list
Check: Importer name and address are checked against the active OFAC SDN database
Why it matters: Same as above; the consignee is equally exposed
Notify party not on OFAC SDN list
Check: Optional notify party (if present) is screened
Why it matters: Sanctioned third parties can also trigger violations
Origin and destination not embargoed
Check: Neither country may be a comprehensively sanctioned jurisdiction
Why it matters: Some countries are off-limits regardless of party identity
Route & Transport
Route validation ensures the declared journey is physically possible and that the transport mode is consistent with the documents being generated.
Port of loading is a valid UN/LOCODE
Check: Port code must exist in the UN/LOCODE database
Why it matters: Invalid port codes are flagged by customs and shipping line systems
Port of discharge is a valid UN/LOCODE
Check: Port code must exist in the UN/LOCODE database
Why it matters: Same as above
Port country matches declared country
Check: Port code's country prefix must match the declared country (e.g., USLAX for US ports)
Why it matters: Catches typos and AI extraction errors
Exporter country matches route origin
Check: exporter.country must equal route.origin_country
Why it matters: Mismatch indicates a routing error or extraction failure
Importer country matches route destination
Check: importer.country must equal route.destination_country
Why it matters: Same as above
Incoterms 2020
Incoterms must be a valid 2020 code and compatible with the declared transport mode. Sea-only terms cannot be used with air freight.
Valid Incoterms 2020 code
Check: Must be one of: EXW, FCA, CPT, CIP, DAP, DPU, DDP, FAS, FOB, CFR, CIF
Why it matters: Older 2010 codes (DAT, DAF, DES, DEQ, DDU) are no longer recognized
Sea-only terms with sea transport
Check: FAS, FOB, CFR, CIF can only be used with sea or inland waterway transport
Why it matters: These terms reference vessel rails and ship loading; using them for air or road is incorrect
Multimodal terms with multimodal transport
Check: EXW, FCA, CPT, CIP, DAP, DPU, DDP work with any mode
Why it matters: These are mode-agnostic and safe defaults for mixed transport
Country-Specific Compliance
Country-specific rules that apply based on the origin or destination jurisdiction. New rules are added as regulations change.
US imports — HTS 10-digit code
Check: Destination US requires full 10-digit HTSUS code per line item
Why it matters: CBP requires the full statistical reporting number, not just the 6-digit HS heading
EU imports — EORI required
Check: Destination EU requires importer to have a valid EORI number
Why it matters: Without an EORI, customs clearance cannot proceed
UK imports — GB-prefixed EORI
Check: Destination UK requires a GB-prefixed EORI (post-Brexit)
Why it matters: EU EORIs no longer work for UK imports
India imports — IEC required
Check: Destination India requires importer to have a valid Importer-Exporter Code (IEC)
Why it matters: DGFT mandates IEC for any import or export
India imports — GSTIN format check
Check: If a GSTIN is provided, it must match the 15-character GST format
Why it matters: Catches typos before they reach Indian customs
Document-Specific Rules
Per-document rules that apply only when the relevant document type is being generated.
Bill of Lading — sea transport only
Check: B/L generation requires route.transport_mode = sea or multimodal with a sea leg
Why it matters: A bill of lading is a sea/inland waterway document; it does not apply to air
Air Waybill — air transport only
Check: AWB generation requires route.transport_mode = air
Why it matters: AWBs are governed by IATA rules and apply only to air freight
Certificate of Origin — origin per line item
Check: Each line item must have a declared country_of_origin
Why it matters: The certificate certifies origin per item, not per shipment
Dangerous Goods Declaration — UN classification required
Check: Hazardous line items must have UN number, hazard class, and packing group
Why it matters: IMDG, IATA-DGR, and ADR all require this classification
VGM Declaration — sea container required
Check: VGM only applies when route.transport_mode = sea and packaging.containers is present
Why it matters: SOLAS VGM requirements only apply to ocean containers
EUR.1 Movement Certificate — preferential origin claim
Check: Requires preferential_origin.agreement_name to be set
Why it matters: EUR.1 is only valid when claiming preference under a specific FTA
USMCA Certificate — North American parties
Check: Requires at least one party in US, Mexico, or Canada
Why it matters: USMCA only applies to trade between the three signatory countries
Compliance Document Pre-Checks
When you select compliance documents for generation, Klervex verifies that all required data is present before sending anything to the renderer. These checks run per document type.
DGD: Emergency contact required
Check: hazardous_shipment.emergency_contact must be non-empty
Why it matters: IMO IMDG Code requires a 24-hour emergency contact on every Dangerous Goods Declaration
CHEMTREC +1-800-424-9300
DGD: UN classification per item
Check: Each hazardous line item must have un_number and hazard_class
Why it matters: A DGD without UN classification is legally invalid and will be rejected by the carrier
Health/Vet: Competent authority
Check: veterinary_data.competent_authority must be non-empty
Why it matters: The importing country requires the name of the issuing government authority
Food Standards Agency (FSA)
Health/Vet: Establishment number
Check: veterinary_data.establishment_number must be non-empty
Why it matters: The approved establishment number links to the registered production facility
UK-EW-12345
Phytosanitary: Issuing authority
Check: phytosanitary_data.issuing_authority must be non-empty
Why it matters: IPPC model requires the national plant protection organisation name
USDA APHIS
CoA: Batch number
Check: analysis_data.batch_number must be non-empty
Why it matters: A Certificate of Analysis without a batch/lot reference cannot be traced to a production run
CoA: Test standard
Check: analysis_data.test_standard must be non-empty
Why it matters: The test standard defines which specification the results were measured against
USP 44-NF 39, ISO 9001
EUR.1: Destination must be EU FTA partner
Check: route.destination_country must be in the EU FTA partner country list
Why it matters: EUR.1 certificates are only valid under preferential trade agreements with EU member states and FTA partners
USMCA: Destination must be US, Canada, or Mexico
Check: route.destination_country must be US, CA, or MX
Why it matters: The USMCA agreement only covers trade between the three North American countries
Smart Document Filtering
Klervex automatically determines which documents are available based on your shipment data. Documents that don't apply are greyed out with a clear reason.
Hazardous goods → DGD
Check: DGD is only available when at least one line item has the dgd compliance flag
Why it matters: Generating a DGD for non-hazardous goods produces an invalid document. MSDS documents are provided by the manufacturer, not generated by Klervex.
Animal products → Health/Vet Certificate
Check: Health/Veterinary Certificate is only available when at least one line item has the vet_cert compliance flag
Why it matters: Vet certificates are required for animal products entering most countries
Plant products → Phytosanitary Certificate
Check: Phytosanitary Certificate is only available when at least one line item has the phyto_cert compliance flag
Why it matters: IPPC phytosanitary certificates are required for plants, plant products, and regulated articles
HS code auto-suggest
Check: When you enter an HS code, Klervex auto-suggests compliance flags based on the tariff chapter (01-05 → vet, 06-14 → phyto, 28-38 → chemical, 30 → pharma)
Why it matters: Reduces manual tagging errors — you can always override the suggestion
EUR.1 / Statement on Origin routing
Check: EUR.1 and Statement on Origin are only available when the destination country is an EU FTA partner
Why it matters: No point generating a preferential origin certificate for a country that doesn't have an FTA with the EU
USMCA routing
Check: USMCA Certificate of Origin is only available when the destination is US, CA, or MX
Why it matters: The agreement only covers North American trade
Where the rule data comes from
Klervex doesn't make up its tariff data. Every lookup table is sourced from an official customs authority and refreshed on a published schedule:
US HTS
Sourced from the US International Trade Commission (USITC) Harmonized Tariff Schedule
EU TARIC
Sourced from the European Commission Directorate-General for Taxation and Customs Union
UK Trade Tariff
Sourced from HMRC's UK Trade Tariff service
India Customs
Sourced from the Central Board of Indirect Taxes and Customs (CBIC)
UN/LOCODE
Sourced from UNECE United Nations Code for Trade and Transport Locations
OFAC SDN
Sourced from the US Treasury Office of Foreign Assets Control Specially Designated Nationals list
Try it on a real shipment
Free tier includes 5 shipments per month. Upload a commercial invoice and see exactly which rules pass, which fail, and what to fix.
Powered by the Rynko platform — deterministic validation, hash-attested document generation, and an audit trail for every run.