EDIFACT CUSCAR Customs Cargo Report

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.

At a glance

Standard
EDIFACT
Version
D03B (US CBP ACE)
Sent by
Carrier or agent to customs
Responses
CUSRES
ediFabric .NET template
TSCUSCAR in EdiFabric.Templates.Edifact
OpenEDI definition
View CUSCAR in the spec library

CUSCAR structure

The 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
UNHMessage headerMandatory1
BGMBeginning of messageOptional1
DTMDate/time/periodOptional>1
LOCPlace/location identificationOptional>1
QTYQuantityOptional>1
RFF loopReferenceOptional>1
RFFReferenceOptional1
DTMDate/time/periodOptional>1
NAD loopName and addressOptional>1
NADName and addressOptional1
DTMDate/time/periodOptional1
CTA loopContact informationOptional>1
CTAContact informationOptional1
COMCommunication contactOptional>1
FTXFree textOptional>1
TDT loopDetails of transportOptional>1
TDTDetails of transportOptional1
LOCPlace/location identificationOptional>1
DTMDate/time/periodOptional>1
GEIProcessing informationOptional>1
EQD loopEquipment detailsOptional>1
EQDEquipment detailsOptional1
TSRTransport service requirementsOptional>1
MEAMeasurementsOptional>1
DIMDimensionsOptional>1
SELSeal numberOptional>1
NADName and addressOptional>1
GEIProcessing informationOptional>1
LOCPlace/location identificationOptional1
TMP loopTemperatureOptional>1
TMPTemperatureOptional1
RNGRange detailsOptional1
RFF loopReferenceOptional>1
RFFReferenceOptional1
LOCPlace/location identificationOptional>1
CNTControl totalOptional>1
CNI loopConsignment informationOptional>1
CNIConsignment informationOptional1
CNTControl totalOptional>1
DOCDocument/message detailsOptional>1
RFF loopReferenceOptional>1
RFFReferenceOptional1
CNTControl totalOptional>1
MOAMonetary amountOptional>1
LOCPlace/location identificationOptional>1
GEIProcessing informationOptional>1
CUXCurrenciesOptional>1
CPICharge payment instructionsOptional>1
TDT loopDetails of transportOptional>1
TDTDetails of transportOptional1
LOCPlace/location identificationOptional>1
DTMDate/time/periodOptional>1
MEAMeasurementsOptional>1
RFF loopReferenceOptional>1
RFFReferenceOptional1
TSRTransport service requirementsOptional>1
NAD loopName and addressOptional>1
NADName and addressOptional1
DTMDate/time/periodOptional>1
RFFReferenceOptional>1
CTA loopContact informationOptional>1
CTAContact informationOptional1
COMCommunication contactOptional>1
QTY loopQuantityOptional>1
QTYQuantityOptional1
FTXFree textOptional>1
GID loopGoods item detailsOptional>1
GIDGoods item detailsOptional1
PACPackageOptional>1
HANHandling instructionsOptional>1
FTXFree textOptional>1
MEAMeasurementsOptional>1
MOAMonetary amountOptional>1
SGPSplit goods placementOptional>1
DGSDangerous goodsOptional>1
PCIPackage identificationOptional>1
CSTCustoms status of goodsOptional1
LOCPlace/location identificationOptional>1
TMDTransport movement detailsOptional>1
GEI loopProcessing informationOptional>1
GEIProcessing informationOptional1
DTMDate/time/periodOptional>1
DOCDocument/message detailsOptional>1
PACPackageOptional>1
MEAMeasurementsOptional>1
QTY loopQuantityOptional>1
QTYQuantityOptional1
FTXFree textOptional1
AUT loopAuthentication resultOptional1
AUTAuthentication resultOptional1
DTMDate/time/periodOptional>1
RFFReferenceOptional>1
UNTMessage trailerMandatory1

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.

Sample CUSCAR file

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'

The same CUSCAR as JSON

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"
  }
}

Parse and validate a CUSCAR file

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'

Generate a CUSCAR file

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'

CUSCAR questions

Who sends a CUSCAR?

The carrier, NVOCC or agent responsible for the cargo, to the customs authority of the port of arrival or departure.

How does customs respond?

Usually with a CUSRES customs response message that accepts the report or lists errors and holds.

Are CUSCAR messages the same in every country?

No. Each customs authority publishes its own implementation guide with the directory version, segments and codes it requires.

How do I parse and generate EDIFACT CUSCAR files in .NET?

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.

Related transactions

Parse your first CUSCAR in five minutes

The Community plan is free forever and needs no credit card. It includes ediFabric .NET, Native and Cloud.