Skip to main content
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)
}
context
context.Context
required
The context for the request
locations
[]*Location
Array of location objects

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)
location
Location
required
The location object to create

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)
locationID
string
required
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
}
locationID
string
required
The ID of the location to update
location
Location
required
The location object with updated fields

Response Types

Location

Represents a physical business location.
id
string
Square-assigned unique identifier
name
string
The location name (appears in the Seller Dashboard)
address
Address
The physical address
timezone
string
IANA timezone identifier
capabilities
[]LocationCapability
Enabled Square features (e.g., CREDIT_CARD_PROCESSING, AUTOMATIC_TRANSFERS)
status
LocationStatus
ACTIVE or INACTIVE
created_at
string
Creation timestamp in RFC 3339 format
merchant_id
string
The ID of the merchant that owns the location
country
Country
Two-letter country code (ISO 3166)
currency
Currency
Currency code (ISO 4217)

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
}

Build docs developers (and LLMs) love