Handle Inventory Event Notifications

Applies to: Inventory API | Orders API | Catalog API

Learn how to use inventory webhooks to receive notifications when quantities are updated for catalog item variations.

Link to section

Overview

The Inventory API exposes a webhook to dispatch inventory.count.updated events every time an inventory quantity is updated for a catalog item variation.

Your application can subscribe to the webhook to receive inventory.count.updated event notifications to track inventory for item variations and changes in near real time reliably and accurately.

Link to section

Requirements and limitations

The following requirements and limitations apply to webhooks for inventory events:

  • Your notification URL must be a publicly available HTTPS URL. It must also return an HTTP 2xx response code within 10 seconds of receiving a notification.

  • Applications that use OAuth must have INVENTORY_READ permission to subscribe to an inventory event and receive notifications.

Link to section

How inventory event notifications work

Each inventory event notification includes basic information, such as the event type and event ID. The data field of each webhook notification contains detailed information about the specific event.

Link to section

Inventory.count.updated event

An inventory.updated event is invoked when an inventory count is updated. Inventory counts can be updated on the following actions:

  • Sale of an item variation - A seller completes a sale in Square Point of Sale or completes an order generated by an Orders API integration.
  • Square Dashboard, Item Library action - A seller updates the count of an item variation using the Item Library - Manage Stock dialog.
  • Stock tracking event - If stock tracking is enabled, any stock action such as sold, received, recounted, restocked, or transferred triggers the event.
  • API-driven count update - Using the BatchChangeInventory endpoint.

The following shows an example of the inventory.count.updated event:

Link to section

State adjustments

The inventory.count.updated webhook event also sends notifications when an item variation stock changes state. For state adjustments, inventory.count.updated sends a single notification containing two inventory counts: one count that describes the quantity and state before the state change and one that describes the quantity and state after the state change.

Link to section

Bulk updates

A single webhook notification can contain up to 100 inventory counts. If a bulk update includes more than 100 updates, the event data spans multiple webhook notifications.

Link to section

Process inventory event notifications

To process inventory event notifications, do the following:

  • Meet requirements and understand limitations.
  • Subscribe to inventory event notifications.
  • Handle received event notifications.
  • Test and deploy your application.

The following sections describe each of these tasks. For information about general webhooks requirements, components, and processes, see Square Webhooks.

Link to section

Subscribe to inventory event notifications

To subscribe to inventory event notifications, you can configure webhooks for your Square inventory application. A webhook registers the URL that Square sends notifications to, the events you want to be notified about, and the Square API version that your integration is using.

To configure a webhook

  1. In the Developer Console, open the application to which you want to subscribe.
  2. In the left pane, choose Webhooks.
  3. At the top of the page, choose Sandbox or Production. Use the Sandbox environment for testing.
  4. Choose Add Endpoint, and then configure the endpoint:
    1. For Webhook Name, enter a name such as Inventory Webhook.
    2. For URL, enter your notification URL. If you don't have a working URL yet, you can enter https://example.com as a placeholder.
    3. Optional. For API Version, choose a Square API version. By default, this is set to the same version as the application.
    4. For Events, choose inventory.count.updated. If you want to receive notifications about other events at the same webhook URL, choose them or configure another endpoint.
    5. Choose Save.

To validate your webhook configuration

You can send a generic notification from the Developer Console to validate that your webhook is configured correctly.

  1. On the Webhooks page for your application, choose the webhook that you want to test.
  2. In the Endpoint Details pane, choose •••, and then choose Send Test Event.
  3. Select an event and then choose Send. If the endpoint is configured correctly, the Send Test Event window displays the response code and notification body.
Link to section

Receive inventory event notifications

To handle notifications, applications typically perform the following steps:

  1. Validate the authenticity of the notification. For more information, see Verify and Validate an Event Notification.
  2. Respond with an HTTP 2xx response code within 10 seconds of receiving the notification.
  3. Inspect, process, store, or forward the notification.

The body of the notification is a JSON object that contains the following properties.

PropertyDescription
merchant_idThe ID of the seller associated with the inventory count.
location_idThe ID of the seller location where the inventory is stored.
typeThe type of event: inventory.count.updated
event_idThe unique ID of the inventory event, which is used for idempotency support. For more information, see Idempotency.
created_atA timestamp of when the event occurred (for example, 2020-12-28T21:59:15.286Z).
dataInformation about the inventory count change, represented by the InventoryCountUpdatedSquareEventData object.
Link to section

Test your webhooks

To test your webhook with actual resources, change an inventory quantity of an item variation in your account. Make sure to test with the same environment (Sandbox or Production) where you registered for the webhook.

The following are some ways you can trigger inventory event notifications.

Test with a Sandbox account

  1. Open the Developer Console.
  2. Under Sandbox Test Accounts, choose Square Dashboard for your test account.

Test with a production account

  1. Open the Square Dashboard.
  2. In the left pane, choose Items & orders, and then choose Items.
    1. Choose an item to open the Edit Item page.
    2. Choose stock and turn on tracking if it's not already on.
    3. Choose an adjustment reason.
    4. Update the stock count.

Test from API Explorer

Sign in to API Explorer and choose your Sandbox or production environment. Call the Inventory API BatchChangeInventory endpoint as needed to test your webhook.

Test using cURL

Send cURL requests to the Inventory API endpoint. For more information, see Build and Manage a Simple Inventory.

Note

You can also send a generic test notification from the Developer Console.

You should receive notifications for inventory events that you subscribe to. Square doesn't send notifications for events that fail.

For information about troubleshooting Square webhooks, see Troubleshoot Webhooks.