How to Automate your Shipments

Use our Shipping Rules feature to automate your shipments by defining actions that will be automatically performed when specific conditions are met.

Introduction to shipping rules

Shipping rules allow you to automate your shipping processes by defining conditions and actions. These rules can be applied to:

  1. New shipments: by default, a newly created shipping rule applies only to shipments created after it.
  2. Existing ones: simply set the recalculate_shipments body field to true.

You can apply more than one shipping rule to your shipments: for this purpose, specify priority for each rule defining the order of application. Rules are applied by their priority in incremental order.

Creating a shipping rule

To create a shipping rule, send a POST request to https://api.easyship.com/2023-01/shipping_rules with the following body parameters:

  1. name (required).
  2. description (required).
  3. recalculate_shipments (optional, false by default).
  4. priority (optional).

Once you've set these parameters, proceed to define conditions and actions.

Defining conditions for a shipping rule

Shipping rule conditions are checked using the AND Boolean operator. You can specify conditions based on various criteria, including destination country, item category, item SKU, and more. Here is the full conditions list:

Condition name (Easyship Dashboard)Name of condition field (Easyship API)Description
Destination countrymatch_countryApply the shipping rule to orders for specified destination countries. This field operates with country identifiers that can be obtained via the Country API.
match_allApply the shipping rule to all shipments.
Item categorymatch_categoryApply the shipping rule to orders including specified item categories. This field operates with category identifiers that can be obtained via the Item Category API.
Destination state or provincematch_stateApply the shipping rule to orders for specified destination states. This option is available only for the United States, Canada, Australia and Mexico. The field operates with state identifiers that can be obtained via the State API.
Destination postal or ZIP codematch_zipcodeApply the shipping rule to orders for specified postal or ZIP codes.

Behaviour of this condition is defined by the following operators (operator string):

is_any_of — match any of specified codes

is_none_of — don’t match (exclude) specified codes

starts_with — match any codes starting with a specified symbols
Item stock keeping unit (SKU)match_skuApply the shipping rule to orders with specified stock keeping units.

Behaviour of this condition is defined by the following operators (operator string):

contains — look for SKU containing specified symbols

does_not_contain — look for SKUs that do not contain specified symbols

is_exactly — look for SKU exactly matching specified symbols
Store or platformmatch_platform_nameApply the shipping rule to orders placed within specified platforms.
match_storeApply the shipping rule to orders placed in specified stores.
Shipping option selected by buyermatch_buyer_selected_courier_nameApply the shipping rule to orders containing specified buyer-selected couriers.

Behaviour of this condition is defined by the following operators (operator string):

contains — look for a courier name containing specified symbols

does_not_contain — look for a courier name that does not contain specified symbols

is_exactly — look for a courier name exactly matching specified symbols
Number of itemsmatch_items_countApply the shipping rule to orders that contain specified number of items.

Behaviour of this condition is defined by the following operators (operator string):

greater_than — greater than a specified number (>)

greater_than_or_equal_to — greater than or equal to a specified number (>=)

less_than — less than a specified number (\<)

less_than_or_equal_to — less than or equal to a specified number (\<=)

equal_to — equal to a specified number (=)
Total selling pricematch_operationApply the shipping rule to orders that contain specified total selling price.

Behaviour of this condition is defined by the following operators (operator string):

greater_than — greater than a specified number (>)

greater_than_or_equal_to — greater than or equal to a specified number (>=)

less_than — less than a specified number (\<)

less_than_or_equal_to — less than or equal to a specified number (\<=)

equal_to — equal to a specified number (=)
Total shipment weightmatch_weightApply the shipping rule to orders that contain specified total shipment weight. The measurement system in use depends on destination country of an order.

Behaviour of this condition is defined by the following operators (operator string):

greater_than — greater than a specified number (>)

greater_than_or_equal_to — greater than or equal to a specified number (>=)

less_than — less than a specified number (\<)

less_than_or_equal_to — less than or equal to a specified number (\<=)

equal_to — equal to a specified number (=)
Order taginclude_order_tag_nameApply the shipping rule to orders including specified tags. The field operates with tag names that can be obtained via the Tag API.

Once you’ve set the conditions, continue with actions.

Defining actions for a shipping rule

To apply actions for the shipping rule conditions, configure the actions array:

