X12 856 Ship Notice/Manifest (ASN)

The 856 is the X12 ship notice/manifest, better known as the advance ship notice or ASN. Suppliers send it when goods ship so the buyer can plan receiving and match cartons to orders.

It is built from HL loops: shipment, then order, then tare (pallet) and pack (carton), then item. Carton labels are identified by their GS1 SSCC in MAN segments.

At a glance

Standard
X12
Version
004010
Functional group
SH (GS01)
Sent by
Supplier to buyer
Responses
997, 861
ediFabric .NET template
TS856 in EdiFabric.Templates.X12
OpenEDI definition
View 856 in the spec library

856 structure

The full X12 856 layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 7 loops and 58 segment positions, in file order. Loops are shaded and their segments indented; Max use is how many times a segment or loop may repeat.

Segment / loop Name Usage Max use
STTransaction Set HeaderMandatory1
BSNBeginning Segment for Ship NoticeMandatory1
DTMDate/Time ReferenceOptional10
HL loopHierarchical LevelMandatory200000
HLHierarchical LevelMandatory1
LINItem IdentificationOptional1
SN1Item Detail (Shipment)Optional1
SLNSubline Item DetailOptional1000
PRFPurchase Order ReferenceOptional1
PO4Item Physical DetailsOptional1
PIDProduct/Item DescriptionOptional200
MEAMeasurementsOptional40
PWKPaperworkOptional25
PKGMarking, Packaging, LoadingOptional25
TD1Carrier Details (Quantity and Weight)Optional20
TD5Carrier Details (Routing Sequence/Transit Time)Optional12
TD3Carrier Details (Equipment)Optional12
TD4Carrier Details (Special Handling, or Hazardous Materials, or Both)Optional5
TSDAssigned Identification, PositionOptional1
REFReference IdentificationOptional>1
PERAdministrative Communications ContactOptional3
LH1 loopHazardous Identification InformationOptional100
LH1Hazardous Identification InformationMandatory1
LH2Hazardous Classification InformationOptional4
LH3Hazardous Material Shipping NameOptional12
LFHFreeform Hazardous Material InformationOptional20
LEPEPA-Required DataOptional>1
LH4Canadian Dangerous RequirementsOptional1
LHTTransborder Hazardous RequirementsOptional3
LHRHazardous Material Identifying Reference NumbersOptional10
PERAdministrative Communications ContactOptional5
LHEEmpty Equipment Hazardous Material InformationOptional1
CLD loopLoad DetailOptional200
CLDLoad DetailMandatory1
REFReference IdentificationOptional200
DTPDate or Time or PeriodOptional1
MANMarks and NumbersOptional>1
DTMDate/Time ReferenceOptional10
FOBF.O.B. Related InstructionsOptional1
PALPallet InformationOptional1
N1 loopNameOptional200
N1NameMandatory1
N2Additional Name InformationOptional2
N3Address InformationOptional2
N4Geographic LocationOptional1
REFReference IdentificationOptional12
PERAdministrative Communications ContactOptional3
FOBF.O.B. Related InstructionsOptional1
SDQDestination QuantityOptional50
ETDExcess Transportation DetailOptional1
CURCurrencyOptional1
SAC loopService, Promotion, Allowance, or Charge InformationOptional>1
SACService, Promotion, Allowance, or Charge InformationMandatory1
CURCurrencyOptional1
GFFurnished Goods and ServicesOptional1
YNQYes/No QuestionOptional10
LM loopCode Source InformationOptional10
LMCode Source InformationMandatory1
LQIndustry CodeMandatory100
V1 loopVessel IdentificationOptional>1
V1Vessel IdentificationMandatory1
R4Port or TerminalOptional>1
DTMDate/Time ReferenceOptional>1
CTTTransaction TotalsOptional1
SETransaction Set TrailerMandatory1

Mandatory segments must be sent, Optional ones only when the data applies. Trading partners often add their own rules in companion guides - ediFabric templates can be adjusted to match. Open the element-level definition in the EdiNation spec library.

Sample 856 file

