Square: Search Customers
Square customers.searchCustomers: arguments, response, policy and SDK examples.
← Customers operations · Get started
Operation square.searchcustomers
Provider route: POST /v2/customers/search. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/square with npm, or alter-sdk-square with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { SquareIntegration } from "@alter-ai/square";
async function execute(input: Parameters<SquareIntegration["customers"]["searchCustomers"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new SquareIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.customers.searchCustomers(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_square import SquareIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = SquareIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.customers.search_customers(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
body | Model | Required within parent | Expand Search Customers — request body — body |
Referenced models: Search Customers — request body — body
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Search Customers — response body |
Referenced models: Search Customers — response body
Schemas
Section titled “Schemas”18 more schemas are linked from the tables above, on the schema pages.
Search Customers — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Defines the fields that are included in the response body of a request to the `SearchCustomers` endpoint. Either `errors` or `customers` is present in a given response (never both). |
count | JSON | Optional | |
count (anyOf 1) | integer | Alternative | The total count of customers associated with the Square account that match the search query. Only customer profiles with public information (`given_name`, `family_name`, `company_name`, `email_address`, or `phone_number`) are counted. This field is present only if `count` is set to `true` in the request. Format: int64 |
count (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
cursor | string | Optional | A pagination cursor that can be used during subsequent calls to `SearchCustomers` to retrieve the next set of results associated with the original query. Pagination cursors are only present when a request succeeds and additional results are available. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). |
customers | array | Optional | The customer profiles that match the search query. If any search condition is not met, the result is an empty object (`{}`). Only customer profiles with public information (`given_name`, `family_name`, `company_name`, `email_address`, or `phone_number`) are included in the response. |
customers[] | Model | Each item | Expand Create Customer — response body — customer |
errors | array | Optional | Any errors that occurred during the request. |
errors[] | Model | Each item | Expand Get Shift — response body — errors item |
Referenced models: Create Customer — response body — customer, Get Shift — response body — errors item
Search Customers — request body — body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Defines the fields that are included in the request body of a request to the `SearchCustomers` endpoint. |
count | boolean | Optional | Indicates whether to return the total count of matching customers in the `count` field of the response. The default value is `false`. |
cursor | string | Optional | Include the pagination cursor in subsequent calls to this endpoint to retrieve the next set of results associated with the original query. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). |
limit | JSON | Optional | |
limit (anyOf 1) | integer | Alternative | The maximum number of results to return in a single page. This limit is advisory. The response might contain more or fewer results. If the specified limit is invalid, Square returns a `400 VALUE_TOO_LOW` or `400 VALUE_TOO_HIGH` error. The default value is 100. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination). Format: int64 Maximum: 100 Minimum: 1 |
limit (anyOf 2) | string | Alternative | Pattern: ^(?:100|[1-9][0-9]{0,1})$(?!\n) |
query | Model | Optional | Expand Search Customers — request body — body query The filtering and sorting criteria for the search request. If a query is not specified, Square returns all customer profiles ordered alphabetically by `given_name` and `family_name`. |
Referenced models: Search Customers — request body — body query
Create Customer — response body — customer
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents a Square customer profile in the Customer Directory of a Square seller. |
address | JSON | Optional | |
address (anyOf 1) | Model | Alternative | Expand Get Payment — response body — payment billing address The physical address associated with the customer profile. |
address (anyOf 2) | null | Alternative | |
birthday | JSON | Optional | |
birthday (anyOf 1) | string | Alternative | The birthday associated with the customer profile, in `YYYY-MM-DD` format. For example, `1998-09-21` represents September 21, 1998, and `0000-09-21` represents September 21 (without a birth year). |
birthday (anyOf 2) | null | Alternative | |
company_name | JSON | Optional | |
company_name (anyOf 1) | string | Alternative | A business name associated with the customer profile. |
company_name (anyOf 2) | null | Alternative | |
created_at | string | Optional | The timestamp when the customer profile was created, in RFC 3339 format. Read only: true |
creation_source | JSON | Optional | |
creation_source (anyOf 1) | string | Alternative | Indicates the method used to create the customer profile. The method used to create the customer profile. See [CustomerCreationSource](#type-customercreationsource) for possible values Known values: OTHER, APPOINTMENTS, COUPON, DELETION_RECOVERY, DIRECTORY, EGIFTING, EMAIL_COLLECTION, FEEDBACK, IMPORT, INVOICES, LOYALTY, MARKETING, MERGE, ONLINE_STORE, INSTANT_PROFILE, TERMINAL, THIRD_PARTY, THIRD_PARTY_IMPORT, UNMERGE_RECOVERY |
creation_source (anyOf 2) | null | Alternative | |
email_address | JSON | Optional | |
email_address (anyOf 1) | string | Alternative | The email address associated with the customer profile. |
email_address (anyOf 2) | null | Alternative | |
family_name | JSON | Optional | |
family_name (anyOf 1) | string | Alternative | The family name (that is, the last name) associated with the customer profile. |
family_name (anyOf 2) | null | Alternative | |
given_name | JSON | Optional | |
given_name (anyOf 1) | string | Alternative | The given name (that is, the first name) associated with the customer profile. |
given_name (anyOf 2) | null | Alternative | |
group_ids | JSON | Optional | |
group_ids (anyOf 1) | array | Alternative | The IDs of [customer groups](entity:CustomerGroup) the customer belongs to. |
group_ids (anyOf 1)[] | string | Each item | |
group_ids (anyOf 2) | null | Alternative | |
id | string | Optional | A unique Square-assigned ID for the customer profile. If you need this ID for an API request, use the ID returned when you created the customer profile or call the [SearchCustomers](api-endpoint:Customers-SearchCustomers) or [ListCustomers](api-endpoint:Customers-ListCustomers) endpoint. |
nickname | JSON | Optional | |
nickname (anyOf 1) | string | Alternative | A nickname for the customer profile. |
nickname (anyOf 2) | null | Alternative | |
note | JSON | Optional | |
note (anyOf 1) | string | Alternative | A custom note associated with the customer profile. |
note (anyOf 2) | null | Alternative | |
phone_number | JSON | Optional | |
phone_number (anyOf 1) | string | Alternative | The phone number associated with the customer profile. |
phone_number (anyOf 2) | null | Alternative | |
preferences | JSON | Optional | |
preferences (anyOf 1) | Model | Alternative | Expand Create Customer — response body — customer preferences email unsubscribed Represents general customer preferences. |
preferences (anyOf 2) | null | Alternative | |
reference_id | JSON | Optional | |
reference_id (anyOf 1) | string | Alternative | An optional second ID used to associate the customer profile with an entity in another system. |
reference_id (anyOf 2) | null | Alternative | |
segment_ids | JSON | Optional | |
segment_ids (anyOf 1) | array | Alternative | The IDs of [customer segments](entity:CustomerSegment) the customer belongs to. |
segment_ids (anyOf 1)[] | string | Each item | |
segment_ids (anyOf 2) | null | Alternative | |
tax_ids | JSON | Optional | |
tax_ids (anyOf 1) | Model | Alternative | Expand Create Customer — request body — body tax ids The tax ID associated with the customer profile. This field is present only for customers of sellers in EU countries or the United Kingdom. For more information, see [Customer tax IDs](https://developer.squareup.com/docs/customers-api/what-it-does#customer-tax-ids). |
tax_ids (anyOf 2) | null | Alternative | |
updated_at | string | Optional | The timestamp when the customer profile was last updated, in RFC 3339 format. Read only: true |
version | JSON | Optional | |
version (anyOf 1) | integer | Alternative | The Square-assigned version number of the customer profile. The version number is incremented each time an update is committed to the customer profile, except for changes to customer segment membership. Format: int64 |
version (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
Referenced models: Create Customer — response body — customer preferences email unsubscribed, Create Customer — request body — body tax ids, Get Payment — response body — payment billing address
Create Customer — response body — customer preferences email unsubscribed
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Represents communication preferences for the customer profile. |
email_unsubscribed | JSON | Optional | |
email_unsubscribed (anyOf 1) | boolean | Alternative | Indicates whether the customer has unsubscribed from marketing campaign emails. A value of `true` means that the customer chose to opt out of email marketing from the current Square seller or from all Square sellers. This value is read-only from the Customers API. |
email_unsubscribed (anyOf 2) | null | Alternative |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: square.searchcustomers. Catalog operation: SearchCustomers. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.
Required provider scopes: ["CUSTOMERS_READ"]
Pinned headers: {"Square-Version": "2026-11-18"}