Prompt
How do I build international shipping support with customs forms and tracking?
Latest observation
To build international shipping support with customs forms and tracking, you usually need to combine shipping rate/label generation, customs documentation, and tracking event ingestion into one flow.
1) Core pieces you need
A. Shipping carrier or aggregator integration
Use a carrier API directly or a shipping platform like:
- UPS / FedEx / DHL / USPS direct APIs
- Aggregators: EasyPost, Shippo, ShipEngine, AfterShip
These services typically provide:
- Rate quotes
- Label purchase
- Customs form generation
- Tracking numbers
- Tracking webhooks
2) Data you must collect at checkout
For international shipments, collect more than domestic shipping info:
- Recipient name
- Full address
- Country
- Phone number and email
- Shipping method
- Contents details for customs:
- Item description
- Quantity
- Unit value
- Currency
- HS code / tariff code if possible
- Country of origin
- Weight
- SKU
- Whether it’s a gift, sale, return, sample, etc.
3) Customs forms
International shipments often require customs paperwork such as:
- Commercial invoice
- CN22 / CN23 (depending on carrier/country/value)
- Electronic customs data submission
What to implement
When creating a shipment, send the carrier:
- Sender and recipient details
- Package details
- Customs items list
- Declared value
- Incoterms if needed
- Export reason
The carrier or aggregator returns:
- Customs form PDF or label with integrated customs info
- Tracking number
- Shipment status
4) Tracking support
Implement tracking in two parts:
A. Initial tracking creation
When the label is purchased, store:
- Carrier
- Tracking number
- Shipment ID
- Label URL
- Customs docs URL
B. Live tracking updates
Use:
- Webhook callbacks from carrier/aggregator
- Or polling if webhooks aren’t available
Track common statuses:
- Label created
- In transit
- Arrived at customs
- Customs held
- Out for delivery
- Delivered
- Exception / returned / lost
5) Customs clearance considerations
International shipping can fail if customs data is incomplete or inaccurate.
Make sure to:
- Use accurate item descriptions
- Avoid vague descriptions like “gift” or “merchandise”
- Include values per item, not just total
- Declare origin country
- Respect restricted goods by destination country
- Handle duties/taxes:
- DDP: duties paid by sender
- DDU/DAP: recipient pays duties on arrival
6) Suggested backend flow
A typical flow looks like this:
- Customer places order
- System validates international address
- System gathers customs item details
- Shipping API requests rates
- Customer selects shipping option
- Create shipment + label + customs docs
- Save tracking number and documents
- Send confirmation email
- Listen for tracking webhooks
- Update shipment status in your database/UI
7) Example API workflow
Conceptually:
POST /shipments
{
"to_address": {
"name": "Jane Doe",
"street1": "123 Main St",
"city": "Toronto",
"state": "ON",
"postal_code": "M5V 2T6",
"country": "CA",
"phone": "+14165551234"
},
"from_address": {
"name": "Your Store",
"street1": "500 Market St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105",
"country": "US",
"phone": "+14155550000"
},
"parcels": [
{
"weight": 2.5,
"length": 10,
"width": 8,
"height": 4
}
],
"customs_items": [
{
"description": "Cotton T-shirt",
"quantity": 2,
"value": 40.00,
"currency": "USD",
"origin_country": "US",
"hs_code": "610910"
}
],
"options": {
"incoterm": "DAP",
"contents_type": "merchandise"
}
}
Response:
{
"shipment_id": "shp_123",
"tracking_number": "1Z999...",
"label_url": "https://...",
"customs_forms": [
"https://.../commercial_invoice.pdf"
]
}
8) Practical implementation tips
- Validate destination-country requirements before creating shipment
- Cache tracking data locally, don’t rely only on live carrier queries
- Provide customer-facing tracking pages
- Handle timezone differences in tracking events
- Use webhooks for near real-time updates
- Support multiple package shipments if needed
- Keep a record of customs declarations for audits
9) If you want the easiest path
For most teams, the fastest route is:
- Shippo or EasyPost for labels + customs + tracking
- AfterShip for tracking UI and notifications if you want a stronger customer-facing tracking experience
10) Things to watch out for
- HS code accuracy
- Restricted/prohibited items
- De minimis thresholds by country
- VAT/GST rules
- Return-to-sender scenarios
- Duties/taxes handling at checkout
If you want, I can also give you:
- a step-by-step architecture diagram,
- a database schema for shipments/customs/tracking, or
- example code using a shipping API like EasyPost or Shippo.