Question

To add an item using the Square Connect API, it requires an Item Variation. To create an Item Variation, it requires an Item ID.

How do you get an Item ID without an Item Variation or how do you create an Item Variation without an Item ID?

https://connect.squareup.com/docs/api?path=getting-started#post-items

https://connect.squareup.com/docs/api?path=getting-started#post-variations

I have tried creating an Item with a manually-created Item Variation object, but receive an unprocessable_entity error in return. I have also attempted to create an Item Variation on a previously-created Item (an Item not created with the API), and received a not_found error.

Was it helpful?

Solution

Thanks for pointing out this confusing point in the docs. When creating a new Item, you must create at least one Variation for that Item in the same request. Note that you don't need to specify an Item ID for the Variation (it's automatically associated with the created Item). For example, providing the following JSON body to the Create Item endpoint creates a Popcorn Item with a single variation, Large.

{
  "name": "Popcorn",
  "description": "Crispy and delicious",
  "variations": [
    {
      "name":"Large",
      "pricing_type":"FIXED_PRICING",
      "price_money": {
         "amount": 500,
         "currency_code": "USD"
      }
    }
  ]
}

Note that you also don't need to include an Item ID in your request body when creating a Variation for an existing Item with the Create Variation endpoint, because you include the Item ID in the path of the request itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top