A ship notice with shipment, order, pack and item levels. Paste it into EdiNation to see every element named and validated.

ISA*00*          *00*          *16*SENDER1        *14*RECEIVER1      *071216*1406*U*00204*000000263*1*T*>~
GS*IN*SENDER1*RECEIVER1*20071216*1406*000000001*X*004010~
ST*856*0001~
BSN*00*01140824*20051015*1345*0001~
HL*1**S~
TD1*CTN25*2****G*45582*LB*1000*CF~
TD5*B*2*JBHT*M~
TD3*TL*ABCD*07213567******30394938483234~
REF*BM*01140824~
REF*CN*082131~
REF*CR*01082131~
DTM*011*200~
N1*ST*WAL-MART DC 6094J-JIT*UL*0078742035260~
N1*SF*SUPPLIER NAME~
HL*2*1*O~
PRF*9988776655***20051015~
REF*IA*211555050~
REF*DP*00005~
REF*MR*0073~
REF*IV*01140824~
N1*BY*WAL-MART STORES,INC.*UL*0078742000992~
HL*3*2*P~
MAN*GM*00000010012345614785~
HL*4*3*I~
LIN**UP*008815509183~
SN1**4*EA~
HL*5*3*I~
LIN**UP*008815547321~
SN1**9*EA~
HL*6*1*O~
PRF*2288115555***20051015~
REF*IA*211555050~
REF*DP*00005~
REF*MR*0073~
REF*IV*01140824~
N1*BY*WAL-MART STORES,INC.*UL*0078742000015~
HL*7*6*P~
MAN*GM*00000010012378945698~
HL*8*7*I~
LIN**UP*008815509183~
SN1**4*EA~
HL*9*7*I~
LIN**UP*008815547321~
SN1**9*EA~
CTT*9~
SE*44*0001~
GE*2*000000001~
IEA*1*000000263~

The same 856 as JSON

ediFabric turns every loop, segment and element into a named field. This is the transaction from the sample, in the JSON that ediFabric Native and Cloud return and accept.

