CUSCAR is the UN/EDIFACT customs cargo report. Carriers and their agents use it to report cargo manifests to customs before arrival or departure. This sample follows the US CBP ACE implementation of D03B.
The message identifies the conveyance and voyage, the ports, and each consignment with its bill of lading, parties, goods description, packages and equipment.
D03B (US CBP ACE)TSCUSCAR in EdiFabric.Templates.EdifactThe full EDIFACT CUSCAR layout from its OpenEDI definition, the same model ediFabric uses to parse, validate and generate it: 18 loops and 75 segment positions, in file order. Loops are shaded and their segments indented; Max use is how many times a segment or loop may repeat.
| Segment / loop | Name | Usage | Max use |
|---|---|---|---|
UNH | Message header | Mandatory | 1 |
BGM | Beginning of message | Optional | 1 |
DTM | Date/time/period | Optional | >1 |
LOC | Place/location identification | Optional | >1 |
QTY | Quantity | Optional | >1 |
| RFF loop | Reference | Optional | >1 |
RFF | Reference | Optional | 1 |
DTM | Date/time/period | Optional | >1 |
| NAD loop | Name and address | Optional | >1 |
NAD | Name and address | Optional | 1 |
DTM | Date/time/period | Optional | 1 |
| CTA loop | Contact information | Optional | >1 |
CTA | Contact information | Optional | 1 |
COM | Communication contact | Optional | >1 |
FTX | Free text | Optional | >1 |
| TDT loop | Details of transport | Optional | >1 |
TDT | Details of transport | Optional | 1 |
LOC | Place/location identification | Optional | >1 |
DTM | Date/time/period | Optional | >1 |
GEI | Processing information | Optional | >1 |
| EQD loop | Equipment details | Optional | >1 |
EQD | Equipment details | Optional | 1 |
TSR | Transport service requirements | Optional | >1 |
MEA | Measurements | Optional | >1 |
DIM | Dimensions | Optional | >1 |
SEL | Seal number | Optional | >1 |
NAD | Name and address | Optional | >1 |
GEI | Processing information | Optional | >1 |
LOC | Place/location identification | Optional | 1 |
| TMP loop | Temperature | Optional | >1 |
TMP | Temperature | Optional | 1 |
RNG | Range details | Optional | 1 |
| RFF loop | Reference | Optional | >1 |
RFF | Reference | Optional | 1 |
LOC | Place/location identification | Optional | >1 |
CNT | Control total | Optional | >1 |
| CNI loop | Consignment information | Optional | >1 |
CNI | Consignment information | Optional | 1 |
CNT | Control total | Optional | >1 |
DOC | Document/message details | Optional | >1 |
| RFF loop | Reference | Optional | >1 |
RFF | Reference | Optional | 1 |
CNT | Control total | Optional | >1 |
MOA | Monetary amount | Optional | >1 |
LOC | Place/location identification | Optional | >1 |
GEI | Processing information | Optional | >1 |
CUX | Currencies | Optional | >1 |
CPI | Charge payment instructions | Optional | >1 |
| TDT loop | Details of transport | Optional | >1 |
TDT | Details of transport | Optional | 1 |
LOC | Place/location identification | Optional | >1 |
DTM | Date/time/period | Optional | >1 |
MEA | Measurements | Optional | >1 |
| RFF loop | Reference | Optional | >1 |
RFF | Reference | Optional | 1 |
TSR | Transport service requirements | Optional | >1 |
| NAD loop | Name and address | Optional | >1 |
NAD | Name and address | Optional | 1 |
DTM | Date/time/period | Optional | >1 |
RFF | Reference | Optional | >1 |
| CTA loop | Contact information | Optional | >1 |
CTA | Contact information | Optional | 1 |
COM | Communication contact | Optional | >1 |
| QTY loop | Quantity | Optional | >1 |
QTY | Quantity | Optional | 1 |
FTX | Free text | Optional | >1 |
| GID loop | Goods item details | Optional | >1 |
GID | Goods item details | Optional | 1 |
PAC | Package | Optional | >1 |
HAN | Handling instructions | Optional | >1 |
FTX | Free text | Optional | >1 |
MEA | Measurements | Optional | >1 |
MOA | Monetary amount | Optional | >1 |
SGP | Split goods placement | Optional | >1 |
DGS | Dangerous goods | Optional | >1 |
PCI | Package identification | Optional | >1 |
CST | Customs status of goods | Optional | 1 |
LOC | Place/location identification | Optional | >1 |
TMD | Transport movement details | Optional | >1 |
| GEI loop | Processing information | Optional | >1 |
GEI | Processing information | Optional | 1 |
DTM | Date/time/period | Optional | >1 |
DOC | Document/message details | Optional | >1 |
PAC | Package | Optional | >1 |
MEA | Measurements | Optional | >1 |
| QTY loop | Quantity | Optional | >1 |
QTY | Quantity | Optional | 1 |
FTX | Free text | Optional | 1 |
| AUT loop | Authentication result | Optional | 1 |
AUT | Authentication result | Optional | 1 |
DTM | Date/time/period | Optional | >1 |
RFF | Reference | Optional | >1 |
UNT | Message trailer | Mandatory | 1 |
Mandatory segments must be sent, Optional ones only when the data applies. Trading partners often add their own rules in companion guides - ediFabric templates can be adjusted to match. Open the element-level definition in the EdiNation spec library.
A cargo report for a vessel voyage with consignments and equipment. Paste it into EdiNation to see every element named and validated.
UNB+UNOA:4+LOCK:ZZ+CBP-ACE-TEST:ZZ+20041016:1604+54++ACE' UNG+CUSCAR+LOCK:ZZ+CBP-ACE-TEST:ZZ+20041016:1604+54+UN+D:03B' UNH+CUSCAR54+CUSCAR:D:03B:UN' BGM+85:::STANDARD+LOCKKH04112206+22' DTM+132:200412301200:203' LOC+60+0901:77'RFF+ABO:ABO04100000' NAD+CA+LOCK:172+++11107 SUNSET HILLS ROAD:77705 ARLINGTON ROAD+RESTON+VA:163+20190' NAD+VW+0000041047:109++AADLER:KEN' FTX+INS++INSURANCE INFOR+NAMESTATE FARM INSURANCE COMPANY:PLCYQO123456789:AMNT100000:YEAR2004' TDT+11++03+:::BT++I++:109::10000324' EQD+BI+10000325:109' SEL+SEALEQUNO001' RFF+ABZ:EQU123' LOC+89+VA:163' CNI+3741+:23' DOC+714:::61+KH041122106::LOCK' RFF+AAM:LOCKKH041122106' CNT+58:158' LOC+9+U0107:78' GEI+7+135' TDT+11' DTM+133:20041230:102' RFF+AWM' TSR+9' NAD+CN+65424:109+1234 MAIN STREET+KATHY SMITH++BELTSVILLE+MD:163+20708+US' CTA+IC' COM+8005551212:TE' NAD+IM+00010:109+1234 MAIN STREET+KATHY SMITH++BELTSVILLE+MD:163+20708+US' CTA+IC' COM+8005551212:TE' NAD+OS+27190:109+1234 MAIN STREET+KATHY SMITH++BELTSVILLE+MD:163+20708+US' CTA+IC' COM+8005551212:TE' GID+1' PAC+158++COL' FTX+AAA+++IRON COIL:SHEET METAL' MEA+AAI++K:750' SGP+10000325:109' UNT+38+CUSCAR54' UNE+1+54' UNZ+1+54'
ediFabric turns every loop, segment and element into a named field. This is the transaction from the sample, in the JSON that ediFabric Native and Cloud return and accept.
{
"UNH": {
"MessageReferenceNumber_01": "CUSCAR54",
"MessageIdentifier_02": {
"MessageType_01": "CUSCAR",
"MessageVersionNumber_02": "D",
"MessageReleaseNumber_03": "03B",
"ControllingAgencyCoded_04": "UN"
}
},
"BGM": {
"DOCUMENTMESSAGENAME_01": {
"Documentnamecode_01": "85",
"Documentname_04": "STANDARD"
},
"DOCUMENTMESSAGEIDENTIFICATION_02": {
"Documentidentifier_01": "LOCKKH04112206"
},
"Messagefunctioncode_03": "22"
},
"DTM": [
{
"DATETIMEPERIOD_01": {
"Dateortimeorperiodfunctioncodequalifier_01": "132",
"Dateortimeorperiodtext_02": "200412301200",
"Dateortimeorperiodformatcode_03": "203"
}
}
],
"LOC": [
{
"Locationfunctioncodequalifier_01": "60",
"LOCATIONIDENTIFICATION_02": {
"Locationnamecode_01": "0901",
"Codelistidentificationcode_02": "77"
}
}
],
"RFFLoop": [
{
"RFF": {
"REFERENCE_01": {
"Referencecodequalifier_01": "ABO",
"Referenceidentifier_02": "ABO04100000"
}
}
}
],
"NADLoop": [
{
"NAD": {
"Partyfunctioncodequalifier_01": "CA",
"PARTYIDENTIFICATIONDETAILS_02": {
"Partyidentifier_01": "LOCK",
"Codelistidentificationcode_02": "172"
},
"STREET_05": {
"Streetandnumberorpostofficeboxidentifier_01": "11107 SUNSET HILLS ROAD",
"Streetandnumberorpostofficeboxidentifier_02": "77705 ARLINGTON ROAD"
},
"Cityname_06": "RESTON",
"COUNTRYSUBENTITYDETAILS_07": {
"Countrysubentitynamecode_01": "VA",
"Codelistidentificationcode_02": "163"
},
"Postalidentificationcode_08": "20190"
}
},
{
"NAD": {
"Partyfunctioncodequalifier_01": "VW",
"PARTYIDENTIFICATIONDETAILS_02": {
"Partyidentifier_01": "0000041047",
"Codelistidentificationcode_02": "109"
},
"PARTYNAME_04": {
"Partyname_01": "AADLER",
"Partyname_02": "KEN"
}
}
}
],
"FTX": [
{
"Textsubjectcodequalifier_01": "INS",
"TEXTREFERENCE_03": {
"Freetextdescriptioncode_01": "INSURANCE INFOR"
},
"TEXTLITERAL_04": {
"Freetext_01": "NAMESTATE FARM INSURANCE COMPANY",
"Freetext_02": "PLCYQO123456789",
"Freetext_03": "AMNT100000",
"Freetext_04": "YEAR2004"
}
}
],
"TDTLoop": [
{
"TDT": {
"Transportstagecodequalifier_01": "11",
"MODEOFTRANSPORT_03": {
"Transportmodenamecode_01": "03"
},
"TRANSPORTMEANS_04": {
"Transportmeansdescription_04": "BT"
},
"Transitdirectionindicatorcode_06": "I",
"TRANSPORTIDENTIFICATION_08": {
"Codelistidentificationcode_02": "109",
"Transportmeansidentificationname_04": "10000324"
}
}
}
],
"EQDLoop": [
{
"EQD": {
"Equipmenttypecodequalifier_01": "BI",
"EQUIPMENTIDENTIFICATION_02": {
"Equipmentidentifier_01": "10000325",
"Codelistidentificationcode_02": "109"
}
},
"SEL": [
{
"Transportunitsealidentifier_01": "SEALEQUNO001"
}
],
"RFFLoop": [
{
"RFF": {
"REFERENCE_01": {
"Referencecodequalifier_01": "ABZ",
"Referenceidentifier_02": "EQU123"
}
},
"LOC": [
{
"Locationfunctioncodequalifier_01": "89",
"LOCATIONIDENTIFICATION_02": {
"Locationnamecode_01": "VA",
"Codelistidentificationcode_02": "163"
}
}
]
}
]
}
],
"CNILoop": [
{
"CNI": {
"Consolidationitemnumber_01": "3741",
"DOCUMENTMESSAGEDETAILS_02": {
"Documentstatuscode_02": "23"
}
},
"DOC": [
{
"DOCUMENTMESSAGENAME_01": {
"Documentnamecode_01": "714",
"Documentname_04": "61"
},
"DOCUMENTMESSAGEDETAILS_02": {
"Documentidentifier_01": "KH041122106",
"Documentsourcedescription_03": "LOCK"
}
}
],
"RFFLoop": [
{
"RFF": {
"REFERENCE_01": {
"Referencecodequalifier_01": "AAM",
"Referenceidentifier_02": "LOCKKH041122106"
}
},
"CNT": [
{
"CONTROL_01": {
"Controltotaltypecodequalifier_01": "58",
"Controltotalquantity_02": "158"
}
}
],
"LOC": [
{
"Locationfunctioncodequalifier_01": "9",
"LOCATIONIDENTIFICATION_02": {
"Locationnamecode_01": "U0107",
"Codelistidentificationcode_02": "78"
}
}
],
"GEI": [
{
"Processinginformationcodequalifier_01": "7",
"PROCESSINGINDICATOR_02": {
"Processingindicatordescriptioncode_01": "135"
}
}
],
"TDTLoop": [
{
"TDT": {
"Transportstagecodequalifier_01": "11"
},
"DTM": [
{
"DATETIMEPERIOD_01": {
"Dateortimeorperiodfunctioncodequalifier_01": "133",
"Dateortimeorperiodtext_02": "20041230",
"Dateortimeorperiodformatcode_03": "102"
}
}
],
"RFFLoop": [
{
"RFF": {
"REFERENCE_01": {
"Referencecodequalifier_01": "AWM"
}
},
"TSR": [
{
"CONTRACTANDCARRIAGECONDITION_01": {
"Contractandcarriageconditioncode_01": "9"
}
}
]
}
]
}
],
"NADLoop": [
{
"NAD": {
"Partyfunctioncodequalifier_01": "CN",
"PARTYIDENTIFICATIONDETAILS_02": {
"Partyidentifier_01": "65424",
"Codelistidentificationcode_02": "109"
},
"NAMEANDADDRESS_03": {
"Nameandaddressdescription_01": "1234 MAIN STREET"
},
"PARTYNAME_04": {
"Partyname_01": "KATHY SMITH"
},
"Cityname_06": "BELTSVILLE",
"COUNTRYSUBENTITYDETAILS_07": {
"Countrysubentitynamecode_01": "MD",
"Codelistidentificationcode_02": "163"
},
"Postalidentificationcode_08": "20708",
"Countrynamecode_09": "US"
},
"CTALoop": [
{
"CTA": {
"Contactfunctioncode_01": "IC"
},
"COM": [
{
"COMMUNICATIONCONTACT_01": {
"Communicationaddressidentifier_01": "8005551212",
"Communicationaddresscodequalifier_02": "TE"
}
}
]
}
]
},
{
"NAD": {
"Partyfunctioncodequalifier_01": "IM",
"PARTYIDENTIFICATIONDETAILS_02": {
"Partyidentifier_01": "00010",
"Codelistidentificationcode_02": "109"
},
"NAMEANDADDRESS_03": {
"Nameandaddressdescription_01": "1234 MAIN STREET"
},
"PARTYNAME_04": {
"Partyname_01": "KATHY SMITH"
},
"Cityname_06": "BELTSVILLE",
"COUNTRYSUBENTITYDETAILS_07": {
"Countrysubentitynamecode_01": "MD",
"Codelistidentificationcode_02": "163"
},
"Postalidentificationcode_08": "20708",
"Countrynamecode_09": "US"
},
"CTALoop": [
{
"CTA": {
"Contactfunctioncode_01": "IC"
},
"COM": [
{
"COMMUNICATIONCONTACT_01": {
"Communicationaddressidentifier_01": "8005551212",
"Communicationaddresscodequalifier_02": "TE"
}
}
]
}
]
},
{
"NAD": {
"Partyfunctioncodequalifier_01": "OS",
"PARTYIDENTIFICATIONDETAILS_02": {
"Partyidentifier_01": "27190",
"Codelistidentificationcode_02": "109"
},
"NAMEANDADDRESS_03": {
"Nameandaddressdescription_01": "1234 MAIN STREET"
},
"PARTYNAME_04": {
"Partyname_01": "KATHY SMITH"
},
"Cityname_06": "BELTSVILLE",
"COUNTRYSUBENTITYDETAILS_07": {
"Countrysubentitynamecode_01": "MD",
"Codelistidentificationcode_02": "163"
},
"Postalidentificationcode_08": "20708",
"Countrynamecode_09": "US"
},
"CTALoop": [
{
"CTA": {
"Contactfunctioncode_01": "IC"
},
"COM": [
{
"COMMUNICATIONCONTACT_01": {
"Communicationaddressidentifier_01": "8005551212",
"Communicationaddresscodequalifier_02": "TE"
}
}
]
}
]
}
],
"GIDLoop": [
{
"GID": {
"Goodsitemnumber_01": "1"
},
"PAC": [
{
"Packagequantity_01": "158",
"PACKAGETYPE_03": {
"Packagetypedescriptioncode_01": "COL"
}
}
],
"FTX": [
{
"Textsubjectcodequalifier_01": "AAA",
"TEXTLITERAL_04": {
"Freetext_01": "IRON COIL",
"Freetext_02": "SHEET METAL"
}
}
],
"MEA": [
{
"Measurementpurposecodequalifier_01": "AAI",
"VALUERANGE_03": {
"Measurementunitcode_01": "K",
"Measure_02": "750"
}
}
],
"SGP": [
{
"EQUIPMENTIDENTIFICATION_01": {
"Equipmentidentifier_01": "10000325",
"Codelistidentificationcode_02": "109"
}
}
]
}
]
}
]
}
],
"UNT": {
"NumberofSegmentsinaMessage_01": "38",
"MessageReferenceNumber_02": "CUSCAR54"
}
}Read the file into typed objects with ediFabric .NET, or post it to the ediFabric Cloud REST API from any language and get JSON back.
using EdiFabric.Templates.EdifactD03B; License.SetSerial("YOUR_SERIAL_KEY"); using (var stream = File.OpenRead(@"C:\edi\CargoReport.txt")) using (var reader = new EdifactReader(stream, (unb, ung, unh) => typeof(TSCUSCAR).GetTypeInfo())) { var items = await reader.ReadToEndAsync(); foreach (var transaction in items.OfType<TSCUSCAR>()) { if (transaction.IsValid(out MessageErrorContext errors)) Console.WriteLine($"{transaction.UNH.MessageReferenceNumber_01} is valid"); else Console.WriteLine(string.Join(Environment.NewLine, errors.Flatten())); } }
curl -X POST 'https://api.edination.com/v2/edifact/read' \ -H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \ -H 'Content-Type: application/octet-stream' \ --data-binary '@CargoReport.txt'
Populate a TSCUSCAR object in .NET, or post JSON in the shape shown above to ediFabric Cloud, and get a valid CUSCAR file back.
using EdiFabric.Templates.EdifactD03B; License.SetSerial("YOUR_SERIAL_KEY"); var transaction = new TSCUSCAR(); // Message header transaction.UNH = new UNH(); transaction.UNH.MessageReferenceNumber_01 = "0001"; transaction.UNH.MessageIdentifier_02 = new S009(); transaction.UNH.MessageIdentifier_02.MessageType_01 = "CUSCAR"; transaction.UNH.MessageIdentifier_02.MessageVersionNumber_02 = "D"; transaction.UNH.MessageIdentifier_02.MessageReleaseNumber_03 = "03B"; transaction.UNH.MessageIdentifier_02.ControllingAgencyCoded_04 = "UN"; transaction.BGM = new BGM(); transaction.BGM.DOCUMENTMESSAGENAME_01 = new C002(); transaction.BGM.DOCUMENTMESSAGENAME_01.Documentnamecode_01 = "85"; transaction.BGM.DOCUMENTMESSAGENAME_01.Documentname_04 = "STANDARD"; transaction.BGM.DOCUMENTMESSAGEIDENTIFICATION_02 = new C106(); transaction.BGM.DOCUMENTMESSAGEIDENTIFICATION_02.Documentidentifier_01 = "LOCKKH04112206"; transaction.BGM.Messagefunctioncode_03 = "22"; // Repeating DTM transaction.DTM = new List<DTM>(); // ... set the remaining loops and segments the same way // SegmentBuilders is in the Common project of the example repository using (var stream = new MemoryStream()) { using (var writer = new EdifactWriter(stream)) { writer.Write(SegmentBuilders.BuildUnb("1")); writer.Write(transaction); } Console.WriteLine(Encoding.UTF8.GetString(stream.ToArray())); }
# the JSON returned by /read, edited or produced by your application curl -X POST 'https://api.edination.com/v2/edifact/write' \ -H 'Ocp-Apim-Subscription-Key: YOUR_SERIAL_KEY' \ -H 'Content-Type: application/json' \ --data-binary '@CargoReport.json' \ -o 'CargoReport.txt'
The carrier, NVOCC or agent responsible for the cargo, to the customs authority of the port of arrival or departure.
Usually with a CUSRES customs response message that accepts the report or lists errors and holds.
No. Each customs authority publishes its own implementation guide with the directory version, segments and codes it requires.
In .NET, install EdiFabric and EdiFabric.Templates.Edifact, read the file with EdifactReader into TSCUSCAR objects and write them back with EdifactWriter. From any other language, post the file to the ediFabric Cloud REST API, which returns the same structure as JSON and converts JSON back to EDIFACT.