# Stock transfers

An order can be configured to ship from a specific [stock location](https://docs.commercelayer.io/core-api-reference/stock_locations) only (e.g. primary). In this scenario, the number of shipments is minimized by creating one or more stock transfers from the stock location where the items are available to the primary one. [Shipping categories](https://docs.commercelayer.io/core-api-reference/shipping_categories) are still honored, by creating different shipments.

Stock transfers can also be created outside of the order scope. In this case, they have no relationships with [shipments](https://docs.commercelayer.io/core-api-reference/shipments) and [line items](https://docs.commercelayer.io/core-api-reference/line_items).

Stock transfers are created in `draft` status and are moved to `upcoming` as soon as the order associated with the related shipment is placed. At this stage, the necessary stock reservations are created to eventually allow [order editing](https://docs.commercelayer.io/core-api-reference/orders#order-editing) (the stock will be then actually decremented when the stock transfer is completed). If stock transfers are involved, when the order fulfillment process starts all the related shipments are moved to the `on_hold` status and the related stock transfers status becomes `picking` (if you want to change the default behavior and put also all the stock transfers `on_hold`, set the `put_stock_transfers_on_hold` attribute to `true` at the [inventory model](https://docs.commercelayer.io/core-api-reference/inventory_models) level — you'll then need to manually manage the subsequent status changes). When a shipment is cancelled all the associated stock transfers are also moved to the `cancelled` status.

{% hint style="info" %}
All the status changes above are **shipment-driven** and happen automatically only if the stock transfer is associated with a shipment. Otherwise, you need to manually pass the corresponding trigger attributes (e.g. `_upcoming,` `_picking`, etc .).
{% endhint %}

{% hint style="warning" %}
To avoid dealing with incomplete stock transfers, make sure to move them to `completed` before the related order approval (or before the moment when you decide to decrement the stock in case you have chosen to do it manually by setting the related flag at the [inventory model](https://docs.commercelayer.io/core-api-reference/inventory_models#manual-stock-decrementation) level).
{% endhint %}

## Changing the stock transfer quantity

Unless a stock transfer is completed or cancelled and provided that there is enough origin stock availability to allow the change, you can update the stock transfer's quantity using [integration](https://app.gitbook.com/s/-LgByaSP8eKjad-MIuHE/api-credentials#integration) API credentials. On successful update, the associated stock reservation will be destroyed and a new one will be created based on the new quantity.

<details>

<summary>Data model</summary>

Check the related [ER diagram](https://commercelayer.io/docs/data-model/stock-transfers) and explore the flowchart that illustrates how the stock transfer resource relates to the other API entities.

</details>

<details>

<summary>How-to</summary>

Check the related [guide](https://app.gitbook.com/s/-Lk-ezuDClaMavTqnRi0/inventory/strategies) to learn more about the available inventory model strategies, how they work, and how stock transfers are managed based on each of them.

</details>
