# X12 Writer Transaction Set Notes

Use these notes when choosing starter segments for structured JSON sent to `write_x12`. Trading partners often require additional segments beyond these basics.

## Envelope Fields

Every write request needs:

- `ISA`: interchange header values, including sender, receiver, date, time, control number, usage indicator, and component separator.
- `Groups[0].GS`: functional group values, including functional identifier, sender, receiver, date, time, control number, transaction type, and version.
- `Groups[0].Transactions[0].ST`: transaction set ID and transaction set control number.

## 850 Purchase Order

Starter business segments:

- `BEG`: purpose, purchase order type, purchase order number, and date.
- `N1Loop`: buyer, seller, ship-to, or bill-to parties when needed.
- `PO1Loop`: line item details.
- `CTTLoop` or `CTT`: transaction totals when needed.

Use `GS.CodeIdentifyingInformationType_1: "PO"` and `ST.TransactionSetIdentifierCode_01: "850"`.

## 810 Invoice

Starter business segments:

- `BIG`: invoice date and invoice number.
- `N1Loop`: party details.
- `IT1Loop`: invoice line details.
- `TDS`: invoice total.
- `CTT`: line count summary when needed.

Use `GS.CodeIdentifyingInformationType_1: "IN"` and `ST.TransactionSetIdentifierCode_01: "810"`.

## 856 Advance Ship Notice

Starter business segments:

- `BSN`: shipment notice identifiers and dates.
- HL loops: shipment, order, pack, and item hierarchy.
- TD segments: carrier and routing details.
- MAN segments: marks, tracking, or package identifiers.

Use `GS.CodeIdentifyingInformationType_1: "SH"` and `ST.TransactionSetIdentifierCode_01: "856"`.

## 997 Functional Acknowledgment

Starter business segments:

- `AK1`: acknowledged group.
- `AK2`: acknowledged transaction set when needed.
- `AK5`: transaction set acknowledgment status.
- `AK9`: group acknowledgment status.

Use `GS.CodeIdentifyingInformationType_1: "FA"` and `ST.TransactionSetIdentifierCode_01: "997"`.
