Purpose
The UNH (Message Header) segment is a mandatory service segment that opens every individual message within an EDIFACT interchange. It serves two critical functions: it assigns a unique reference number to the message, and it identifies the message type, version, release, and controlling agency. Without the UNH segment, a receiving system would have no way of knowing what kind of business document it is processing or how to parse the segments that follow.
Every UNH segment must be paired with a corresponding UNT (Message Trailer) segment that closes the message. Together, they form the message envelope, which sits inside the interchange envelope created by UNB and UNZ.
Data Elements
The UNH segment contains the following key data elements:
- 0062 - Message Reference Number: A unique reference assigned by the sender to identify this specific message within the interchange. This value must match the reference in the corresponding UNT segment.
- S009 - Message Identifier: A composite element containing:
- 0065 - Message Type: The six-character code identifying the message type (e.g., INVOIC, ORDERS, DESADV).
- 0052 - Message Version Number: The version of the message standard (e.g., D for Draft).
- 0054 - Message Release Number: The release within the version (e.g., 96A, 01B).
- 0051 - Controlling Agency: The organization responsible for the definition, typically UN.
- 0068 - Common Access Reference (conditional): Used to relate multiple messages that belong to the same business transaction.
Format and Syntax
The general format of a UNH segment is:
UNH+referenceNumber+messageType:versionNumber:releaseNumber:controllingAgency' The segment tag UNH is followed by data elements separated by the plus sign (+) element separator. Composite data elements use the colon (:) as a component separator. The segment terminates with the segment terminator, typically an apostrophe (').
Messages That Use UNH
The UNH segment is present in every UN/EDIFACT message without exception. It is always the first segment of any message, regardless of the message type. Common messages where you will encounter UNH include:
- INVOIC (Invoice)
- ORDERS (Purchase Order)
- DESADV (Despatch Advice)
- APERAK (Application Error and Acknowledgement)
- CONTRL (Syntax and Service Report)
- IFTMIN (Instruction for Transport)
Example
Below is a typical UNH segment from an INVOIC message using EDIFACT version D96A:
UNH+1+INVOIC:D:96A:UN' In this example, the message reference number is 1, the message type is INVOIC (Invoice), the version is D (Draft), the release is 96A, and the controlling agency is UN (United Nations).
A more complex example with a common access reference:
UNH+MSG00142+ORDERS:D:01B:UN+REF2024-001' Here the message reference is MSG00142, the message type is ORDERS using release D01B, and the common access reference REF2024-001 links it to related messages in the same business transaction.