Site Logo

Shipping Rules Guide

Shipping Rules provide ShipEngine with a set of criteria to determine which carrier and service to apply to a shipment. This allows you to automate the selection of carrier and service according to your specific business needs.

If you are new to ShipEngine's Shipping Rules, be sure to read our Introduction to Shipping Rules page.

Currently, you must create your shipping rules in the ShipEngine dashboard. Once created, each rule will have a shipping rule ID you can add to the shipment object for either Create Shipment or Purchase Label calls.

For each shipment, ShipEngine will evaluate the rule statements against the shipment details and apply the appropriate carrier_id and service_code to the shipment for you.

Create a Shipping Rule

To create a shipping rule:

  1. Log into your ShipEngine account and go to Shipping Rules.ShipEngine Dashboard Shipping Rules in the side navigation
  2. Click the Create rule button.
  3. Choose the type of rule you wish to create, condition or service group.Select shipping rule type popup
  4. Enter a name for your rule (each rule requires a unique name).
  5. Create the statements with the conditions you require (see below sections for details on creating each type of rule).

Condition-based Rules

With condition based rules, you define explicit sets of conditions the shipment must meet for the service defined in the statement to be allocated to that shipment.

To create a condition-based rule:

  1. Fill in the first condition for Statement 1. Shipping rule with first rule statement
  2. Add more conditions if needed. Remember, additional conditions behave as AND statements.
  3. Set the carrier and service that should apply to shipments meeting the statement conditions in the allocate fields.
  4. Add more statements if needed. Remember, additional statements behave as ELSE IF statements. Shipping rule with second rule statement
  5. Set the default carrier and service that will apply if the shipment does not meet the conditions for any of the rule statements.
  6. Save the rule.

Service Group Rules

With service group rules, you first create a list of services in a prioritized order. Then, you create "exclusion statements" with conditions that will exclude a service from the shipment if the shipment meets the statement conditions.

To create a service group rule:

  1. Choose a carrier and select which of that carrier's services to include in your priority list. Add services to Service Group shipping rule
  2. Click the Add to list button to add this set of services to the list.
  3. (Optional) Continue to add services to your priority list, a carrier at a time, until you have the full list of services you wish this rule to contiain.
  4. Arrange the priority of the services in your list. You can drag and drop the services into the desired order, or use the up/down arrows to adjust the position of a service in the list. Move services in priority list for shipping rules
  5. Fill in the first condition for Statement 1. Service group rule first statement
  6. Add more conditions if needed. Remember, additional conditions behave as AND statements.
  7. Choose which services to exclude from shipments that meet the statement conditions.
  8. Add more statements if needed. Remember, additional statements behave as ELSE IF statements. Service group rule second statement
  9. Save the rule.

Apply Rules to Your Shipments

Once you have created your shipping rules, you will use the shipping_rule_id property in place of the carrier_id and service_code properties in your shipment object for any shipment you want the rule to apply to. You can use the shipping_rule_id property for both the Create Shipment and Purchase Label endpoints.

Shipengine will evaluate the shipping rule provided in the request to determine the carrier_id and service_code that should apply to the shipment. Both will then be included in the corresponding response.

Create Shipment Example Request

This is an example of the shipment object in a request for Creating a Shipment.

POST /v1/shipments/

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
POST /v1/shipments HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"shipments": [
{
"shipping_rule_id": "se-49",
"ship_to": {
"address_line1": "200 Grays Inn Road",
"city_locality": "London",
"postal_code": "WC1X 8XZ",
"country_code": "GB",
"name": "John Smith",
"phone": "+44 020 5555 5555",
"email": "[email protected]"
},
"ship_from": {
"address_line1": "Victoria Embankment",
"city_locality": "London",
"postal_code": "SW1A 2JF",
"country_code": "GB",
"name": "Norman Shaw",
"phone": "+44 020 7219 4272",
"email": "[email protected]"
},
"packages": [
{
"package_code": "package",
"weight": {
"value": 1.5,
"unit": "kilogram"
},
"dimensions": {
"height": 6,
"width": 5,
"length": 15,
"unit": "centimeter"
}
}
]
}
]
}

Purchase Label Example Request

This is an example of the shipment object in a request for Purchasing a Label.

POST /v1/labels/

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
POST /v1/labels HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"shipment": {
"shipping_rule_id": "se-49",
"ship_to": {
"address_line1": "200 Grays Inn Road",
"city_locality": "London",
"postal_code": "WC1X 8XZ",
"country_code": "GB",
"name": "John Smith",
"phone": "+44 020 5555 5555",
"email": "[email protected]"
},
"ship_from": {
"address_line1": "Victoria Embankment",
"city_locality": "London",
"postal_code": "SW1A 2JF",
"country_code": "GB",
"name": "Norman Shaw",
"phone": "+44 020 7219 4272",
"email": "[email protected]"
},
"packages": [
{
"package_code": "package",
"weight": {
"value": 1.5,
"unit": "kilogram"
},
"dimensions": {
"height": 6,
"width": 5,
"length": 15,
"unit": "centimeter"
}
}
]
}
}

Available Condition Properties

The following identifiers are currently available to use in your statement conditions:

IdentifierValue TypeAvailable OperatorsDescription
To address residential indicatorstringis, is notIndicates whether this is a residential address.
From address residential indicatorstringis, is notIndicates whether this is a residential address.
To countrystringis, is notThe two-letter ISO 3166-1 country code
From countrystringis, is notThe two-letter ISO 3166-1 country code
Warehouse IDlistin, not inThe warehouse that the shipment is being shipped from
To postal codelistin, not in, starts withList of postal codes, separated by a comma
From postal codelistin, not in, starts withList of postal codes, separated by a comma
Number of packagesintegeris, is less than, is less or equal to, is greater than, is greater than or equal toNumber of packages of a shipment
Total weightdecimalis, is less than, is less or equal to, is greater than, is greater than or equal toWeight of a shipment
Available units: Gram, Kilogram, Pound, Ounce
Max dimensiondecimalis, is less than, is less or equal to, is greater than, is greater than or equal toDimension filter of any of the available dimensions of a shipment height width length
Available units: centimeter, inch
Shipment valuedecimalis, is less than, is less or equal to, is greater than, is greater than or equal toShipment’s product value sum