{
  "ST": {
    "TransactionSetIdentifierCode_01": "856",
    "TransactionSetControlNumber_02": "0001"
  },
  "BSN": {
    "TransactionSetPurposeCode_01": "00",
    "ShipmentIdentification_02": "01140824",
    "Date_03": "20051015",
    "Time_04": "1345",
    "HierarchicalStructureCode_05": "0001"
  },
  "HLLoop": [
    {
      "HL": {
        "HierarchicalIDNumber_01": "1",
        "HierarchicalLevelCode_03": "S"
      },
      "TD1": [
        {
          "PackagingCode_01": "CTN25",
          "LadingQuantity_02": "2",
          "WeightQualifier_06": "G",
          "Weight_07": "45582",
          "UnitorBasisforMeasurementCode_08": "LB",
          "Volume_09": "1000",
          "UnitorBasisforMeasurementCode_10": "CF"
        }
      ],
      "TD5": [
        {
          "RoutingSequenceCode_01": "B",
          "IdentificationCodeQualifier_02": "2",
          "IdentificationCode_03": "JBHT",
          "TransportationMethodTypeCode_04": "M"
        }
      ],
      "TD3": [
        {
          "EquipmentDescriptionCode_01": "TL",
          "EquipmentInitial_02": "ABCD",
          "EquipmentNumber_03": "07213567",
          "SealNumber_09": "30394938483234"
        }
      ],
      "REF": [
        {
          "ReferenceIdentificationQualifier_01": "BM",
          "ReferenceIdentification_02": "01140824"
        },
        {
          "ReferenceIdentificationQualifier_01": "CN",
          "ReferenceIdentification_02": "082131"
        },
        {
          "ReferenceIdentificationQualifier_01": "CR",
          "ReferenceIdentification_02": "01082131"
        }
      ],
      "DTM": [
        {
          "DateTimeQualifier_01": "011",
          "Date_02": "200"
        }
      ],
      "N1Loop": [
        {
          "N1": {
            "EntityIdentifierCode_01": "ST",
            "Name_02": "WAL-MART DC 6094J-JIT",
            "IdentificationCodeQualifier_03": "UL",
            "IdentificationCode_04": "0078742035260"
          }
        },
        {
          "N1": {
            "EntityIdentifierCode_01": "SF",
            "Name_02": "SUPPLIER NAME"
          }
        }
      ]
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "2",
        "HierarchicalParentIDNumber_02": "1",
        "HierarchicalLevelCode_03": "O"
      },
      "PRF": {
        "PurchaseOrderNumber_01": "9988776655",
        "Date_04": "20051015"
      },
      "REF": [
        {
          "ReferenceIdentificationQualifier_01": "IA",
          "ReferenceIdentification_02": "211555050"
        },
        {
          "ReferenceIdentificationQualifier_01": "DP",
          "ReferenceIdentification_02": "00005"
        },
        {
          "ReferenceIdentificationQualifier_01": "MR",
          "ReferenceIdentification_02": "0073"
        },
        {
          "ReferenceIdentificationQualifier_01": "IV",
          "ReferenceIdentification_02": "01140824"
        }
      ],
      "N1Loop": [
        {
          "N1": {
            "EntityIdentifierCode_01": "BY",
            "Name_02": "WAL-MART STORES,INC.",
            "IdentificationCodeQualifier_03": "UL",
            "IdentificationCode_04": "0078742000992"
          }
        }
      ]
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "3",
        "HierarchicalParentIDNumber_02": "2",
        "HierarchicalLevelCode_03": "P"
      },
      "MAN": [
        {
          "MarksandNumbersQualifier_01": "GM",
          "MarksandNumbers_02": "00000010012345614785"
        }
      ]
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "4",
        "HierarchicalParentIDNumber_02": "3",
        "HierarchicalLevelCode_03": "I"
      },
      "LIN": {
        "ProductServiceIDQualifier_02": "UP",
        "ProductServiceID_03": "008815509183"
      },
      "SN1": {
        "NumberofUnitsShipped_02": "4",
        "UnitorBasisforMeasurementCode_03": "EA"
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "5",
        "HierarchicalParentIDNumber_02": "3",
        "HierarchicalLevelCode_03": "I"
      },
      "LIN": {
        "ProductServiceIDQualifier_02": "UP",
        "ProductServiceID_03": "008815547321"
      },
      "SN1": {
        "NumberofUnitsShipped_02": "9",
        "UnitorBasisforMeasurementCode_03": "EA"
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "6",
        "HierarchicalParentIDNumber_02": "1",
        "HierarchicalLevelCode_03": "O"
      },
      "PRF": {
        "PurchaseOrderNumber_01": "2288115555",
        "Date_04": "20051015"
      },
      "REF": [
        {
          "ReferenceIdentificationQualifier_01": "IA",
          "ReferenceIdentification_02": "211555050"
        },
        {
          "ReferenceIdentificationQualifier_01": "DP",
          "ReferenceIdentification_02": "00005"
        },
        {
          "ReferenceIdentificationQualifier_01": "MR",
          "ReferenceIdentification_02": "0073"
        },
        {
          "ReferenceIdentificationQualifier_01": "IV",
          "ReferenceIdentification_02": "01140824"
        }
      ],
      "N1Loop": [
        {
          "N1": {
            "EntityIdentifierCode_01": "BY",
            "Name_02": "WAL-MART STORES,INC.",
            "IdentificationCodeQualifier_03": "UL",
            "IdentificationCode_04": "0078742000015"
          }
        }
      ]
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "7",
        "HierarchicalParentIDNumber_02": "6",
        "HierarchicalLevelCode_03": "P"
      },
      "MAN": [
        {
          "MarksandNumbersQualifier_01": "GM",
          "MarksandNumbers_02": "00000010012378945698"
        }
      ]
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "8",
        "HierarchicalParentIDNumber_02": "7",
        "HierarchicalLevelCode_03": "I"
      },
      "LIN": {
        "ProductServiceIDQualifier_02": "UP",
        "ProductServiceID_03": "008815509183"
      },
      "SN1": {
        "NumberofUnitsShipped_02": "4",
        "UnitorBasisforMeasurementCode_03": "EA"
      }
    },
    {
      "HL": {
        "HierarchicalIDNumber_01": "9",
        "HierarchicalParentIDNumber_02": "7",
        "HierarchicalLevelCode_03": "I"
      },
      "LIN": {
        "ProductServiceIDQualifier_02": "UP",
        "ProductServiceID_03": "008815547321"
      },
      "SN1": {
        "NumberofUnitsShipped_02": "9",
        "UnitorBasisforMeasurementCode_03": "EA"
      }
    }
  ],
  "CTT": {
    "NumberofLineItems_01": "9"
  },
  "SE": {
    "NumberofIncludedSegments_01": "44",
    "TransactionSetControlNumber_02": "0001"
  }
}

