Skip to main content

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:

FieldTypeDescription
requiredFieldSpec[]Fields that must be filled. Generation is blocked if these are missing (pre-check errors).
recommendedFieldSpec[]Fields that should be filled. Generation proceeds but warns if these are missing (soft warnings).

Each FieldSpec has:

FieldTypeDescription
fieldPathstringDot-notation path matching the form field (camelCase, e.g., exporter.companyName)
dataPathstringDot-notation path in the shipment data (snake_case, e.g., exporter.name)
labelstringHuman-readable field label
tabstringWhich 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 TypeRequired FieldsRecommended Fields
COMMERCIAL_INVOICEExporter, importer, origin/destination, currency, total valuePorts, vessel
PACKING_LISTExporter, importer, total packagesWeights
BILL_OF_LADINGShipper, consignee, ports, vesselFreight payment, container/seal
AIR_WAYBILLShipper, consignee, airportsCarrier, agent, charge code
CERTIFICATE_OF_ORIGINExporter, consignee, origin country(none)
PROFORMA_INVOICEExporter, importer, currency(none)
INSURANCE_CERTIFICATE(none)Insurance company, policy, coverage, claims agent, deductible
SHIPPERS_LETTER_OF_INSTRUCTIONExporter/USPPI nameForwarding agent, EEI filing, freight, consignee type
VGM_DECLARATIONShipper, container numberWeighing method/station/date, authorised person, booking ref
DANGEROUS_GOODS_DECLARATIONEmergency contact (24h)Transport regulation, handling instructions
HEALTH_VETERINARY_CERTIFICATECompetent authority, establishment numberInspector, inspection date, attestation
PHYTOSANITARY_CERTIFICATEIssuing authorityPlace of origin, point of entry, treatment, inspector
CERTIFICATE_OF_ANALYSISBatch number, test standardProduct 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