Action name (Easyship Dashboard)Name of action field (Easyship API)Description
Exclude specified courier servicesadd_never_courierRemove specified courier services from applicable shipments. This field operates with courier identifiers that can be obtained via the Courier ID.
Prefer specified courier servicesadd_preferred_courierAdd specified courier services to applicable shipments. This field operates with courier identifiers that can be obtained via the [Courier ID](Courier ID).
Set import tax and duty payorforce_incotermsSet specified duty tax type and duty payor to all applicable shipments.

Behaviour of this condition is defined by the following operators (operator string):

DDP — pre-paid tax and duties included in shipping cost

DDU — post-paid tax and duties included in shipping cost

DDU_and_Best_DDP — tree post-paid and one pre-paid shipping options offered at checkout

DDP_and_Best_DDU — one post-paid and three pre-paid shipping options offered at checkout
Select couriers byforce_sort_byChange the sorting rule for selection of couriers for all applicable shipments.

Behaviour of this action is defined by the following operators (operator string):

total_charge — best price

delivery_time_rank — fastest delivery

value_for_money_rank — best value for money
Set insurance asforce_insuranceAlways set or reject insurance for all applicable shipments.

Behaviour of this action is defined by the insured boolean operator:

true — insure all applicable shipments

false — don’t insure all applicable shipments
Filter couriers by tracking qualityforce_tracking_ratingFilter couriers by tracking quality for all applicable shipments.

Behaviour of this action is defined by the force_tracking_rating boolean operator:

true — always filter couriers by tracking quality

false — never filter couriers by tracking quality
Select boxforce_packageAutomatically select specified box by Box ID for all applicable shipments.

This rule includes two options:

force_box_id — select specified box identifiers with the box type

force_flat_rate_box_id — select a specific flat rate box with an ID. For flat-rate shipping, the price is determined by the packaging rather than the weight or dimensions of an item.
Exclude specified boxesreject_packagesExclude boxes by specific Box ID.
Declare residential addressforce_residential_surchargeAlways set or reject setting a shipment destination address as residential for all applicable shipments.

Behaviour of this action is defined by the set_as_residential boolean operator:

true — set the destination address as residential for all applicable shipments

false — unset the destination address as residential for all shipments
Ship fromforce_ship_fromSet the sender’s origin address for all applicable shipments. This field operates with address identifiers that can be obtained via the Address ID.
Include return labels (domestic)force_automated_return_requestedInclude or reject including return labels for all applicable domestic shipments.

Behaviour of this action is defined by the automated_return_requested boolean operator:

true — always include return labels

false — never include return labels
Filter couriers by delivery timeadd_forced_delivery_timeFilter available couriers by delivery time for all applicable shipments.

Behaviour of this action is defined by the following operators (operator string):

less_than — less than a specified number (\<)

less_than_or_equal_to — less than or equal to a specified number (\<=)

greater_than_or_equal_to — greater than or equal to a specified number (>=)

greater_than — greater than a specified number (>)

Editing a shipping rule

You can modify an existing shipping rule by executing the PATCH https://api.easyship.com/2023-01/shipping_rules/{shipping_rule_id} request, where {shipping_rule_id} is the shipping rule identifier provided when you create a new rule.

This method allows to change core fields, add and edit its conditions and actions, and adjust the rule to your requirements.

To edit a rule, specify the request body parameters:

  1. Change name, description and priority if needed.
  2. Change existing conditions and actions: in case you don’t specify existing conditions or actions, they will be removed from the shipping rule.
  3. Add new conditions or actions if applicable.

Activating and deactivating a shipping rule

Manage your shipping rules by activating and deactivating them as needed.

To activate a shipping rule, execute POST https://api.easyship.com/2023-01/shipping_rules/{id}/activate where {id} is the shipping rule ID provided when you create a new rule.

To deactivate a shipping rule, execute POST https://api.easyship.com/2023-01/shipping_rules/{id}/deactivate.

Deleting a shipping rule

To delete a shipping rule, execute DELETE https://api.easyship.com/2023-01/shipping_rules/{shipping_rule_id} where {shipping_rule_id} is the shipping rule ID provided when you create a new rule.

To learn more about shipping rules functionality, see our Help Center article on How to Automate Tasks with Shipping Rules.