Zonos logo
DOCS

Cartonization

/

Create packaging options and cartonize with the Zonos API

Learn how to create packaging options and cartonize items prior to shipping

When fulfilling orders, it is important to package your items in the most effective way possible. The createPackagingOptions mutation allow users to tell Zonos about the packaging options that you use. If no packaging options are provided to us, a default value of 8x4x2 is used. Once you have provided us with your packaging options, you can use the cartonize mutation to determine which items should be placed in which package. These details can then be passed to the carrier to provide a more accurate shipping cost calculation.

Create packaging options 

The first step in determining how items should be packaged is to provide the packaging options that you commonly use to ship items.

Mutation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
mutation {
	createPackagingOption(
		input: {
			height: "10"
			length: "5"
			weightCapacity: "100"
			width: "5"
			dimensionalUnit: INCH
			name: "Box 1"
			type: PACKAGE
			weightUnit: POUND
		}
	) {
		name
		width
		weightUnit
		weightCapacity
		height
		length
	}
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
{
  "data": {
    "createPackagingOption": {
      "name": "Box 1",
      "width": 5,
      "weightUnit": "POUND",
      "weightCapacity": 100,
      "height": 10,
      "length": 5
    }
  }
}

Cartonizing items for the shipment 

Once you have provided packaging options, you will perform the cartonize mutation. This will take in the shipTo, shipFrom, and item details in order to properly determine which items will go in which box for shipping.

Mutation

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
mutation {
	partyCreateWorkflow(
		input: [
			{ type: ORIGIN, location: { countryCode: US } }
			{ type: DESTINATION, location: { countryCode: CA } }
		]
	) {
		id
	}
	itemCreateWorkflow(
		input: [
			{
				quantity: 4
				amount: 50
				productId: "123"
				description: "test 1223"
				currencyCode: USD
				measurements: [
					{ type: WEIGHT, value: 10, unitOfMeasure: POUND }
					{ type: LENGTH, value: 10, unitOfMeasure: INCH }
					{ type: WIDTH, value: 5, unitOfMeasure: INCH }
					{ type: HEIGHT, value: 2, unitOfMeasure: INCH }
				]
			}
		]
	) {
		id
	}
	cartonizeWorkflow {
		packagingOption {
			name
		}
		id
		width
		length
		height
		dimensionalUnit
		weight
		weightUnit
		items {
			quantity
			item {
				productId
				id
			}
		}
	}
}

Response

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
{
  "data": {
    "partyCreateWorkflow": [
      {
        "id": "party_ee2f80f2-0775-449e-a5f8-e8c5310f9c67"
      },
      {
        "id": "party_0ea8c605-3a4b-4e19-8f1a-316cb8ddbe78"
      }
    ],
    "itemCreateWorkflow": [
      {
        "id": "item_d0cb6416-17cc-404f-9755-a93ce4356c38"
      }
    ],
    "cartonizeWorkflow": [
      {
        "packagingOption": {
          "name": "Box 1"
        },
        "id": "carton_d0615c15-5158-4908-b818-9e5eeb7092ed",
        "width": 5.0,
        "length": 5.0,
        "height": 10.0,
        "dimensionalUnit": "INCH",
        "weight": 20,
        "weightUnit": "POUND",
        "items": [
          {
            "quantity": 1,
            "item": {
              "productId": "123",
              "id": "item_d0cb6416-17cc-404f-9755-a93ce4356c38"
            }
          },
          {
            "quantity": 1,
            "item": {
              "productId": "123",
              "id": "item_d0cb6416-17cc-404f-9755-a93ce4356c38"
            }
          }
        ]
      },
      {
        "packagingOption": {
          "name": "Box 1"
        },
        "id": "carton_817de960-8e20-43c4-84c8-f8eedfea1f93",
        "width": 5.0,
        "length": 5.0,
        "height": 10.0,
        "dimensionalUnit": "INCH",
        "weight": 20,
        "weightUnit": "POUND",
        "items": [
          {
            "quantity": 1,
            "item": {
              "productId": "123",
              "id": "item_d0cb6416-17cc-404f-9755-a93ce4356c38"
            }
          },
          {
            "quantity": 1,
            "item": {
              "productId": "123",
              "id": "item_d0cb6416-17cc-404f-9755-a93ce4356c38"
            }
          }
        ]
      }
    ]
  }
}