Build and Manage a Simple Inventory

Applies to: Inventory API | Catalog API

Learn how to manage the stock level of item variations by increasing inventory amounts and changing them for spoiled items.

Link to section

Overview

If you're processing itemized payments with Square APIs or hardware, quantities for item variations with inventory tracking enabled are automatically updated. For other operations that change quantities, you need to apply the adjustment manually.

Link to section

Requirements and limitations

  • You have item variations defined in your Square product catalog. For information about working with the Catalog API, see Add a Catalog Item.
  • Applications using OAuth must have INVENTORY_READ permission to read inventory information and INVENTORY_WRITE permission to update inventory states.
  • You need a valid access token. You should test with Sandbox credentials whenever possible. For more information, see Access Tokens and Other Square Credentials.
Link to section

1. Create or search for catalog item variations to track

Building and maintaining an inventory amounts to specifying a quantity of stock for selected product item variations in the item library. Before setting inventory amounts, your application needs to create the item variation to track or find the existing item variation that you want to set inventory amounts for.

New products:

  1. Use the UpsertCatalogObject endpoint to create item variations. For information about adding item variations, see Add a Catalog Item.
  2. Use BatchChangeInventory to set their stock levels.

Existing products:

  1. Use SearchCatalogItems to find the variation IDs. For information about searching the catalog, see Search for Items and Objects.
  2. Use BatchChangeInventory to update their stock levels.
Link to section

Search for item variations to track in inventory

The following cURL example calls the SearchCatalogItems endpoint of the Catalog API to find previously created item variations representing Medium sized shirts:

Search catalog items

Link to section

2. Increase the in-stock quantity of an item variation

When the seller receives new inventory (such as 100 blue medium shirts at their store), they can update the system using the BatchChangeInventory endpoint. This call tells the Inventory API to add the items to stock at that location, changing their status from NONE to IN_STOCK.

Link to section

Receive 100 blue medium shirts

Batch change inventory

When updating inventory, you need four key pieces of information: the item's variation ID (to identify the specific product), the inventory state change, the location ID (to specify which store), and a timestamp (to track when the change happened).

Link to section

3. Record items received as damaged

The seller might find a few of the new shirts to be damaged. To track these items, the seller needs to report the shirts as damaged and deduct them from IN_STOCK inventory.

Call the BatchChangeInventory endpoint, specify a quantity of two units of the shirts, and change their inventory state from IN_STOCK to WASTE.

Link to section

Record two damaged shirts

The following cURL example shows how to update the inventory to account for two units of damaged item variation (Medium blue shirt) as unsellable:

Batch change inventory