Extract Customs Declaration

Merge a commercial invoice, packing list, and bill of lading into a unified customs declaration.

Who this is for

Freight forwarders and customs brokers use this recipe to automate declaration processing. Upload a commercial invoice, packing list, and bill of lading in one API call — receive a unified customs record with shipper, consignee, goods description, HS codes, weights, and declared values.

Request
curl -X POST https://api.iterationlayer.com/document-extraction/v1/extract \
  -H "Authorization: Bearer $ITERATION_LAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "files": [
      {
        "type": "url",
        "name": "commercial-invoice.pdf",
        "url": "https://example.com/docs/commercial-invoice.pdf"
      },
      {
        "type": "url",
        "name": "packing-list.pdf",
        "url": "https://example.com/docs/packing-list.pdf"
      },
      {
        "type": "url",
        "name": "bill-of-lading.pdf",
        "url": "https://example.com/docs/bill-of-lading.pdf"
      }
    ],
    "schema": {
      "fields": [
        {
          "name": "shipper",
          "type": "OBJECT",
          "description": "Shipper details",
          "fields": [
            {
              "name": "name",
              "type": "TEXT",
              "description": "Shipper company name"
            },
            {
              "name": "address",
              "type": "TEXT",
              "description": "Shipper address"
            },
            {
              "name": "country",
              "type": "TEXT",
              "description": "Shipper country"
            }
          ]
        },
        {
          "name": "consignee",
          "type": "OBJECT",
          "description": "Consignee details",
          "fields": [
            {
              "name": "name",
              "type": "TEXT",
              "description": "Consignee company name"
            },
            {
              "name": "address",
              "type": "TEXT",
              "description": "Consignee address"
            },
            {
              "name": "country",
              "type": "TEXT",
              "description": "Consignee country"
            }
          ]
        },
        {
          "name": "goods",
          "type": "ARRAY",
          "description": "List of goods in the shipment",
          "fields": [
            {
              "name": "description",
              "type": "TEXT",
              "description": "Description of the goods"
            },
            {
              "name": "hs_code",
              "type": "TEXT",
              "description": "Harmonized System code"
            },
            {
              "name": "quantity",
              "type": "INTEGER",
              "description": "Number of units"
            },
            {
              "name": "weight_in_kg",
              "type": "NUMBER",
              "description": "Weight in kilograms"
            },
            {
              "name": "declared_value",
              "type": "CURRENCY_AMOUNT",
              "description": "Declared customs value"
            }
          ]
        },
        {
          "name": "total_weight_in_kg",
          "type": "NUMBER",
          "description": "Total shipment weight in kilograms"
        },
        {
          "name": "total_declared_value",
          "type": "CURRENCY_AMOUNT",
          "description": "Total declared customs value"
        },
        {
          "name": "currency",
          "type": "TEXT",
          "description": "Currency code for declared values"
        }
      ]
    }
  }'
