202 Secondary Mortgage Market Loan Delivery (004020)

This is the standard X12 004020 spec, with 13 loops and 72 segment positions, as OpenEDI JSON, an ediFabric C# template and an ediFabric Native model. To change it for a trading partner, customize it in the EDI Spec Builder.

Loading the spec…
The spec as an OpenAPI 3 schema with x-openedi-* extensions, for ediFabric Native, ediFabric Cloud and the EDI Spec Builder. Download OpenEDI (130 KB) Generate classes
The ediFabric .NET template, class TS202. It needs the common segments, composites and codes of X12 004020, one download for every transaction in the version. Download C# (2 KB) Common files (254 KB)
The intermediary model ediFabric Native loads with set_map. Download Native (100 KB)

Use the 202 spec in your code

ediFabric .NET

Add the C# template and its common files to your project, or reference the template NuGet package, and read 202 files into TS202 objects. See ediFabric .NET.

ediFabric Native

Map version 004020 to the Native model with set_map, then parse 202 files to JSON from Python, Java, C or C#. See Convert between EDI and JSON.

OpenEDI

Select Customize in Spec Builder to copy the spec under your own name, change it for your partner, and parse files against it in EdiNation, ediFabric Native or ediFabric Cloud. Read about OpenEDI.

Generate 202 classes in Python, Java, Node.js, Go, Rust or C

ediFabric Native returns each 202 as JSON, with the property names of the OpenEDI schema. To work with that JSON as typed objects, generate classes from the OpenEDI file in your language and deserialize the JSON into TS202. Serialize the objects back to JSON to build EDI with ediFabric Native. The classes keep the loops, segments, lengths and code lists, but not the EDI data formats, so validate files with ediFabric Native. Read more in Generate a class from OpenEDI.

Python: datamodel-code-generator. Node.js: openapi-typescript. Java, Go, Rust and C: OpenAPI Generator.

202 structure

Loops and segments of the standard 202, with their usage and maximum repeats.

IDNameUsageMax use
STTransaction Set HeaderOptional1
BGNBeginning SegmentMandatory1
TRNTraceOptional1
DTPDate or Time or PeriodOptional1
Loop N1NameOptional5
N1NameMandatory1
N2Additional Name InformationOptional1
N3Address InformationOptional2
N4Geographic LocationOptional1
REFReference IdentificationOptional3
PERAdministrative Communications ContactOptional2
Loop N9Reference IdentificationMandatory>1
N9Reference IdentificationMandatory1
Loop DEXDelivery Execution InformationMandatory>1
DEXDelivery Execution InformationMandatory1
REFReference IdentificationMandatory15
CN1Contract InformationOptional1
PCTPercent AmountsOptional10
INTInterestOptional10
AMTMonetary AmountOptional4
QTYQuantityOptional5
MPPMortgage Pool ProgramOptional1
DTPDate or Time or PeriodOptional10
IIIInformationOptional15
Loop ASMAmount and Settlement MethodOptional>1
ASMAmount and Settlement MethodMandatory1
N1NameOptional1
REFReference IdentificationOptional5
Loop NM1Individual or Organizational NameMandatory>1
NM1Individual or Organizational NameMandatory1
Loop LXAssigned NumberMandatory>1
LXAssigned NumberMandatory1
REFReference IdentificationOptional15
AMTMonetary AmountOptional20
DTPDate or Time or PeriodOptional5
YNQYes/No QuestionOptional10
QTYQuantityOptional5
N1NameOptional6
IIIInformationOptional50
LUCLoan UnderwritingOptional1
RLDDown Payment DataOptional50
INTInterestOptional6
PPDPayment Pattern DetailsOptional1
PWKPaperworkOptional2
BUYLoan BuydownOptional1
PEXProperty or Housing ExpenseOptional10
BEPBorrower Education ProgramOptional2
Loop IGIInsurer or Guarantor InformationOptional>1
IGIInsurer or Guarantor InformationMandatory1
REFReference IdentificationOptional1
PCTPercent AmountsOptional10
Loop NX1Property or Entity IdentificationOptional>1
NX1Property or Entity IdentificationMandatory1
NX2Location ID ComponentOptional15
REAReal Estate Property InformationOptional1
PDSProperty Description/Legal DescriptionOptional2
Loop LN1Loan Specific DataOptional5
LN1Loan Specific DataMandatory1
YNQYes/No QuestionOptional1
DTPDate or Time or PeriodOptional5
REFReference IdentificationOptional10
Loop CRCConditions IndicatorOptional>1
CRCConditions IndicatorMandatory1
IN1Individual IdentificationOptional1
IN2Individual Name Structure ComponentsOptional30
DMGDemographic InformationOptional1
QTYQuantityOptional10
N1NameOptional1
YNQYes/No QuestionOptional5
AINIncomeOptional10
AMTMonetary AmountOptional15
Loop SCMCredit Score ModelOptional>1
SCMCredit Score ModelMandatory1
SCSCredit ScoreOptional5
Loop PAMPeriod AmountOptional4
PAMPeriod AmountMandatory1
YNQYes/No QuestionMandatory1
REFReference IdentificationMandatory1
Loop UWIUnderwriting InformationOptional5
UWIUnderwriting InformationMandatory1
IIIInformationOptional10
REFReference IdentificationOptional1
MSGMessage TextOptional>1
CTTTransaction TotalsOptional1
SETransaction Set TrailerOptional1