How long for a BatchChangeInventory request to take effect?

I’m successfully sending a BatchChangeInventory request. However, it seems that the quantity of the item (as reflected both in my online store and the Square dashboard) takes hours or even up to a day to get updated. This isn’t good enough. For my business case, I need the item quantity to update in, say, 5 minutes or less. Any hints or advice here?

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Handle Inventory Event Notifications
Inventory API
Enable Stock Conversion

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

The Square Inventory API is designed to reflect changes in real-time. However, in some cases, there might be a delay due to network issues or high server load. If you’re experiencing consistent delays, it might be worth checking your implementation for any potential issues. If everything seems fine on your end, you should reach out to Square’s technical support for further assistance.

This answer was reviewed by @Bryan-Square.

It sounds like InventoryPhysicalCount will force an immediate udpate?

Right, what was the request that you were making that was taking so long? :slightly_smiling_face:

Here’s what takes so long:

	# Create an inventory adjustment request
	body = {
		"idempotency_key": str(uuid.uuid4()),
		"changes": [
			{
				"type": "PHYSICAL_COUNT",
				"physical_count": {
					"catalog_object_id": item_id,
					"state": "IN_STOCK",
					"location_id": location_id,
					"quantity": str(desired_quantity),
					"occurred_at": datetime.now().replace(microsecond=0).isoformat() + 'Z'
				}
			}
		]
	}

	# Call the BatchChangeInventory endpoint
	response = square_client.inventory.batch_change_inventory(body)

Am I doing something wrong or is it expected to take hours for the Square website to reflect the update?

What’s your application ID and the catalog_object_id that you updated? :slightly_smiling_face:

App id is sq0idp-AZympsf16HcqLj6gr9pbOA

Here’s one of the items I was trying to update: 7XENLUZSBNUJE6LZEPPAQTW4

Here’s the full JSON request:

  content-length: 279
content-type: application/json
square-version: 2024-07-17
accept-encoding: gzip
accept: application/json
user-agent: Square-Python-SDK/37.1.1.20240717 (2024-07-17) CPython/3.11.2 (Linux)


    {
  "idempotency_key": "97049e5c-2c03-442c-a7d1-f8f5044bea9d",
  "changes": [
    {
      "type": "PHYSICAL_COUNT",
      "physical_count": {
        "catalog_object_id": "7XENLUZSBNUJE6LZEPPAQTW4",
        "state": "IN_STOCK",
        "location_id": "L8D59ES12E8CR",
        "quantity": "12",
        "occurred_at": "2024-08-14T13:28:14Z"
      }
    }
  ]

And the response is empty, which seems weird to me:

    date: Wed, 14 Aug 2024 18:28:14 GMT
content-length: 26
square-version: 2024-07-17
vary: Origin, Accept-Encoding
content-encoding: gzip
x-frame-options: SAMEORIGIN
content-type: application/json


    {}

I wonder if it’s because my request is missing some of the fields shown here:

For example, I didn’t put employee_id. However I don’t even know where I’d find that information.

I believe the error is that I didn’t convert the occurred_at timestamp to UTC.

With this change, it seems to work. :slight_smile:

Glad to hear that you figured it out. :slightly_smiling_face: