CUSCAR Customs cargo report message (D04B)

This is the standard EDIFACT D04B spec, with 17 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 (103 KB) Generate classes
The ediFabric .NET template, class TSCUSCAR. It needs the common segments, composites and codes of EDIFACT D04B, one download for every transaction in the version. Download C# (1 KB) Common files (57 KB)
The intermediary model ediFabric Native loads with set_map. Native supports X12 today, and EDIFACT is coming. Download Native (1 KB)

Use the CUSCAR 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 CUSCAR files into TSCUSCAR objects. See ediFabric .NET.

ediFabric Native

Native supports X12 today, and EDIFACT is coming. When it's available, map version D04B to this Native model with set_map to parse CUSCAR files to JSON from Python, Java, C or C#. See ediFabric Native.

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 CUSCAR classes in Python, Java, Node.js, Go, Rust or C

The OpenEDI file describes each CUSCAR as JSON. To work with CUSCAR data as typed objects, generate classes from the OpenEDI file in your language; the root class is TSCUSCAR. The classes keep the loops, segments, lengths and code lists, but not the EDI data formats. Read more in Generate a class from OpenEDI.

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

For a sample file, the same data as JSON, and code to parse, validate and generate the CUSCAR, see the CUSCAR transaction guide.

CUSCAR structure

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

IDNameUsageMax use
UNHMessage HeaderOptional1
BGMBEGINNING OF MESSAGEMandatory1
DTMDATE/TIME/PERIODOptional9
LOCPLACE/LOCATION IDENTIFICATIONOptional9
QTYQUANTITYOptional9
Loop RFFREFERENCEOptional99
RFFREFERENCEMandatory1
DTMDATE/TIME/PERIODOptional9
Loop NADNAME AND ADDRESSOptional99
NADNAME AND ADDRESSMandatory1
DTMDATE/TIME/PERIODOptional1
Loop CTACONTACT INFORMATIONOptional9
CTACONTACT INFORMATIONMandatory1
COMCOMMUNICATION CONTACTOptional9
FTXFREE TEXTOptional9
Loop TDTTRANSPORT INFORMATIONOptional9
TDTTRANSPORT INFORMATIONMandatory1
LOCPLACE/LOCATION IDENTIFICATIONOptional99
DTMDATE/TIME/PERIODOptional99
GEIPROCESSING INFORMATIONOptional9
Loop EQDEQUIPMENT DETAILSOptional9999
EQDEQUIPMENT DETAILSMandatory1
TSRTRANSPORT SERVICE REQUIREMENTSOptional9
MEAMEASUREMENTSOptional9
DIMDIMENSIONSOptional9
SELSEAL NUMBEROptional9
NADNAME AND ADDRESSOptional9
GEIPROCESSING INFORMATIONOptional9
LOCPLACE/LOCATION IDENTIFICATIONOptional1
Loop TMPTEMPERATUREOptional9
TMPTEMPERATUREMandatory1
RNGRANGE DETAILSOptional1
CNTCONTROL TOTALOptional9
Loop CNICONSIGNMENT INFORMATIONOptional9999
CNICONSIGNMENT INFORMATIONMandatory1
CNTCONTROL TOTALOptional9
Loop RFFREFERENCEOptional9999
RFFREFERENCEMandatory1
CNTCONTROL TOTALOptional9
MOAMONETARY AMOUNTOptional9
LOCPLACE/LOCATION IDENTIFICATIONOptional99
GEIPROCESSING INFORMATIONOptional9
CUXCURRENCIESOptional9
CPICHARGE PAYMENT INSTRUCTIONSOptional9
Loop TDTTRANSPORT INFORMATIONOptional9
TDTTRANSPORT INFORMATIONMandatory1
LOCPLACE/LOCATION IDENTIFICATIONOptional9
DTMDATE/TIME/PERIODOptional9
MEAMEASUREMENTSOptional9
Loop RFFREFERENCEOptional9
RFFREFERENCEMandatory1
TSRTRANSPORT SERVICE REQUIREMENTSOptional9
Loop NADNAME AND ADDRESSOptional99
NADNAME AND ADDRESSMandatory1
DTMDATE/TIME/PERIODOptional9
RFFREFERENCEOptional9
Loop CTACONTACT INFORMATIONOptional9
CTACONTACT INFORMATIONMandatory1
COMCOMMUNICATION CONTACTOptional9
Loop QTYQUANTITYOptional9
QTYQUANTITYMandatory1
FTXFREE TEXTOptional9
Loop GIDGOODS ITEM DETAILSMandatory9999
GIDGOODS ITEM DETAILSMandatory1
PACPACKAGEOptional9
HANHANDLING INSTRUCTIONSOptional9
FTXFREE TEXTOptional99
MEAMEASUREMENTSOptional99
MOAMONETARY AMOUNTOptional9
SGPSPLIT GOODS PLACEMENTOptional9999
DGSDANGEROUS GOODSOptional99
PCIPACKAGE IDENTIFICATIONOptional9
CSTCUSTOMS STATUS OF GOODSOptional1
LOCPLACE/LOCATION IDENTIFICATIONOptional9
TMDTRANSPORT MOVEMENT DETAILSOptional9
Loop GEIPROCESSING INFORMATIONOptional9
GEIPROCESSING INFORMATIONMandatory1
DTMDATE/TIME/PERIODOptional9
DOCDOCUMENT/MESSAGE DETAILSOptional9
PACPACKAGEOptional9
MEAMEASUREMENTSOptional9
Loop QTYQUANTITYOptional9
QTYQUANTITYMandatory1
FTXFREE TEXTOptional1
Loop AUTAUTHENTICATION RESULTOptional1
AUTAUTHENTICATION RESULTMandatory1
DTMDATE/TIME/PERIODOptional9
RFFREFERENCEOptional9
UNTMessage TrailerOptional1