Developer Resources > Examples
Inventory
If you are using Dynamic Slotting, this section will explain the basic mutations and queries available:
Also, for managing Inventory through our API we have two powerful tools:
Managing Inventory on Dynamic Slotting Accounts
If you are using Dynamic Slotting, you might need to use the following queries & mutations when managing Inventory:
Location Query
This query will allow you to get the location’s name
, warehouse_id
or type
by using the location’s id
.
query { location(id: "QmluOjIyNDMwNDY=") { request_id complexity data { legacy_id name warehouse_id type { name } } } }
You should get something like this:
{ "data": { "location": { "request_id": "5f5692457acb6db59e0d556e", "complexity": 1, "data": { "legacy_id": 2243046, "name": "01PE06CC02", "warehouse_id": "V2FyZWhvdXNlOjExNzkw", "type": { "name": "Bin" } } } } }
Locations Query
This query will allow you to navigate through all the locations on a specific warehouse, for example, for warehouse_id = “V2FyZWhvdXNlOjExNzkw” if you try the following query:
query { locations(warehouse_id: "V2FyZWhvdXNlOjExNzkw") { request_id data { edges { node { id name zone type { name } pickable sellable } } } } }
You should get something like this:
{ "data": { "locations": { "request_id": "5ecbfee8e0e42dd4a4e13928", "data": { "edges": [ { "node": { "id": "QmluOjE0OTQxMDg=", "name": "Bin BO", "zone": "A", "type": "Pallet storage", "pickable": false, "sellable": false } }, { "node": { "id": "QmluOjEGehEDg=", "name": "Bin-A1", "zone": "A", "type": "Pallet storage", "pickable": true, "sellable": true } }] }}}}
Locations list for a specific Product Query
If you need to get all the existing locations for a specific SKU, you can use the location’s connection on the Product Query, for example, for SKU:”1122334458″
query { product(sku: "1122334458") { request_id data { sku name warehouse_products { warehouse_id locations { edges { node { location_id quantity } } } } } } }
And the response should be all of its locations on the different warehouses:
{ "data": { "product": { "request_id": "5ecc00a2075127485340d212", "data": { "sku": "1122334458", "name": "Test Product 4", "warehouse_products": [ { "warehouse_id": "V2FyZWhvdXNlOjExNzkw", "locations": { "edges": [ { "node": { "location_id": "QmluOjE0OTQxMDg=", "quantity": 0 } }, { "node": { "location_id": "QmluOjE0OTQxMTM=", "quantity": 18387 } }] }}}}}}
Create a new Location Mutation
If you need to create a new Location, you can use the location_create
mutation, for example:
mutation { location_create(data: { warehouse_id: "V2FyZWhvdXNlOjExNzkw", name: "Bin-12345" zone: "C2" pickable: false sellable: false }) { request_id location { name zone type { name } pickable sellable } } }
Update an existing Location Mutation
You can also edit the settings on an existing location by using the location_update
mutation and using the location_id
, for example:
mutation { location_update(data: { location_id: "123BVerb3456jnx" pickable: true sellable: true }) { request_id location { name zone type { name } pickable sellable } } }
Inventory add / Inventory remove Mutations
When removing or adding inventory for a specific SKU on a location, you can use both inventory_add
and inventory_remove
mutations. They both work similar, for example:
mutation { inventory_add(data: { sku: "1122334458", warehouse_id: "V2FyZWhvdXNlOjExNzkw", location_id: "QmluOjE0OTQxMDg=" quantity: 1 reason: "Test removing inventory from Public API" }) { request_id warehouse_product { locations { edges { node { location_id quantity } } } } } }
If you are going to perform this on a 3PL account you should also include the customer_account_id
Inventory Replace Mutation
This mutation works similar to what add or remove does, but it replaces the existing inventory on that location, for example:
mutation { inventory_replace(data: { sku: "1122334458", warehouse_id: "V2FyZWhvdXNlOjExNzkw", location_id: "QmluOjE0OTQxMDg=" quantity: 5 reason: "Testing replacing inventory from Public API" includes_non_sellable: False }) { request_id warehouse_product { locations { edges { node { location_id quantity } } } } }
Thi action will replace all the inventory for that Location on the Warehouse.
If the action is performed on a 3PL account, customer_account_id
should also be included.