> ## Documentation Index
> Fetch the complete documentation index at: https://stedi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Segment requirements in X12 EDI

When a segment is used in a transaction set, the X12 standard specifies two types of segment requirements: `Mandatory` and `Optional`.

* **Mandatory**: Segments marked as mandatory (`M`) must be present in the EDI transaction.
* **Optional**: Segments marked as optional (`O`) may be present in the EDI transaction.

For each transaction set, the X12 standard defines a base specification, which denotes the requirements of each segment. All segments marked as `M` (mandatory) in the base specification must be present in the EDI file sent between two trading partners. On the other hand, all segments marked as `O` (optional) in the base specification can either be optional or mandatory, depending on the implementation guide that you and your trading partner agree to.

The requirement of a segment is always defined in the context of the transaction set and the position it is used in. For example, a [REF](https://www.stedi.com/edi/x12-008010/segment/REF) segment might have different requirement parameters if it is used in an [850 Purchase Order](https://www.stedi.com/edi/x12-008010/850) vs. a [270 Eligibility, Coverage, or Benefit inquiry](https://www.stedi.com/edi/x12-008010/270). Furthermore, the same segment might be used multiple times in different places in the same transaction set. For example, a [DTM Date/Time Reference](https://www.stedi.com/edi/x12-008010/segment/DTM) segment could be optional in the `Heading` but mandatory in the `Detail`.

As with all things in X12 EDI, trading partners will create a specification to suit their business needs. For example, your trading partners may decide that some segments — even optional as per the standard — must be present in the data (i.e., are mandatory). On the other hand, according to the X12 standard, you cannot mark segments that are mandatory in the base X12 specification as optional in your guide. In practice, some businesses break the X12 standard and you’ll have to conform to their specification nonetheless.

Most X12 implementation guides used in the industry were built using a tool called SpecBuilder, which creates a standard PDF format. We will use SpecBuilder PDFs and their terminology to explain segment requirements below, but your trading partner might send these requirements in different formats (e.g. CSV, Word, custom PDF).

In these implementation guides, the segment requirements given by X12 are found in the requirement column (`Req` for short). The `Req` column will show which segments are mandatory (`M`) or optional (`O`). Trading partners that deviate from the base specification will often indicate which fields are optional or mandatory in a column called `Usage` or `Attributes`, and they typically use a different syntax, such as `Must use` (mandatory) and `Used` (optional).

<Image alt="Image of segment requirements" src="/edi/images/docs/x12/segments/segment-requirements/img1.jpg" width="1238px" height="865px" caption="" />

Additionally, the segment requirements are also usually found on the segment detail page near the description or header. In these areas, the requirements are also indicated as either mandatory or optional. For trading partner specific requirements, look for the `User Option` or `Usage` label and the `Must use` or `Used` syntax.

<Image alt="Image of segment requirements in segment detail" src="/edi/images/docs/x12/segments/segment-requirements/img4.jpg" width="1238px" height="545px" caption="" />

## X12 types

### Mandatory

Mandatory segments are marked with an `M` or `Mandatory` in most implementation guides. If a segment is defined as mandatory in a transaction set, then you cannot send X12 data without it. In most cases, transactions that are missing mandatory segments will either be stopped by the sender, or rejected by the recipient.

For example, the [BIG (Beginning Segment for Invoice)](https://www.stedi.com/edi/x12-008010/segment/BIG) segment used in all X12 [810 Invoices](https://www.stedi.com/edi/x12-008010/810) is mandatory. It contains vital invoice information, such as the invoice number and date. You cannot send an invoice without these values.

<Image alt="Image of mandatory BIG segment in 810" src="/edi/images/docs/x12/segments/segment-requirements/img3.jpg" width="1238px" height="865px" caption="" />

<Image alt="Image of mandatory BIG segment" src="/edi/images/docs/x12/segments/segment-requirements/img4.jpg" width="1238px" height="545px" caption="" />

### Optional

Optional segments are marked with an `O` or `Optional` in most implementation guides.

If a segment is marked as optional, it can be omitted in the data and the transaction would still be valid. Often, PDF specifications will explain when to use optional segments in a notes section.

For example, the [CUR (Currency)](https://www.stedi.com/edi/x12-008010/segment/CUR) segment used in X12 810 Invoices is optional. Trading partners might agree that the default currency is US Dollars and use `CUR` only when the invoice currency is different from US Dollars.

<Image alt="Image of optional CUR segment in 810" src="/edi/images/docs/x12/segments/segment-requirements/img5.jpg" width="1238px" height="865px" caption="" />

<Image alt="Image of optional CUR segment" src="/edi/images/docs/x12/segments/segment-requirements/img6.png" width="1238px" height="591px" caption="" />

If you want to see the segment requirements for a specific transaction set, see [EDI Reference](https://www.stedi.com/edi/x12/transaction-set).