Parse and validate an 856 file

Read the file into typed objects with ediFabric .NET, convert it to JSON in process with the ediFabric Native bindings for Python, Java and C, or post it to the ediFabric Cloud REST API from any language.

using EdiFabric.Templates.X12004010;

License.SetSerial("YOUR_SERIAL_KEY");

using (var stream = File.OpenRead(@"C:\edi\ShipNotice.txt"))
using (var reader = new X12Reader(stream, "EdiFabric.Templates.X12"))
{
    var items = await reader.ReadToEndAsync();
    foreach (var transaction in items.OfType<TS856>())
    {
        if (transaction.IsValid(out MessageErrorContext errors))
            Console.WriteLine($"{transaction.ST.TransactionSetControlNumber_02} is valid");
        else
            Console.WriteLine(string.Join(Environment.NewLine, errors.Flatten()));
    }
}
import json
import edifabric_x12 as ef

serial = "YOUR_SERIAL_KEY"
ef.load_library()
ef.set_serial(serial)
ef.set_map(json.dumps({"default": serial, "maps": {}}))

edi = open("ShipNotice.txt", "rb").read()
output, offset = ef.parse(edi, ef.ParseMode.JSON_VALIDATE)
transactions = output[:offset]
report = json.loads(output[offset:])
print(report["errors_count"])
import com.edifabric.nativex12.EdiFabricX12;
import com.edifabric.nativex12.ParseMode;
import com.edifabric.nativex12.ParseResult;

String serial = "YOUR_SERIAL_KEY";
EdiFabricX12.loadLibrary();
EdiFabricX12.setSerial(serial);
EdiFabricX12.setMap("{\"default\":\"" + serial + "\",\"maps\":{}}");

String edi = Files.readString(Path.of("ShipNotice.txt"));
ParseResult result = EdiFabricX12.parse(edi, ParseMode.JSON_VALIDATE);
System.out.println(result.getTransactions());
System.out.println(result.getReport());
#include "edifabric_x12.h"

const char *serial = "YOUR_SERIAL_KEY";
ef_parse_result result;

if (ef_load_library(NULL) != 0)
    return 1;
ef_set_serial(serial);
ef_set_map("{\"default\":\"YOUR_SERIAL_KEY\",\"maps\":{}}");

char *edi = read_file("ShipNotice.txt", NULL);   /* helper in example_all_functions.c */
if (ef_parse(edi, EF_PARSE_JSON_VALIDATE, NULL, &result) == 0) {
    /* transactions = output[0 .. offset), report = output[offset .. length) */
    fwrite(result.output.data, 1, (size_t)result.output.length, stdout);
    ef_free(result.output.data);
}
curl -X POST 'https://api.edination.com/v2/x12/read' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/octet-stream' \
--data-binary '@ShipNotice.txt'

Generate an 856 file

Populate a TS856 object in .NET, or pass JSON in the shape shown above to ediFabric Native or ediFabric Cloud, and get a valid 856 file back.

using EdiFabric.Templates.X12004010;

License.SetSerial("YOUR_SERIAL_KEY");

var transaction = new TS856();

