Migration to general_customs_declaration
The top-level customs_declaration object in requests to create or update shipments (e.g., in CreateCompositeShipmentRequest) previously supported several specific, now-deprecated declaration types. These have now been replaced with a general customs declaration that can be used for all occasions.
Summary of Changes
- Deprecated JSON fields on
CustomsDeclaration:cn22cn23cp72electronic_invoice_upselectronic_invoice_fedex
- Replacement: All of the above are replaced by the
general_customs_declarationfield which uses theGeneralCustomsDeclarationobject. - Affected Endpoints:
POST /shipments.createPOST /shipments.createAndBookPOST /customs_declaration.upsert- All endpoints responding with a
Shipmentobject (ascustoms.declarationwill now containgeneral_customs_declarationinstead of the deprecated fields).
Reason for Deprecation
Previously, the customs_declaration object supported several distinct, specific declaration types (e.g., cn22, electronic_invoice_ups). This approach led to a fragmented and less flexible system, requiring integrators to manage multiple structures for similar information. To simplify the API, improve maintainability, and allow for a more consistent representation of customs data, these specific types have been consolidated into a single, general customs declaration (general_customs_declaration). This new structure is designed to be comprehensive enough for all use cases, reducing complexity and making future extensions easier.
Before Migration (Example JSON Body)
You might have been sending a customs_declaration object in your request body like this:
{
"customs_declaration": {
"cn22": {
"items": [
{
"description": "Cotton T-Shirt",
"quantity": 2,
"total_net_weight": 400,
"total_value": 5000,
"hs_tariff_number": "61091000",
"country_of_origin": "PT"
}
],
"currency": "USD",
"total_gross_weight": 550,
"contents_type": "SALE",
"eori_number": "SE1234567890"
}
}
}
After Migration (Example JSON Body)
The equivalent object using general_customs_declaration is structured as follows. Note that the entire customs_declaration object is now replaced by the content of GeneralCustomsDeclaration.
{
"customs_declaration": {
"general_customs_declaration": {
"items": [
{
"name": "Cotton T-Shirt",
"quantity": 2,
"unit_net_weight": 200,
"unit_value": 2500,
"hs_tariff_number": "61091000",
"country_of_origin": "PT"
}
],
"currency": "USD",
"total_gross_weight": 550,
"contents_type": "SALE",
"seller_identification_numbers": {
"eori": "SE1234567890"
}
}
}
}
Migration Steps
To migrate your integrations, you will need to:
- Identify Existing Declaration Type: Determine which of the deprecated customs declaration types (
cn22,cn23,cp72,electronic_invoice_ups,electronic_invoice_fedex) your integration is currently using. - Map Fields to
GeneralCustomsDeclaration: Using the provided field mapping tables, translate your existing customs data to the corresponding fields within thegeneral_customs_declarationobject. - Recalculate Item Values (Crucial): For each item within the customs declaration's
itemsarray, you must converttotal_valuetounit_value(total value / quantity) andtotal_net_weighttounit_net_weight(total net weight / quantity). This is a critical change, and failing to perform this calculation will result in incorrect customs declarations. - Update Request Bodies: Modify your
POST /shipments.create,POST /shipments.createAndBook, orPOST /customs_declaration.upsertrequest bodies to use the newgeneral_customs_declarationobject instead of the deprecated specific types. Ensure the entirecustoms_declarationobject now contains only thegeneral_customs_declarationfield. - Update API Response Parsing: When consuming API responses that include shipment details, ensure your code is updated to expect and parse the
customs.declarationfield to containgeneral_customs_declarationinstead of the old specific types.
Field Mapping Tables
DeclarationCN (CN22, CN23, CP72)
cn22, cn23, cp72 have been moved to general_customs_declaration and the fields should be mapped as:
Deprecated Field (DeclarationCN) |
New Field (GeneralCustomsDeclaration) |
Notes |
|---|---|---|
items.description |
items.description |
Direct mapping |
items.quantity |
items.quantity |
Direct mapping |
items.total_net_weight |
items.unit_net_weight |
Calculation required: total_net_weight / quantity |
items.total_value |
items.unit_value |
Calculation required: total_value / quantity |
items.hs_tariff_number |
items.hs_tariff_number |
Direct mapping |
items.country_of_origin |
items.country_of_origin |
Direct mapping |
currency |
currency |
Direct mapping |
total_gross_weight |
total_gross_weight |
Direct mapping |
contents_type |
contents_type |
Direct mapping |
contents_explanation |
contents_explanation |
Direct mapping |
eori_number |
seller_identification_numbers.eori |
Assumes EORI belongs to the seller. |
ElectronicInvoiceUPS / ElectronicInvoiceFedex
electronic_invoice_ups and electronic_invoice_fedex have been moved to general_customs_declaration and the fields should be mapped as:
Deprecated Field (ElectronicInvoiceUPS / ElectronicInvoiceFedex) |
New Field (GeneralCustomsDeclaration) |
Notes |
|---|---|---|
items.description |
items.description |
Direct mapping |
items.quantity |
items.quantity |
Direct mapping |
items.total_value |
items.unit_value |
Calculation required: total_value / quantity |
items.hs_tariff_number |
items.hs_tariff_number |
Direct mapping |
items.country_of_origin |
items.country_of_origin |
Direct mapping |
items.total_net_weight (Fedex only) |
items.unit_net_weight |
Calculation required: total_net_weight / quantity |
items.unit_value (Fedex only) |
items.unit_value |
Direct mapping |
currency |
currency |
Direct mapping |
total_gross_weight (UPS only) |
total_gross_weight |
Direct mapping |
contents_type |
contents_type |
Direct mapping |
contents_explanation (UPS only) |
contents_explanation |
Direct mapping |
invoice_number (UPS only) |
invoice_number |
Direct mapping |
invoice_date (UPS only) |
invoice_date |
Direct mapping |
sold_to (UPS only) |
sold_to |
Direct mapping |
incoterms (Fedex only) |
incoterms |
Direct mapping |
declaration_statement (Fedex only) |
declaration_statement |
Direct mapping |