{
  "slug": "edi-856-specification",
  "title": "EDI 856 specification: segment structure, the HL hierarchy, and a worked ASN",
  "description": "What an Advance Ship Notice contains, how the HL loop encodes shipment structure, which segments are mandatory, and a complete valid example you can run.",
  "keywords": [
    "edi 856 specification",
    "856 asn format",
    "856 segments",
    "hl hierarchy 856",
    "advance ship notice structure",
    "bsn segment",
    "man gm sscc",
    "edi 856 example"
  ],
  "cause": [
    "An 856 announces a shipment before it arrives. Its spine is BSN — purpose code, shipment identifier, date, time, and a hierarchical structure code declaring which levels the document uses.",
    "Everything after that is the HL loop. X12 has no nesting, so the shipment tree is flattened: HL01 is this node's identifier, HL02 the identifier of its parent, HL03 the level type, and HL04 a flag saying whether children follow. Level codes are S shipment, O order, T tare or pallet, P pack or carton, I item.",
    "Common structures are S-O-P-I (shipment, order, carton, item) and S-O-T-P-I when pallets are identified. The retailer's implementation guide dictates which, and generic X12 validation will not tell you a required level is missing.",
    "Within the loops: PRF carries the purchase order number at order level, MAN with qualifier GM carries the SSCC-18 at pack level, LIN carries product identifiers and SN1 the quantity shipped at item level. CTT counts HL segments — not line items — and SE01 counts every segment from ST through SE inclusive."
  ],
  "example": {
    "label": "Generate a complete valid ASN and see the resulting hierarchy",
    "curl": "curl -sX POST https://fluentedi.com/v1/edi/build -H 'content-type: application/json'   -d '{\"document\":\"856\",\"data\":{\"shipment_id\":\"SHIP1001\",\"orders\":[{\"po_number\":\"4500123456\",\"packs\":[{\"sscc\":\"006141411234567890\",\"items\":[{\"upc\":\"012345678905\",\"quantity\":12}]}]}],\"parties\":[{\"role\":\"ST\",\"name\":\"ACME STORES\",\"id\":\"0042\"}]}}'",
    "output": "ST*856*0001~ BSN*00*SHIP1001*20260824*1200*0001~\nHL*1**S*1~ N1*ST*ACME STORES*92*0042~\nHL*2*1*O*1~ PRF*4500123456~\nHL*3*2*P*1~ MAN*GM*006141411234567890~\nHL*4*3*I~ LIN**UP*012345678905~ SN1**12*EA~\nCTT*4~ SE*10*0001~\n\n\"isa_length\": 106, \"isa_length_valid\": true, \"hl_count\": 4"
  },
  "fix": [
    "Assign HL identifiers during generation, never by hand. Every child must name the identifier its parent actually received.",
    "Confirm which levels your retailer requires before sending. Validate with require_levels set to that structure — a missing carton level is valid X12 and still a chargeback.",
    "CTT01 on an 856 counts HL segments. Counting line items there is a common and silent error.",
    "Check every SSCC-18 before it reaches both the label and the MAN segment, so the two cannot disagree."
  ],
  "tools": [
    "https://fluentedi.com/v1/edi/build",
    "https://fluentedi.com/v1/edi/validate",
    "https://fluentedi.com/v1/edi/parse",
    "https://fluentedi.com/v1/gs1/checkdigit"
  ]
}