//  856 is the Transaction Set Identifier Code for the Advance Ship Notice
//  0001 is the Transaction Set Control Number
transaction.ST = new ST();
transaction.ST.TransactionSetIdentifierCode_01 = "856";
transaction.ST.TransactionSetControlNumber_02 = "0001";

//  00 is the Transaction Set Purpose Code "00" indicates Original.
//  01140824 is the Shipment Identification Number.
//  20051015 is the Document Creation Date.
//  1345 is the Time.
//  0001 is the Hierarchical Structure. "0001" indicates "Pick and Pack Structure". 
transaction.BSN = new BSN();
transaction.BSN.TransactionSetPurposeCode_01 = "00";
transaction.BSN.ShipmentIdentification_02 = "01140824";
transaction.BSN.Date_03 = "20051015";
transaction.BSN.Time_04 = "1345";
transaction.BSN.HierarchicalStructureCode_05 = "0001";

//  Repeating HL Loops
transaction.HLLoop = new List<Loop_HL_856>();

// ... set the remaining loops and segments the same way

// SegmentBuilders is in the Common project of the example repository
using (var stream = new MemoryStream())
{
    using (var writer = new X12Writer(stream))
    {
        writer.Write(SegmentBuilders.BuildIsa("1"));
        writer.Write(SegmentBuilders.BuildGs("1"));
        writer.Write(transaction);
    }
    Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray()));
}
import json
import edifabric_x12 as ef

serial = "YOUR_SERIAL_KEY"
ef.load_library()
ef.set_serial(serial)
ef.set_map(json.dumps({"default": serial, "maps": {}}))

# the transactions JSON returned by ef.parse, edited or produced by your application
transactions = open("ShipNotice.json", "rb").read()
edi = ef.build(transactions, postfix="\r\n")
print(edi)
import com.edifabric.nativex12.EdiFabricX12;

String serial = "YOUR_SERIAL_KEY";
EdiFabricX12.loadLibrary();
EdiFabricX12.setSerial(serial);
EdiFabricX12.setMap("{\"default\":\"" + serial + "\",\"maps\":{}}");

// the transactions JSON returned by parse, edited or produced by your application
String transactions = Files.readString(Path.of("ShipNotice.json"));
String edi = EdiFabricX12.build(transactions, "\r\n");
System.out.println(edi);
#include "edifabric_x12.h"

ef_buffer edi;

if (ef_load_library(NULL) != 0)
    return 1;
ef_set_serial("YOUR_SERIAL_KEY");
ef_set_map("{\"default\":\"YOUR_SERIAL_KEY\",\"maps\":{}}");

/* the transactions JSON returned by ef_parse, edited or produced by your application */
char *transactions = read_file("ShipNotice.json", NULL);
if (ef_build(transactions, "\r\n", &edi) == 0) {
    fwrite(edi.data, 1, (size_t)edi.length, stdout);
    ef_free(edi.data);
}
# the JSON returned by /read, edited or produced by your application
curl -X POST 'https://api.edination.com/v2/x12/write' \
-H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \
-H 'Content-Type: application/json' \
--data-binary '@ShipNotice.json' \
-o 'ShipNotice.txt'

856 questions

What is the HL structure of an 856?

HL03 gives each level: S shipment, O order, T tare, P pack, I item. Retailers usually require either S-O-P-I (pick and pack) or S-O-T-P-I with pallets.

When should the 856 be sent?

After the goods leave and before they arrive. Most retailers require it within a set time of shipment and charge back late or inaccurate ASNs.

What is the EDIFACT equivalent?

DESADV, the despatch advice message.

How do I parse and generate X12 856 files in .NET, Python, Java and C?

In .NET, install EdiFabric and EdiFabric.Templates.X12, read the file with X12Reader into TS856 objects and write them back with X12Writer. From Python, Java or C, use ediFabric Native, which converts 856 files to JSON and JSON back to X12 inside your process. From any other language, post the file to the ediFabric Cloud REST API.

Parse your first 856 in five minutes

The Community plan is free forever and needs no credit card. It includes ediFabric .NET, Native and Cloud.