304 Shipping Instructions (003040)

This is the standard X12 003040 spec, with 16 loops and 110 segment positions, as OpenEDI JSON, an ediFabric C# template and an ediFabric Native model. To change it for a trading partner, customize it in the EDI Spec Builder.

Loading the spec…
The spec as an OpenAPI 3 schema with x-openedi-* extensions, for ediFabric Native, ediFabric Cloud and the EDI Spec Builder. Download OpenEDI (135 KB) Generate classes
The ediFabric .NET template, class TS304. It needs the common segments, composites and codes of X12 003040, one download for every transaction in the version. Download C# (2 KB) Common files (185 KB)
The intermediary model ediFabric Native loads with set_map. Download Native (122 KB)

Use the 304 spec in your code

ediFabric .NET

Add the C# template and its common files to your project, or reference the template NuGet package, and read 304 files into TS304 objects. See ediFabric .NET.

ediFabric Native

Map version 003040 to the Native model with set_map, then parse 304 files to JSON from Python, Java, C or C#. See Convert between EDI and JSON.

OpenEDI

Select Customize in Spec Builder to copy the spec under your own name, change it for your partner, and parse files against it in EdiNation, ediFabric Native or ediFabric Cloud. Read about OpenEDI.

Generate 304 classes in Python, Java, Node.js, Go, Rust or C

ediFabric Native returns each 304 as JSON, with the property names of the OpenEDI schema. To work with that JSON as typed objects, generate classes from the OpenEDI file in your language and deserialize the JSON into TS304. Serialize the objects back to JSON to build EDI with ediFabric Native. The classes keep the loops, segments, lengths and code lists, but not the EDI data formats, so validate files with ediFabric Native. Read more in Generate a class from OpenEDI.

Python: datamodel-code-generator. Node.js: openapi-typescript. Java, Go, Rust and C: OpenAPI Generator.

304 structure

Loops and segments of the standard 304, with their usage and maximum repeats.

IDNameUsageMax use
STTransaction Set HeaderOptional1
B2Beginning Segment for Shipment Information TransactionMandatory1
B2ASet PurposeOptional1
Y6AuthenticationOptional2
G1Shipment Type InformationOptional1
G2Beyond RoutingOptional1
G3Compensation InformationOptional1
N9Reference NumberOptional100
V1Vessel IdentificationOptional2
V3Vessel ScheduleOptional1
M0Letter of Credit ReferenceOptional1
M1InsuranceOptional5
M2Sales/Delivery TermsOptional1
C2Bank IDOptional1
C3CurrencyOptional1
ITDTerms of Sale/Deferred Terms of SaleOptional1
DTMDate/Time ReferenceOptional20
Loop N1NameOptional100
N1NameMandatory1
N2Additional Name InformationOptional2
N3Address InformationOptional2
N4Geographic LocationOptional1
G61ContactOptional3
Loop R4PortOptional20
R4PortMandatory1
DTMDate/Time ReferenceOptional15
R2ARoute Information with PreferenceOptional25
R2R22Optional13
K1RemarksOptional12
L11Business InstructionsOptional99
H3Special Handling InstructionsOptional6
L5Description, Marks and NumbersOptional999
X1Export LicenseOptional1
X2Import LicenseOptional5
Loop C8Certifications and ClausesOptional20
C8Certifications and ClausesMandatory1
C8CCertifications Clauses ContinuationOptional5
SUPSupplementary InformationOptional10
Loop LXAssigned NumberOptional999
LXAssigned NumberMandatory1
Y2Container DetailsOptional10
Loop N7Equipment DetailsOptional999
N7Equipment DetailsMandatory1
QTYQuantityOptional1
L4MeasurementOptional1
N12Equipment EnvironmentOptional1
M7Seal NumbersOptional5
W09Equipment and TemperatureOptional1
LH6Hazardous CertificationOptional6
Loop L1Rate and ChargesOptional20
L1Rate and ChargesMandatory1
C3CurrencyOptional1
L7Tariff ReferenceOptional1
X1Export LicenseOptional1
X2Import LicenseOptional5
N9Reference NumberOptional3
Loop H1Hazardous MaterialOptional10
H1Hazardous MaterialMandatory1
H2Additional Hazardous Material DescriptionOptional10
Loop LH1Hazardous Identification InformationOptional100
LH1Hazardous Identification InformationMandatory1
LH2Hazardous Classification InformationOptional4
LH3Hazardous Material Shipping NameOptional10
LFHFreeform Hazardous Material InformationOptional20
LEPEPA Required DataOptional3
LH4Canadian Dangerous RequirementsOptional1
LHTTransborder Hazardous RequirementsOptional3
LHRHazardous Material Identifying Reference NumbersOptional5
PERAdministrative Communications ContactOptional5
L11Business InstructionsOptional100
K1RemarksOptional10
Loop L0Line Item - Quantity and WeightOptional120
L0Line Item - Quantity and WeightMandatory1
MEAMeasurementsOptional10
PO4Item Physical DetailsOptional1
QTYQuantityOptional5
L4MeasurementOptional1
LH6Hazardous CertificationOptional1
Loop PALPallet InformationOptional3
PALPallet InformationMandatory1
QTYQuantityOptional1
CTPPricing InformationOptional1
L5Description, Marks and NumbersOptional999
L12Alternate Lading DescriptionOptional20
N9Reference NumberOptional10
Loop L1Rate and ChargesOptional20
L1Rate and ChargesMandatory1
C3CurrencyOptional1
L7Tariff ReferenceOptional1
SACService, Promotion, Allowance, or Charge InformationOptional10
L9Charge DetailOptional10
X1Export LicenseOptional1
X2Import LicenseOptional5
Loop C8Certifications and ClausesOptional20
C8Certifications and ClausesMandatory1
C8CCertifications Clauses ContinuationOptional5
SUPSupplementary InformationOptional10
Loop H1Hazardous MaterialOptional10
H1Hazardous MaterialMandatory1
H2Additional Hazardous Material DescriptionOptional10
Loop LH1Hazardous Identification InformationOptional100
LH1Hazardous Identification InformationMandatory1
LH2Hazardous Classification InformationOptional4
LH3Hazardous Material Shipping NameOptional10
LFHFreeform Hazardous Material InformationOptional20
LEPEPA Required DataOptional3
LH4Canadian Dangerous RequirementsOptional1
LHTTransborder Hazardous RequirementsOptional3
LHRHazardous Material Identifying Reference NumbersOptional5
PERAdministrative Communications ContactOptional5
Loop L3Total Weight and ChargesOptional1
L3Total Weight and ChargesMandatory1
MEAMeasurementsOptional5
PWKPaperworkOptional50
SUPSupplementary InformationOptional25
Loop L1Rate and ChargesOptional20
L1Rate and ChargesMandatory1
C3CurrencyOptional1
TDSTotal Monetary Value SummaryOptional1
SACService, Promotion, Allowance, or Charge InformationOptional10
L9Charge DetailOptional10
ISSInvoice Shipment SummaryOptional5
V9Event DetailOptional10
K1RemarksOptional999
L11Business InstructionsOptional24
SETransaction Set TrailerOptional1