Document Field Requirements API
Returns the required and recommended fields for each document type. Use this endpoint to validate client-side before calling generate-documents.
info
This endpoint does not require authentication. It returns static configuration data.
Get Field Requirements
GET /functions/v1/document-field-requirements
Example Request
curl "https://<project-ref>.supabase.co/functions/v1/document-field-requirements"
Response (200)
{
"requirements": {
"COMMERCIAL_INVOICE": {
"required": [
{
"fieldPath": "exporter.companyName",
"dataPath": "exporter.name",
"label": "Exporter name",
"tab": "parties"
},
{
"fieldPath": "importer.companyName",
"dataPath": "importer.name",
"label": "Importer name",
"tab": "parties"
}
],
"recommended": [
{
"fieldPath": "route.portOfLoading",
"dataPath": "route.port_of_loading",
"label": "Port of loading",
"tab": "route"
}
]
},
"BILL_OF_LADING": { "..." },
"..."
}
}
Response Structure
The response contains a requirements object keyed by document type. Each document type has:
| Field | Type | Description |
|---|---|---|
required | FieldSpec[] | Fields that must be filled. Generation is blocked if these are missing (pre-check errors). |
recommended | FieldSpec[] | Fields that should be filled. Generation proceeds but warns if these are missing (soft warnings). |
Each FieldSpec has:
| Field | Type | Description |
|---|---|---|
fieldPath | string | Dot-notation path matching the form field (camelCase, e.g., exporter.companyName) |
dataPath | string | Dot-notation path in the shipment data (snake_case, e.g., exporter.name) |
label | string | Human-readable field label |
tab | string | Which form tab the field is on (e.g., parties, route, goods, logistics) |
Supported Document Types (16)
The endpoint returns field requirements for all 16 document types:
| Document Type | Required Fields | Recommended Fields |
|---|---|---|
COMMERCIAL_INVOICE | Exporter, importer, origin/destination, currency, total value | Ports, vessel |
PACKING_LIST | Exporter, importer, total packages | Weights |
BILL_OF_LADING | Shipper, consignee, ports, vessel | Freight payment, container/seal |
AIR_WAYBILL | Shipper, consignee, airports | Carrier, agent, charge code |
CERTIFICATE_OF_ORIGIN | Exporter, consignee, origin country | (none) |
PROFORMA_INVOICE | Exporter, importer, currency | (none) |
INSURANCE_CERTIFICATE | (none) | Insurance company, policy, coverage, claims agent, deductible |
SHIPPERS_LETTER_OF_INSTRUCTION | Exporter/USPPI name | Forwarding agent, EEI filing, freight, consignee type |
VGM_DECLARATION | Shipper, container number | Weighing method/station/date, authorised person, booking ref |
DANGEROUS_GOODS_DECLARATION | Emergency contact (24h) | Transport regulation, handling instructions |
HEALTH_VETERINARY_CERTIFICATE | Competent authority, establishment number | Inspector, inspection date, attestation |
PHYTOSANITARY_CERTIFICATE | Issuing authority | Place of origin, point of entry, treatment, inspector |
CERTIFICATE_OF_ANALYSIS | Batch number, test standard | Product name, laboratory, overall result |
EUR1_MOVEMENT_CERTIFICATE | (none) | Agreement name |
USMCA_CERTIFICATE_OF_ORIGIN | (none) | Producer name, certifier type |
STATEMENT_ON_ORIGIN | (none) | Agreement name |