Site Logo

Introduction to Shipping Rules

ShipEngine's shipping rules allow you to define a set of conditions that determine which carrier and service a shipment will use, rather than assigning the carrier and service values within the shipment object of a Create Shipment or Purchase Label call.

This allows you to automate carrier and service selection for your shipments based on the criteria you've set for your specific workflow.

Requirements

After creating your shipping rules, you'll use the shipping_rule_id in the shipment object in place of both the carrier_id and service_code in your relevant API calls.

Type of Shipping Rules

There are two types of shipping rules you can create:

  • Condition based rules
  • Service group rules

Both types of rules use If/Then logic. The difference is how each type of shipping rule executes this logic.

In both cases, you create Statements where you define rule conditions. A statement can contain multiple conditions and a rule can contain multiple statements.

When a statement has multiple conditions, these conditions are additive, as in, they behave like AND statements. When a rule has multiple statements, each statement behaves like an ELSE IF statement. For condition-base rules, this means subsequent statements are only evaluated if the prior statement does not apply. For service group rules, all statements in a rule are evaluated.

Condition Based Rules

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

Example statement:

  • IF total shipment weight is less than 2 kg
  • AND detination country equals GB (Great Britain)
  • AND if the maximum dimension is less than 1m
  • Then allocate Yodel Next Day as the shipment's carrier and service

Condition based rules also include a default service option, or an ELSE statement. This states that if none of the statements in the rule are true, then allocate the default carrier and service to the shipment instead.

Service Group Rules

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

For example, your prioritized list of services includes service A (highest priority service), service B, service C, and service D (lowest priority service). You then define the following statements to exclude services from consideration:

  • If shipment weight is greater than 3kg, exclude service A
  • If shipment weight is greater than 5kg, exclude service D
  • If shipment destination is GB AND max dimension is greater than 1m, exclude service C.

If all three of these statements are true for a specific shipment, service B will be allocated to that shipment. If after a rule is evaluated, there is more than one service in the priority list that could be applied, the highest priority service remaining in the list will be allocated to the shipment.

Creating Shipping Rules

For details on creating and using shipping rules, go to our Shipping Rules Guide.

Currently, you must create and manage your shipping rules in the ShipEngine dashboard. However, we will soon be adding a shipping rules endpoint so you can create and manage your shipping rules programmatically. Stay tuned!