857 Shipment and Billing Notice (005020)

This is the standard X12 005020 spec, with 16 loops and 67 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 TS857. It needs the common segments, composites and codes of X12 005020, one download for every transaction in the version. Download C# (1 KB) Common files (267 KB)
The intermediary model ediFabric Native loads with set_map. Download Native (109 KB)

Use the 857 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 857 files into TS857 objects. See ediFabric .NET.

ediFabric Native

Map version 005020 to the Native model with set_map, then parse 857 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 857 classes in Python, Java, Node.js, Go, Rust or C

ediFabric Native returns each 857 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 TS857. 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.

For a sample file, the same data as JSON, and code to parse, validate and generate the 857, see the 857 transaction guide.

857 structure

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

IDNameUsageMax use
STTransaction Set HeaderOptional1
BHTBeginning of Hierarchical TransactionMandatory1
Loop HLHierarchical LevelMandatory>1
HLHierarchical LevelMandatory1
Loop G05Total Shipment InformationOptional1
G05Total Shipment InformationMandatory1
TD1Carrier Details (Quantity and Weight)Optional5
TD3Carrier Details (Equipment)Optional5
TD4Carrier Details (Special Handling, or Hazardous Materials, or Both)Optional5
TD5Carrier Details (Routing Sequence/Transit Time)Optional10
FOBF.O.B. Related InstructionsOptional1
DTMDate/Time ReferenceOptional5
N9Extended Reference InformationOptional20
PERAdministrative Communications ContactOptional5
CURCurrencyOptional1
Loop N1Party IdentificationOptional10
N1Party IdentificationMandatory1
N2Additional Name InformationOptional2
N3Party LocationOptional2
N4Geographic LocationOptional1
Loop LMCode Source InformationOptional>1
LMCode Source InformationMandatory1
LQIndustry Code IdentificationMandatory>1
Loop TDSTotal Monetary Value SummaryOptional1
TDSTotal Monetary Value SummaryMandatory1
PRFPurchase Order ReferenceOptional1
N9Extended Reference InformationOptional>1
DTMDate/Time ReferenceOptional10
ITDTerms of Sale/Deferred Terms of SaleOptional5
TXITax InformationOptional10
SN1Item Detail (Shipment)Optional1
ISSInvoice Shipment SummaryOptional1
Loop SACService, Promotion, Allowance, or Charge InformationOptional25
SACService, Promotion, Allowance, or Charge InformationMandatory1
TXITax InformationOptional10
Loop N1Party IdentificationOptional10
N1Party IdentificationMandatory1
N2Additional Name InformationOptional2
N3Party LocationOptional2
N4Geographic LocationOptional1
Loop FA1Type of Financial Accounting DataOptional>1
FA1Type of Financial Accounting DataMandatory1
FA2Accounting DataMandatory>1
Loop PALPallet Type and Load CharacteristicsOptional1
PALPallet Type and Load CharacteristicsMandatory1
SN1Item Detail (Shipment)Optional1
MANMarks and Numbers InformationOptional10
Loop LXTransaction Set Line NumberOptional1
LXTransaction Set Line NumberMandatory1
N9Extended Reference InformationOptional15
SN1Item Detail (Shipment)Optional1
PO4Item Physical DetailsOptional1
MEAMeasurementsOptional10
PKGMarking, Packaging, LoadingOptional10
MANMarks and Numbers InformationOptional10
Loop IT1Baseline Item Data (Invoice)Optional1
IT1Baseline Item Data (Invoice)Mandatory1
IT3Additional Item DataOptional1
PO4Item Physical DetailsOptional1
TD4Carrier Details (Special Handling, or Hazardous Materials, or Both)Optional>1
TC2CommodityOptional5
TXITax InformationOptional10
CTPPricing InformationOptional10
N9Extended Reference InformationOptional10
MEAMeasurementsOptional10
DTMDate/Time ReferenceOptional10
ITDTerms of Sale/Deferred Terms of SaleOptional>1
Loop PIDProduct/Item DescriptionOptional25
PIDProduct/Item DescriptionMandatory1
MEAMeasurementsOptional10
Loop SLNSubline Item DetailOptional1000
SLNSubline Item DetailMandatory1
PIDProduct/Item DescriptionOptional25
Loop SACService, Promotion, Allowance, or Charge InformationOptional25
SACService, Promotion, Allowance, or Charge InformationMandatory1
TXITax InformationOptional10
Loop LMCode Source InformationOptional>1
LMCode Source InformationMandatory1
LQIndustry Code IdentificationMandatory>1
Loop FA1Type of Financial Accounting DataOptional>1
FA1Type of Financial Accounting DataMandatory1
FA2Accounting DataMandatory>1
SETransaction Set TrailerOptional1