Manage source items
If Adobe Commerce is configured to manage inventory, Commerce assigns all existing products to the default source. Currently, Commerce also assigns newly-created products to the default source. Single Source merchants do not need to manage source items, but Multi Source merchants may need to move products from the default source to a custom source, or move products from one custom source to another.
Service names:
inventoryApiSourceItemsDeleteV1
inventoryApiSourceItemsSaveV1
inventoryApiSourceItemRepositoryV1
REST endpoints:
POST V1/inventory/source-items-delete
POST V1/inventory/source-items
GET V1/inventory/source-items
sourceItems parameters:
Unassign products from a source
Use the POST V1/inventory/source-items-delete endpoint to unassign one or more products from the specified source. The sku and source_code attributes are required for each product.
data-variant=warning
data-slots=text
Sample usage:
POST <host>/rest/<store_code>/V1/inventory/source-items-delete
Payload:
{
"sourceItems": [{
"sku": "new_product1",
"source_code": "default"
},
{
"sku": "new_product2",
"source_code": "default"
}]
}
Response:
Commerce returns an empty array.
[]
Assign products to a source
POST V1/inventory/source-items is a powerful endpoint that allows you to define which sources carry each product as well as how many units are available at each source. You can use the endpoint to set up the initial quantities for each SKU at each source or add quantities as you receive shipments to replenish your supply.
data-variant=info
data-slots=text
The following example assigns 1000 units of product new_product1 to the central source and 2000 units to the east source. It also assigns 500 units of product new_product2 to the central source and 250 units to the east source.
Sample usage:
POST <host>/rest/<store_code>/V1/inventory/source-items
Payload:
{
"sourceItems": [{
"sku": "new_product1",
"source_code": "central",
"quantity": 1000,
"status": 1
},
{
"sku": "new_product1",
"source_code": "east",
"quantity": 2000,
"status": 1
},
{
"sku": "new_product2",
"source_code": "central",
"quantity": 500,
"status": 1
},
{
"sku": "new_product2",
"source_code": "east",
"quantity": 250,
"status": 1
}]
}
Response:
Commerce returns an empty array.
[]
Search for source items
The following call returns all source items for sku = new_product2.
See Search using REST APIs for information about constructing a search query.
Sample Usage:
GET <host>/rest/<store_code>/V1/inventory/source-items?searchCriteria[filter_groups][0][filters][0][field]=sku&searchCriteria[filter_groups][0][filters][0][value]=new_product2&searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Payload:
None
Response:
{
"items": [
{
"sku": "new_product2",
"source_code": "central",
"quantity": 500,
"status": 1
},
{
"sku": "new_product2",
"source_code": "east",
"quantity": 250,
"status": 1
}
],
"search_criteria": {
"filter_groups": [
{
"filters": [
{
"field": "sku",
"value": "new_product2",
"condition_type": "eq"
}
]
}
]
},
"total_count": 2
}