The X12 Envelope: ISA, GS, and ST Explained
Every ANSI X12 file is built from nested envelopes that handle routing and control. Understanding this envelope is essential, because it is how you find where one document ends and another begins, who sent the file, and which document type you are looking at. The X12 envelope has three levels: ISA, GS, and ST.
The three levels, from outside in
- ISA / IEA - the interchange envelope, the outermost wrapper. One per transmission.
- GS / GE - the functional group, which bundles documents of the same type.
- ST / SE - the transaction set, which is one actual business document.
Each level has a header (ISA, GS, ST) and a matching trailer (IEA, GE, SE). They nest strictly: an interchange contains one or more groups, each group contains one or more transaction sets.
ISA: the interchange header
The ISA is unusual in X12 because it is fixed length - exactly 106 characters - with every field in a fixed position. This rigidity exists so a receiver can read the delimiters and key routing information before parsing anything else. Key ISA fields include:
- Sender and receiver IDs with their qualifiers, identifying the trading partners.
- Date and time of the interchange.
- Interchange control number, which the closing IEA must match.
- Usage indicator:
Pfor production orTfor test. This one character tells you whether the data is real.
Because the ISA is fixed width, errors in its length or padding are a common cause of parse failures. The delimiters themselves are read from specific ISA positions.
GS: the functional group
The GS groups transaction sets of the same functional type so they can be processed together. It carries a functional identifier code (for example PO for purchase orders, IN for invoices), the application sender and receiver, a date and time, a group control number, and the version of the standard being used (such as 004010 or 005010). That version governs how the documents inside should be interpreted.
ST: the transaction set
The ST is where an actual document begins. ST*850*0001 says this is an 850 purchase order with control number 0001. The transaction set type here is what tells you the document type - 850, 810, 856, 837, and so on. The closing SE repeats the control number and states how many segments the transaction contained, which lets the receiver verify nothing was lost or truncated.
How control numbers tie it together
Each level has a control number that its trailer must echo:
- ISA control number = IEA control number
- GS group control number = GE group control number
- ST control number = SE control number
These matched pairs are an integrity check. If a header and trailer disagree, the interchange is malformed. Control numbers also help detect duplicates and missing transmissions over time.
A skeleton example
ISA*00* *00* *ZZ*SENDER*ZZ*RECEIVER*240220*0900*U*00401*000000123*0*P*:~ GS*PO*SENDER*RECEIVER*20240220*0900*123*X*004010~ ST*850*0001~ ... transaction body ... SE*12*0001~ GE*1*123~ IEA*1*000000123~
Reading the envelope: a production interchange (P) from SENDER to RECEIVER, containing one functional group of purchase orders under version 004010, which holds one 850 transaction. The control numbers 000000123, 123, and 0001 match their trailers.
Why this matters when troubleshooting
- A file with multiple documents is split at the ST/SE boundaries; the envelope tells you where.
- The usage indicator (P or T) instantly tells you whether you are looking at real or test data.
- Mismatched control numbers point straight to a structural problem.
Paste an X12 file and EdiPeek lays out the ISA, GS, and ST envelope with every field labeled, plus a summary of sender, receiver, and document type. Nothing leaves your browser.
Open the X12 viewer