Response
{
  "success": true,
  "data": {
    "shipper": {
      "value": {
        "name": {
          "value": "Shenzhen Electronics Co.",
          "confidence": 0.97,
          "citations": [
            "Shenzhen Electronics Co., Ltd."
          ]
        },
        "address": {
          "value": "88 Nanshan Road, Shenzhen",
          "confidence": 0.94,
          "citations": [
            "88 Nanshan Road, Shenzhen 518000"
          ]
        },
        "country": {
          "value": "CN",
          "confidence": 0.99,
          "citations": ["China"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "consignee": {
      "value": {
        "name": {
          "value": "EuroTech Imports GmbH",
          "confidence": 0.98,
          "citations": ["EuroTech Imports GmbH"]
        },
        "address": {
          "value": "Industriestr. 12, Hamburg",
          "confidence": 0.95,
          "citations": [
            "Industriestr. 12, 20095 Hamburg"
          ]
        },
        "country": {
          "value": "DE",
          "confidence": 0.99,
          "citations": ["Germany"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "goods": {
      "value": [
        {
          "description": {
            "value": "Wireless Bluetooth Earbuds",
            "confidence": 0.96,
            "citations": [
              "Wireless Bluetooth Earbuds"
            ]
          },
          "hs_code": {
            "value": "8518.30.20",
            "confidence": 0.93,
            "citations": ["HS 8518.30.20"]
          },
          "quantity": {
            "value": 500,
            "confidence": 0.98,
            "citations": ["Qty: 500 pcs"]
          },
          "weight_in_kg": {
            "value": 45.0,
            "confidence": 0.95,
            "citations": ["Net Weight: 45.0 kg"]
          },
          "declared_value": {
            "value": {
              "amount": "7,500.00",
              "currency": "USD"
            },
            "confidence": 0.97,
            "citations": ["USD 7,500.00"]
          }
        }
      ],
      "confidence": 0.95,
      "citations": []
    },
    "total_weight_in_kg": {
      "value": 52.5,
      "confidence": 0.96,
      "citations": [
        "Gross Weight: 52.5 kg"
      ]
    },
    "total_declared_value": {
      "value": {
        "amount": "7,500.00",
        "currency": "USD"
      },
      "confidence": 0.97,
      "citations": [
        "Total Declared Value: USD 7,500.00"
      ]
    },
    "currency": {
      "value": "USD",
      "confidence": 0.99,
      "citations": ["Currency: USD"]
    }
  }
}
Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });

const result = await client.extract({
  files: [
    {
      type: "url",
      name: "commercial-invoice.pdf",
      url: "https://example.com/docs/commercial-invoice.pdf",
    },
    {
      type: "url",
      name: "packing-list.pdf",
      url: "https://example.com/docs/packing-list.pdf",
    },
    {
      type: "url",
      name: "bill-of-lading.pdf",
      url: "https://example.com/docs/bill-of-lading.pdf",
    },
  ],
  schema: {
    fields: [
      {
        name: "shipper",
        type: "OBJECT",
        description: "Shipper details",
        fields: [
          {
            name: "name",
            type: "TEXT",
            description: "Shipper company name",
          },
          {
            name: "address",
            type: "TEXT",
            description: "Shipper address",
          },
          {
            name: "country",
            type: "TEXT",
            description: "Shipper country",
          },
        ],
      },
      {
        name: "consignee",
        type: "OBJECT",
        description: "Consignee details",
        fields: [
          {
            name: "name",
            type: "TEXT",
            description: "Consignee company name",
          },
          {
            name: "address",
            type: "TEXT",
            description: "Consignee address",
          },
          {
            name: "country",
            type: "TEXT",
            description: "Consignee country",
          },
        ],
      },
      {
        name: "goods",
        type: "ARRAY",
        description: "List of goods in the shipment",
        fields: [
          {
            name: "description",
            type: "TEXT",
            description: "Description of the goods",
          },
          {
            name: "hs_code",
            type: "TEXT",
            description: "Harmonized System code",
          },
          {
            name: "quantity",
            type: "INTEGER",
            description: "Number of units",
          },
          {
            name: "weight_in_kg",
            type: "NUMBER",
            description: "Weight in kilograms",
          },
          {
            name: "declared_value",
            type: "CURRENCY_AMOUNT",
            description: "Declared customs value",
          },
        ],
      },
      {
        name: "total_weight_in_kg",
        type: "NUMBER",
        description: "Total shipment weight in kilograms",
      },
      {
        name: "total_declared_value",
        type: "CURRENCY_AMOUNT",
        description: "Total declared customs value",
      },
      {
        name: "currency",
        type: "TEXT",
        description: "Currency code for declared values",
      },
    ],
  },
});

console.log(result);
Response
{
  "success": true,
  "data": {
    "shipper": {
      "value": {
        "name": {
          "value": "Shenzhen Electronics Co.",
          "confidence": 0.97,
          "citations": [
            "Shenzhen Electronics Co., Ltd."
          ]
        },
        "address": {
          "value": "88 Nanshan Road, Shenzhen",
          "confidence": 0.94,
          "citations": [
            "88 Nanshan Road, Shenzhen 518000"
          ]
        },
        "country": {
          "value": "CN",
          "confidence": 0.99,
          "citations": ["China"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "consignee": {
      "value": {
        "name": {
          "value": "EuroTech Imports GmbH",
          "confidence": 0.98,
          "citations": ["EuroTech Imports GmbH"]
        },
        "address": {
          "value": "Industriestr. 12, Hamburg",
          "confidence": 0.95,
          "citations": [
            "Industriestr. 12, 20095 Hamburg"
          ]
        },
        "country": {
          "value": "DE",
          "confidence": 0.99,
          "citations": ["Germany"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "goods": {
      "value": [
        {
          "description": {
            "value": "Wireless Bluetooth Earbuds",
            "confidence": 0.96,
            "citations": [
              "Wireless Bluetooth Earbuds"
            ]
          },
          "hs_code": {
            "value": "8518.30.20",
            "confidence": 0.93,
            "citations": ["HS 8518.30.20"]
          },
          "quantity": {
            "value": 500,
            "confidence": 0.98,
            "citations": ["Qty: 500 pcs"]
          },
          "weight_in_kg": {
            "value": 45.0,
            "confidence": 0.95,
            "citations": ["Net Weight: 45.0 kg"]
          },
          "declared_value": {
            "value": {
              "amount": "7,500.00",
              "currency": "USD"
            },
            "confidence": 0.97,
            "citations": ["USD 7,500.00"]
          }
        }
      ],
      "confidence": 0.95,
      "citations": []
    },
    "total_weight_in_kg": {
      "value": 52.5,
      "confidence": 0.96,
      "citations": [
        "Gross Weight: 52.5 kg"
      ]
    },
    "total_declared_value": {
      "value": {
        "amount": "7,500.00",
        "currency": "USD"
      },
      "confidence": 0.97,
      "citations": [
        "Total Declared Value: USD 7,500.00"
      ]
    },
    "currency": {
      "value": "USD",
      "confidence": 0.99,
      "citations": ["Currency: USD"]
    }
  }
}
Request
from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

result = client.extract(
    files=[
        {
            "type": "url",
            "name": "commercial-invoice.pdf",
            "url": "https://example.com/docs/commercial-invoice.pdf",
        },
        {
            "type": "url",
            "name": "packing-list.pdf",
            "url": "https://example.com/docs/packing-list.pdf",
        },
        {
            "type": "url",
            "name": "bill-of-lading.pdf",
            "url": "https://example.com/docs/bill-of-lading.pdf",
        },
    ],
    schema={
        "fields": [
            {
                "name": "shipper",
                "type": "OBJECT",
                "description": "Shipper details",
                "fields": [
                    {
                        "name": "name",
                        "type": "TEXT",
                        "description": "Shipper company name",
                    },
                    {
                        "name": "address",
                        "type": "TEXT",
                        "description": "Shipper address",
                    },
                    {
                        "name": "country",
                        "type": "TEXT",
                        "description": "Shipper country",
                    },
                ],
            },
            {
                "name": "consignee",
                "type": "OBJECT",
                "description": "Consignee details",
                "fields": [
                    {
                        "name": "name",
                        "type": "TEXT",
                        "description": "Consignee company name",
                    },
                    {
                        "name": "address",
                        "type": "TEXT",
                        "description": "Consignee address",
                    },
                    {
                        "name": "country",
                        "type": "TEXT",
                        "description": "Consignee country",
                    },
                ],
            },
            {
                "name": "goods",
                "type": "ARRAY",
                "description": "List of goods in the shipment",
                "fields": [
                    {
                        "name": "description",
                        "type": "TEXT",
                        "description": "Description of the goods",
                    },
                    {
                        "name": "hs_code",
                        "type": "TEXT",
                        "description": "Harmonized System code",
                    },
                    {
                        "name": "quantity",
                        "type": "INTEGER",
                        "description": "Number of units",
                    },
                    {
                        "name": "weight_in_kg",
                        "type": "NUMBER",
                        "description": "Weight in kilograms",
                    },
                    {
                        "name": "declared_value",
                        "type": "CURRENCY_AMOUNT",
                        "description": "Declared customs value",
                    },
                ],
            },
            {
                "name": "total_weight_in_kg",
                "type": "NUMBER",
                "description": "Total shipment weight in kilograms",
            },
            {
                "name": "total_declared_value",
                "type": "CURRENCY_AMOUNT",
                "description": "Total declared customs value",
            },
            {
                "name": "currency",
                "type": "TEXT",
                "description": "Currency code for declared values",
            },
        ]
    },
)

print(result)
Response
{
  "success": true,
  "data": {
    "shipper": {
      "value": {
        "name": {
          "value": "Shenzhen Electronics Co.",
          "confidence": 0.97,
          "citations": [
            "Shenzhen Electronics Co., Ltd."
          ]
        },
        "address": {
          "value": "88 Nanshan Road, Shenzhen",
          "confidence": 0.94,
          "citations": [
            "88 Nanshan Road, Shenzhen 518000"
          ]
        },
        "country": {
          "value": "CN",
          "confidence": 0.99,
          "citations": ["China"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "consignee": {
      "value": {
        "name": {
          "value": "EuroTech Imports GmbH",
          "confidence": 0.98,
          "citations": ["EuroTech Imports GmbH"]
        },
        "address": {
          "value": "Industriestr. 12, Hamburg",
          "confidence": 0.95,
          "citations": [
            "Industriestr. 12, 20095 Hamburg"
          ]
        },
        "country": {
          "value": "DE",
          "confidence": 0.99,
          "citations": ["Germany"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "goods": {
      "value": [
        {
          "description": {
            "value": "Wireless Bluetooth Earbuds",
            "confidence": 0.96,
            "citations": [
              "Wireless Bluetooth Earbuds"
            ]
          },
          "hs_code": {
            "value": "8518.30.20",
            "confidence": 0.93,
            "citations": ["HS 8518.30.20"]
          },
          "quantity": {
            "value": 500,
            "confidence": 0.98,
            "citations": ["Qty: 500 pcs"]
          },
          "weight_in_kg": {
            "value": 45.0,
            "confidence": 0.95,
            "citations": ["Net Weight: 45.0 kg"]
          },
          "declared_value": {
            "value": {
              "amount": "7,500.00",
              "currency": "USD"
            },
            "confidence": 0.97,
            "citations": ["USD 7,500.00"]
          }
        }
      ],
      "confidence": 0.95,
      "citations": []
    },
    "total_weight_in_kg": {
      "value": 52.5,
      "confidence": 0.96,
      "citations": [
        "Gross Weight: 52.5 kg"
      ]
    },
    "total_declared_value": {
      "value": {
        "amount": "7,500.00",
        "currency": "USD"
      },
      "confidence": 0.97,
      "citations": [
        "Total Declared Value: USD 7,500.00"
      ]
    },
    "currency": {
      "value": "USD",
      "confidence": 0.99,
      "citations": ["Currency: USD"]
    }
  }
}
Request
package main

import il "github.com/iterationlayer/sdk-go"

client := il.NewClient("YOUR_API_KEY")

result, err := client.Extract(il.ExtractRequest{
    Files: []il.FileInput{
        il.NewFileFromURL(
            "commercial-invoice.pdf",
            "https://example.com/docs/commercial-invoice.pdf",
        ),
        il.NewFileFromURL(
            "packing-list.pdf",
            "https://example.com/docs/packing-list.pdf",
        ),
        il.NewFileFromURL(
            "bill-of-lading.pdf",
            "https://example.com/docs/bill-of-lading.pdf",
        ),
    },
    Schema: il.ExtractionSchema{
        "goods": il.NewArrayFieldConfig(
            "goods",
            "List of goods in the shipment",
            []il.FieldConfig{
                il.NewTextFieldConfig(
                    "description", "Description of the goods",
                ),
                il.NewTextFieldConfig(
                    "hs_code", "Harmonized System code",
                ),
                il.NewIntegerFieldConfig(
                    "quantity", "Number of units",
                ),
                il.NewDecimalFieldConfig(
                    "weight_in_kg", "Weight in kilograms",
                ),
                il.NewCurrencyAmountFieldConfig(
                    "declared_value", "Declared customs value",
                ),
            },
        ),
        "total_weight_in_kg": il.NewDecimalFieldConfig(
            "total_weight_in_kg",
            "Total shipment weight in kilograms",
        ),
        "total_declared_value": il.NewCurrencyAmountFieldConfig(
            "total_declared_value",
            "Total declared customs value",
        ),
        "currency": il.NewTextFieldConfig(
            "currency", "Currency code for declared values",
        ),
    },
})
Response
{
  "success": true,
  "data": {
    "shipper": {
      "value": {
        "name": {
          "value": "Shenzhen Electronics Co.",
          "confidence": 0.97,
          "citations": [
            "Shenzhen Electronics Co., Ltd."
          ]
        },
        "address": {
          "value": "88 Nanshan Road, Shenzhen",
          "confidence": 0.94,
          "citations": [
            "88 Nanshan Road, Shenzhen 518000"
          ]
        },
        "country": {
          "value": "CN",
          "confidence": 0.99,
          "citations": ["China"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "consignee": {
      "value": {
        "name": {
          "value": "EuroTech Imports GmbH",
          "confidence": 0.98,
          "citations": ["EuroTech Imports GmbH"]
        },
        "address": {
          "value": "Industriestr. 12, Hamburg",
          "confidence": 0.95,
          "citations": [
            "Industriestr. 12, 20095 Hamburg"
          ]
        },
        "country": {
          "value": "DE",
          "confidence": 0.99,
          "citations": ["Germany"]
        }
      },
      "confidence": 0.96,
      "citations": []
    },
    "goods": {
      "value": [
        {
          "description": {
            "value": "Wireless Bluetooth Earbuds",
            "confidence": 0.96,
            "citations": [
              "Wireless Bluetooth Earbuds"
            ]
          },
          "hs_code": {
            "value": "8518.30.20",
            "confidence": 0.93,
            "citations": ["HS 8518.30.20"]
          },
          "quantity": {
            "value": 500,
            "confidence": 0.98,
            "citations": ["Qty: 500 pcs"]
          },
          "weight_in_kg": {
            "value": 45.0,
            "confidence": 0.95,
            "citations": ["Net Weight: 45.0 kg"]
          },
          "declared_value": {
            "value": {
              "amount": "7,500.00",
              "currency": "USD"
            },
            "confidence": 0.97,
            "citations": ["USD 7,500.00"]
          }
        }
      ],
      "confidence": 0.95,
      "citations": []
    },
    "total_weight_in_kg": {
      "value": 52.5,
      "confidence": 0.96,
      "citations": [
        "Gross Weight: 52.5 kg"
      ]
    },
    "total_declared_value": {
      "value": {
        "amount": "7,500.00",
        "currency": "USD"
      },
      "confidence": 0.97,
      "citations": [
        "Total Declared Value: USD 7,500.00"
      ]
    },
    "currency": {
      "value": "USD",
      "confidence": 0.99,
      "citations": ["Currency: USD"]
    }
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.