Added Main Location to Merchants and Locations APIs

We’re excited to share a new feature on our Merchants and Locations APIs making it easier to find the main location on an account.

The main location is the first location that is ever created for a merchant’s account.

:one: With RetrieveMerchant and ListMerchant, specifying a Merchant ID will return a new field called main_location_id with the ID of the main location.
:two: With RetrieveLocation, you can find the location details of the main location without knowing the location ID. Just specify main as the location ID to retrieve the main location’s information

If you have any questions, please reach out and we’ll be happy to help!

1 Like

Thanks, I’ve built an app that asks for order_write and payment_write. But I did not receive the location ID of the merchant which (I guess) I need to send the orders to. How can I get the location ID? Should I ask the merchant for it? Where could she find it (I did not see it on her dashboard today)?
Or should I add something in the “&scope=ORDERS_WRITE+PAYMENTS_WRITE” about it?

The easiest thing would be having MERCHANT_PROFILE_READ permission and just calling ListLocations to find the merchant’s locations, and ask the merchant which they want to use.

thanks. What if I just add MERCHANT_PROFILE_READ to the scope?
&scope=ORDERS_WRITE+PAYMENTS_WRITE+MERCHANT_PROFILE_READ

Would that work? Most of the merchants that use my app have 1 location only

Apologies for the delay here, yes that should work just fine.

Thank you!
If I have an app where customers can place orders to any of the 2 locations. I’d like to add a dropdown where customers can select the location they want to send the order to.

is there some way to retrieve the 2 location_id from the merchant manually so I can add that info to the dropdown?

Sure, you can use the ListLocations endpoint to fill the drop down, and then retrieve the id that they choose.

1 Like

Thanks @sjosey
Do Location IDs change?
What I have done is hard coding the location IDs in the app
So when I create an order:

  1. Get location ID → Do I need to implement this step? Or can I create the order from step 2 and prefill the location ID that I hardcoded in the dropdown?
  2. Create order
  3. Create payment

I’m a newbie, so sorry if I’m asking basic questions

No, location ids will never change.

Hardcoding is technically fine, although it limits you, so I would still recommend pulling the location from the API. If the merchant(s) wants to change locations, you’d need to account for that, and if you’re hardcoding that would be difficult or a bad experience from a seller’s point of view.

1 Like

may i know where any way to switch the main location?
for example, i have 3 locations, currently the 1st one is main location but i want to use the 3rd one as main location

Currently there isn’t a way to select the main location. It will always be the oldest active location of the Square account. :slightly_smiling_face: