The Locations API allows you to manage the physical locations of a Square seller. Each location can have its own configuration, including receipt layouts, item prices, and sales reports.
Overview
The Locations client provides methods to:
List all locations
Create new locations
Retrieve location details
Update location information
Client Initialization
import (
" context "
" github.com/square/square-go-sdk/v3 "
" github.com/square/square-go-sdk/v3/core "
)
client := square . NewClient (
& core . RequestOptions {
Token : "YOUR_ACCESS_TOKEN" ,
},
)
Methods
List Locations
Retrieves all locations for a seller, including inactive locations. Locations are listed alphabetically by name.
locations/client/client.go
response , err := client . Locations . List ( context . TODO ())
if err != nil {
// Handle error
}
for _ , location := range response . Locations {
fmt . Printf ( "Location: %s (ID: %s ) \n " , * location . Name , * location . ID )
}
The context for the request
Array of location objects The unique identifier for the location
The physical address of the location
The IANA timezone identifier (e.g., “America/Los_Angeles”)
The current status: ACTIVE or INACTIVE
Square features enabled for this location
Create Location
Creates a new location for the seller. Locations created via the API are permanent and visible to the seller.
locations/client/client.go
request := & square . CreateLocationRequest {
Location : & square . Location {
Name : square . String ( "Midtown" ),
Address : & square . Address {
AddressLine1 : square . String ( "1234 Peachtree St. NE" ),
Locality : square . String ( "Atlanta" ),
AdministrativeDistrictLevel1 : square . String ( "GA" ),
PostalCode : square . String ( "30309" ),
},
Description : square . String ( "Midtown Atlanta store" ),
},
}
response , err := client . Locations . Create ( context . TODO (), request )
if err != nil {
// Handle error
}
fmt . Printf ( "Created location: %s \n " , * response . Location . ID )
The location object to create The name of the location (must be unique)
The physical address of the location
A description of the location
The phone number for the location
The business name for the location
The business email for the location
Get Location
Retrieves details of a single location. You can specify “main” as the location ID to retrieve the main location.
locations/client/client.go
request := & square . GetLocationsRequest {
LocationID : "LOCATION_ID" ,
}
response , err := client . Locations . Get ( context . TODO (), request )
if err != nil {
// Handle error
}
fmt . Printf ( "Location: %s \n " , * response . Location . Name )
The ID of the location to retrieve. Use “main” to get the main location.
Update Location
Updates an existing location’s information.
locations/client/client.go
request := & square . UpdateLocationRequest {
LocationID : "LOCATION_ID" ,
Location : & square . Location {
Name : square . String ( "Updated Name" ),
Description : square . String ( "Updated description" ),
},
}
response , err := client . Locations . Update ( context . TODO (), request )
if err != nil {
// Handle error
}
The ID of the location to update
The location object with updated fields
Response Types
Location
Represents a physical business location.
Square-assigned unique identifier
The location name (appears in the Seller Dashboard)
Enabled Square features (e.g., CREDIT_CARD_PROCESSING, AUTOMATIC_TRANSFERS)
Creation timestamp in RFC 3339 format
The ID of the merchant that owns the location
Two-letter country code (ISO 3166)
Error Handling
response , err := client . Locations . Get ( context . TODO (), request )
if err != nil {
// Check for API errors
if response != nil && len ( response . Errors ) > 0 {
for _ , e := range response . Errors {
fmt . Printf ( "Error: %s - %s \n " , e . Category , e . Detail )
}
}
return err
}