Square API Upsert Error: "Object version does not match latest database version" even when using latest version from Get action

Hi all,

I’m running into an issue with the Square Catalog API (Upsert Catalog Object) in n8n.

:magnifying_glass_tilted_left: Problem:

When I try to upsert an ITEM, I get this error:

Bad request - please check your parameters
Object version does not match latest database version.

The weird part is, I am using the latest version.
My flow looks like this:


:link: My Flow:

  1. Webhook: receives the updated price, description, and other fields.
  2. Square API → Get Catalog Object: I use the item ID to pull the latest object, including its version.
  3. Square API → Upsert Catalog Object: I pass the object ID and the version directly from the previous step.
  4. Square API still returns the version mismatch error.

:hammer_and_wrench: Example of my Upsert body:

{
  "idempotency_key": "upsert-{{ Math.floor(Math.random() * 10000000) }}",
  "object": {
    "type": "ITEM",
    "id": "{{ $json.items[0].id }}",
    "version": {{ $json.items[0].version }},
    "present_at_all_locations": true,
    "item_data": {
      "name": "{{ $('Webhook').item.json.body['Service Name'] }}",
      "description": "{{ $('Webhook').item.json.body['Sales Description'] }}",
      "category_id": "{{ $('Webhook').item.json.body['Category ID - Square - Charleston'] }}",
      "is_taxable": true,
      "variations": [
        {
          "type": "ITEM_VARIATION",
          "id": "{{ $json.items[0].item_data.variations[0].id }}",
          "present_at_all_locations": true,
          "item_variation_data": {
            "item_id": "{{ $json.items[0].id }}",
            "name": "Regular",
            "sku": "{{ $('Webhook').item.json.body.SKU }}",
            "pricing_type": "FIXED_PRICING",
            "price_money": {
              "amount": {{ $('Webhook').item.json.body['New Price'] }},
              "currency": "USD"
            }
          }
        }
      ]
    }
  }
}

:white_check_mark: What I checked:

  • Confirmed the version value is correct by checking it directly in the Get Catalog Object response.
  • Verified that no other processes are modifying the item between the Get and the Upsert.
  • Ensured the id matches the correct item, and the category_id, sku, and other fields are correct.

:red_question_mark: Question:

  • Has anyone run into a version mismatch when the version is correct?
  • Could n8n be caching a stale version somehow?
  • Is there a better pattern for updating Square catalog objects reliably?

Any ideas would be appreciated!
Thanks :folded_hands:

(sorry for the chat gpt layout that was the best way to put my problems into words haha)

The missing part is not the “version” of the item, it’s the “version” of the variation. Add it to your JSON and it will work.