> For the complete documentation index, see [llms.txt](https://docs.fulfillmenttools.com/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/complex-routing-with-combinatorics/fences.md).

# Fences

{% hint style="info" %}
If you would like to use these functionalities, [contact our Support team](https://ocfulfillment.atlassian.net/servicedesk/customer/portal/1) for more information and activation support.
{% endhint %}

{% hint style="info" %}
Note the difference between complex routing with combinatorics fences and regular [fences](/documentation/by-pillar/advanced-order-routing/fences.md).
{% endhint %}

Fences define hard constraints within the routing decision. They establish mandatory conditions that must be satisfied to be considered a valid routing option.

fulfillmenttools validates each potential routing option against all configured fences. Any routing option that doesn't meet all fence conditions is discarded immediately and excluded from further consideration.

This strict behavior ensures that only routing options that fully comply with non-negotiable business, operational, or contractual requirements remain eligible.

Because fences eliminate invalid options early, they directly influence which facilities or routing options can be selected. If all potential options violate at least one fence, routing may yield no valid option, and the order becomes [unroutable](https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/unroutable-orders).

## Types of fences

There are two types of fences that fulfillmenttools distinguishes between:

* [Default fences](#standard-fences)
* [Custom fences](#custom-fences)

Both can be added to the routing strategy via Backoffice or [API](/documentation/apis/api-reference/routing-plans-doms.md).

### **Default fences**

fulfillmenttools provides predefined fences that cover common and generally applicable restrictions by default.

#### **Country borders**

The country border fence excludes all routing options in which not all locations are located in the same country as the final recipient.

The final recipient can be either a consume or an ordering facility.

The country determination is based on:

* Consumer: the delivery address (not the billing address)
* Facility: the facility address

Any routing option that violates this condition is considered invalid and is excluded from the final routing decision.

The country border fence prevents cross‑border shipping in routing decisions. This restriction may be required, for example, due to licensing constraints, customs regulations, or other legal and regulatory requirements.

#### **Order completeness**

The order completeness fence ensures that only routing options are considered in which all items of an order can be successfully assigned to one or more facilities. A routing option must therefore achieve an assignment rate of 100%. If at least one item can't be assigned, the entire routing option is excluded from the routing decision.

The purpose of this fence is to ensure that the final recipient receives all items that were ordered. As a consequence, partial fulfillment is not permitted. If no routing option exists that allows a complete assignment of all order items, the routing process results in an [unroutable](/documentation/by-pillar/advanced-order-routing/unroutable-orders.md) outcome. In such cases, the order can't be fulfilled at all.

**Example**

A consumer places an order containing:

* 1 × item A
* 1 × item B

Two routing options are evaluated:

* **Option 1**
  * Item A can be successfully assigned to a location
  * Item B can't be assigned to any location
  * The resulting assignment rate is 50%
  * Result: This option is filtered out by the order completeness fence

<figure><img src="/files/RNk2DHsEzAS5q7Gj04Fc" alt="" width="375"><figcaption></figcaption></figure>

* **Option 2**
  * Item A can be successfully assigned to a location
  * Item B can be successfully assigned to an additional location
  * This results in an assignment rate of 100%
  * Result: Provided that [order split](/documentation/by-pillar/advanced-order-routing/order-split.md) is active, this option isn't filtered out by the fence

<figure><img src="/files/9VJIA8edicQDxuiAmNbZ" alt="" width="375"><figcaption></figcaption></figure>

Items may fail to be assigned to a location for various reasons, including:

* No location has the item available.
* Locations with available stock don't have a valid `facilityConnection` to deliver the item to the final recipient.
* Locations with stock and a valid `facilityConnection` are excluded by another fence.

In all of these cases, the routing option is rejected by the order completeness fence if full assignment can't be achieved.

#### Preselected facilities

The preselected facilities fence reduces the facility candidates to be considered from all facilities within the network to only specified ones. This list may contain from 1 to 500 `facilityRefs` and is only applicable for ship-from-store orders.

### **Custom fences**

Custom fences extend the standard fence mechanism to support project‑specific or business‑specific requirements.

You can create custom fences that can be used on their own or alongside default fences. See the [Custom routing rules article](/documentation/by-pillar/advanced-order-routing/doms-toolkit.md) for full details.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fulfillmenttools.com/documentation/by-pillar/advanced-order-routing/complex-routing-with-combinatorics/fences.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
