DOCS

Validate a Declaration ID

Shipping labels | Validate a Declaration ID

Retrieve status of a Declaration ID and auto-fill customs documentation

If you create postal labels, you can call Zonos to retrieve complete customs declaration details when a user provides a Declaration ID. This eliminates the need for users to manually fill out customs documentation, creating a seamless shipping experience where duties are prepaid and customs forms are automatically populated.

Auto-fill customs declarations 

Follow the steps below to enable automatic customs declaration population using Declaration IDs from your platform.

1. Enable Declaration ID field in label creation flow

Add a Declaration ID field to your postal label creation interface. When users enter a valid Declaration ID, your platform can auto-populate the customs declaration, eliminating manual data entry.

2. Query Declaration ID status and customs declaration details

Use the following query to retrieve complete customs declaration data using the Declaration ID. This returns validation status along item details, values, HS codes, and recipient information when available

Query

GraphQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
query DeclarationQuery($id: ID!) {
  declaration(id: $id) {
    id
    status
    paymentStatus
    landedCost {
      id
      method
      landedCostGuaranteeCode
      amountSubtotals {
        duties
        taxes
        fees
        landedCostTotal
      }
    }
    items {
      id
      sku
      productId
      amount
      currencyCode
      name
      hsCode
      description
      hsCodeSource
      countryOfOrigin
      quantity
      measurements {
        type
        value
        unitOfMeasure
      }
    }
    parties {
      id
      type
      person {
        firstName
        lastName
        email
        phone
      }
      location {
        id
        line1
        line2
        countryCode
        postalCode
      }
    }
  }
}

Variables

GraphQL

1
2
  "id": "0mm1993s0mdcn"
}

3. Handle response and auto-populate customs declaration

The API response includes validation status and customs data. Use the status information to determine whether the Declaration ID is valid, then auto-populate available customs data or prompt for manual entry.

Example responses

Valid Declaration ID with complete customs data:

Response

JSON

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
  "data": {
    "declaration": {
      "id": "0mm1993s0mdcn",
      "status": "OPEN",
      "paymentStatus": "OPEN",
      "landedCost": {
        "id": "landed_cost_eabb13ab-df23-45df-9ce8-96dd29d396d1",
        "method": "DAP",
        "landedCostGuaranteeCode": "NOT_APPLICABLE",
        "amountSubtotals": {
          "duties": 0.0,
          "taxes": 0.0,
          "fees": 2.62,
          "landedCostTotal": 2.62
        }
      },
      "items": [
        {
          "id": "item_0mm199388v57g",
          "sku": "item_1",
          "productId": "item_1",
          "amount": 70.0,
          "currencyCode": "USD",
          "name": "Item 1",
          "hsCode": "9504.90.4000",
          "description": "This is the description for Item 1",
          "hsCodeSource": "TARIFF_COMPLETED",
          "countryOfOrigin": "CN",
          "quantity": 2,
          "measurements": [
            {
              "type": "WEIGHT",
              "value": 1,
              "unitOfMeasure": "POUND"
            }
          ]
        }
      ],
      "parties": [
        {
          "id": "party_0kesb32rw5hfa",
          "type": "DESTINATION",
          "person": {
            "firstName": "test",
            "lastName": "origin",
            "email": null,
            "phone": "1234567890"
          },
          "location": {
            "id": "location_c7882546-652e-49cb-81a4-98962a54c49f",
            "line1": "123 Test Street",
            "line2": "",
            "countryCode": "US",
            "postalCode": "84790"
          }
        },
        {
          "id": "party_0mjfz59bgg175",
          "type": "ORIGIN",
          "person": {
            "firstName": "test",
            "lastName": "destination",
            "email": null,
            "phone": "1234567890"
          },
          "location": {
            "id": "location_0mdzb9vk8bp7c",
            "line1": "998 Ridgehaven",
            "line2": null,
            "countryCode": "CA",
            "postalCode": "N0N 0N0"
          }
        }
      ]
    }
  }
}

4. Create the shipment

Process the label creation using either auto-populated data from a Declaration ID or manually entered declaration information.

5. Link tracking number to Declaration ID

After label creation, use the declarationShipmentCreate mutation to link the tracking number with the Declaration ID, ensuring proper duty payment validation and shipment tracking.

Create shipment

GraphQL

1
2
3
mutation DeclarationShipmentCreate($input: DeclarationShipmentCreateInput!) {
  declarationShipmentCreate(input: $input)
}

You can create a shipment tied to a Declaration ID by passing an array of trackingNumbers and the declarationID used for the shipment.

Variables without carton details

GraphQL

1
2
3
4
5
6
{
  "input": {
    "declarationId": "0mm32wfyrn5es",
    "trackingNumbers": ["test_tracking_1", "test_tracking_2"]
  }
}

You can create a shipment by passing the declarationID used for the shipment. If you have details about the cartons, and items within the cartons, you can pass those in the shipmentCarton along with the trackingNumber for that carton.

Variables with carton details

GraphQL

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  "input": {
    "declarationId": "0mm32wfyrn5es",
    "shipmentCartons": [
      {
        "dimensionalUnit": "INCH",
        "length": 8,
        "width": 4,
        "height": 2,
        "trackingNumber": "1234567890",
        "weight": 5,
        "weightUnit": "POUND",
        "items": [
          {
            "itemReference": "item_1",
            "quantity": 3,
            "hsCode": "1234.56.7890"
          }
        ]
      }
    ]
  }
}

Was this page helpful?