---
title: "SearchCustomers"
method: POST
path: "/v2/customers/search"
tags: ["Customers"]
---

# SearchCustomers

`POST /v2/customers/search`

Searches the customer profiles associated with a Square account using a supported query filter.

Calling `SearchCustomers` without any explicit query filter returns all
customer profiles ordered alphabetically based on `given_name` and
`family_name`.

Under normal operating conditions, newly created or updated customer profiles become available
for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated
profiles can take closer to one minute or longer, especially during network incidents and outages.

## Request body

- SearchCustomersRequest — Defines the fields that are included in the request body of a request to the `SearchCustomers` endpoint.
  - `cursor` string — 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/working-with-apis/pagination).
  - `limit` integer — The maximum number of results to return in a single page. This limit is advisory. The response might contain more or fewer results. The limit is ignored if it is less than the minimum or greater than the maximum value. The default value is 100. For more information, see [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination).
  - `query` CustomerQuery — Represents a query (including filtering criteria, sorting criteria, or both) used to search for customer profiles.
    - `filter` CustomerFilter — Represents a set of `CustomerQuery` filters used to limit the set of customers returned by the [SearchCustomers](https://developer.squareup.com/reference/square_2021-08-18/customers-api/search-customers) endpoint.
      - `created_at` TimeRange — Represents a generic time range. The start and end values are represented in RFC 3339 format. Time ranges are customized to be inclusive or exclusive based on the needs of a particular endpoint. Refer to the relevant endpoint-specific documentation to determine how time ranges are handled.
        - `end_at` string — A datetime value in RFC 3339 format indicating when the time range ends.
        - `start_at` string — A datetime value in RFC 3339 format indicating when the time range starts.
      - `creation_source` CustomerCreationSourceFilter — The creation source filter. If one or more creation sources are set, customer profiles are included in, or excluded from, the result if they match at least one of the filter criteria.
        - `rule` string — Indicates whether a customer profile matching the filter criteria should be included in the result or excluded from the result. Default: `INCLUDE`.
        - `values` string[] — The list of creation sources used as filtering criteria.
      - `email_address` CustomerTextFilter — A filter to select customers based on exact or fuzzy matching of customer attributes against a specified query. Depending on the customer attributes, the filter can be case-sensitive. This filter can be exact or fuzzy, but it cannot be both.
        - `exact` string — Use the exact filter to select customers whose attributes match exactly the specified query.
        - `fuzzy` string — Use the fuzzy filter to select customers whose attributes match the specified query in a fuzzy manner. When the fuzzy option is used, search queries are tokenized, and then each query token must be matched somewhere in the searched attribute. For single token queries, this is effectively the same behavior as a partial match operation.
      - `group_ids` FilterValue — A filter to select resources based on an exact field value. For any given value, the value can only be in one property. Depending on the field, either all properties can be set or only a subset will be available. Refer to the documentation of the field.
        - `all` string[] — A list of terms that must be present on the field of the resource.
        - `any` string[] — A list of terms where at least one of them must be present on the field of the resource.
        - `none` string[] — A list of terms that must not be present on the field the resource
      - `phone_number` CustomerTextFilter — A filter to select customers based on exact or fuzzy matching of customer attributes against a specified query. Depending on the customer attributes, the filter can be case-sensitive. This filter can be exact or fuzzy, but it cannot be both.
        - `exact` string — Use the exact filter to select customers whose attributes match exactly the specified query.
        - `fuzzy` string — Use the fuzzy filter to select customers whose attributes match the specified query in a fuzzy manner. When the fuzzy option is used, search queries are tokenized, and then each query token must be matched somewhere in the searched attribute. For single token queries, this is effectively the same behavior as a partial match operation.
      - `reference_id` CustomerTextFilter — A filter to select customers based on exact or fuzzy matching of customer attributes against a specified query. Depending on the customer attributes, the filter can be case-sensitive. This filter can be exact or fuzzy, but it cannot be both.
        - `exact` string — Use the exact filter to select customers whose attributes match exactly the specified query.
        - `fuzzy` string — Use the fuzzy filter to select customers whose attributes match the specified query in a fuzzy manner. When the fuzzy option is used, search queries are tokenized, and then each query token must be matched somewhere in the searched attribute. For single token queries, this is effectively the same behavior as a partial match operation.
      - `updated_at` TimeRange — Represents a generic time range. The start and end values are represented in RFC 3339 format. Time ranges are customized to be inclusive or exclusive based on the needs of a particular endpoint. Refer to the relevant endpoint-specific documentation to determine how time ranges are handled.
        - `end_at` string — A datetime value in RFC 3339 format indicating when the time range ends.
        - `start_at` string — A datetime value in RFC 3339 format indicating when the time range starts.
    - `sort` CustomerSort — Specifies how searched customers profiles are sorted, including the sort key and sort order.
      - `field` string — Use one or more customer attributes as the sort key to sort searched customer profiles. For example, use the creation date (`created_at`) of customers or default attributes as the sort key. Default: `DEFAULT`.
      - `order` string — Indicates the order in which results should be sorted based on the sort field value. Strings use standard alphabetic comparison to determine order. Strings representing numbers are sorted as strings. Default: `ASC`.

## Response `200`

Success

- SearchCustomersResponse — 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).
  - `cursor` string — 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/working-with-apis/pagination).
  - `customers` Customer[] — An array of `Customer` objects that match a query.
    - `address` Address — Represents a postal address in a country. The address format is based on an [open-source library from Google](https://github.com/google/libaddressinput). For more information, see [AddressValidationMetadata](https://github.com/google/libaddressinput/wiki/AddressValidationMetadata). This format has dedicated fields for four address components: postal code, locality (city), administrative district (state, prefecture, or province), and sublocality (town or village). These components have dedicated fields in the `Address` object because software sometimes behaves differently based on them. For example, sales tax software may charge different amounts of sales tax based on the postal code, and some software is only available in certain states due to compliance reasons. For the remaining address components, the `Address` type provides the `address_line_1` and `address_line_2` fields for free-form data entry. These fields are free-form because the remaining address components have too many variations around the world and typical software does not parse these components. These fields enable users to enter anything they want. Note that, in the current implementation, all other `Address` type fields are blank. These include `address_line_3`, `sublocality_2`, `sublocality_3`, `administrative_district_level_2`, `administrative_district_level_3`, `first_name`, `last_name`, and `organization`. When it comes to localization, the seller's language preferences (see [Language preferences](https://developer.squareup.com/docs/locations-api#location-specific-and-seller-level-language-preferences)) are ignored for addresses. Even though Square products (such as Square Point of Sale and the Seller Dashboard) mostly use a seller's language preference in communication, when it comes to addresses, they will use English for a US address, Japanese for an address in Japan, and so on.
      - `address_line_1` string — The first line of the address. Fields that start with `address_line` provide the address's most specific details, like street number, street name, and building name. They do *not* provide less specific details like city, state/province, or country (these details are provided in other fields).
      - `address_line_2` string — The second line of the address, if any.
      - `address_line_3` string — The third line of the address, if any.
      - `administrative_district_level_1` string — A civil entity within the address's country. In the US, this is the state.
      - `administrative_district_level_2` string — A civil entity within the address's `administrative_district_level_1`. In the US, this is the county.
      - `administrative_district_level_3` string — A civil entity within the address's `administrative_district_level_2`, if any.
      - `country` string — The address's country, in ISO 3166-1-alpha-2 format.
      - `first_name` string — Optional first name when it's representing recipient.
      - `last_name` string — Optional last name when it's representing recipient.
      - `locality` string — The city or town of the address.
      - `organization` string — Optional organization name when it's representing recipient.
      - `postal_code` string — The address's postal code.
      - `sublocality` string — A civil region within the address's `locality`, if any.
      - `sublocality_2` string — A civil region within the address's `sublocality`, if any.
      - `sublocality_3` string — A civil region within the address's `sublocality_2`, if any.
    - `birthday` string — The birthday associated with the customer profile, in RFC 3339 format. The year is optional. The timezone and time are not allowed. For example, `0000-09-21T00:00:00-00:00` represents a birthday on September 21 and `1998-09-21T00:00:00-00:00` represents a birthday on September 21, 1998.
    - `cards` Card[] — Payment details of the credit, debit, and gift cards stored on file for the customer profile. DEPRECATED at version 2021-06-16. Replaced by calling [ListCards](https://developer.squareup.com/reference/square_2021-08-18/cards-api/list-cards) (for credit and debit cards on file) or [ListGiftCards](https://developer.squareup.com/reference/square_2021-08-18/gift-cards-api/list-gift-cards) (for gift cards on file) and including the `customer_id` query parameter. For more information, see [Migrate to the Cards API and Gift Cards API](https://developer.squareup.com/docs/customers-api/use-the-api/integrate-with-other-services#migrate-customer-cards).
      - `billing_address` Address — Represents a postal address in a country. The address format is based on an [open-source library from Google](https://github.com/google/libaddressinput). For more information, see [AddressValidationMetadata](https://github.com/google/libaddressinput/wiki/AddressValidationMetadata). This format has dedicated fields for four address components: postal code, locality (city), administrative district (state, prefecture, or province), and sublocality (town or village). These components have dedicated fields in the `Address` object because software sometimes behaves differently based on them. For example, sales tax software may charge different amounts of sales tax based on the postal code, and some software is only available in certain states due to compliance reasons. For the remaining address components, the `Address` type provides the `address_line_1` and `address_line_2` fields for free-form data entry. These fields are free-form because the remaining address components have too many variations around the world and typical software does not parse these components. These fields enable users to enter anything they want. Note that, in the current implementation, all other `Address` type fields are blank. These include `address_line_3`, `sublocality_2`, `sublocality_3`, `administrative_district_level_2`, `administrative_district_level_3`, `first_name`, `last_name`, and `organization`. When it comes to localization, the seller's language preferences (see [Language preferences](https://developer.squareup.com/docs/locations-api#location-specific-and-seller-level-language-preferences)) are ignored for addresses. Even though Square products (such as Square Point of Sale and the Seller Dashboard) mostly use a seller's language preference in communication, when it comes to addresses, they will use English for a US address, Japanese for an address in Japan, and so on.
        - `address_line_1` string — The first line of the address. Fields that start with `address_line` provide the address's most specific details, like street number, street name, and building name. They do *not* provide less specific details like city, state/province, or country (these details are provided in other fields).
        - `address_line_2` string — The second line of the address, if any.
        - `address_line_3` string — The third line of the address, if any.
        - `administrative_district_level_1` string — A civil entity within the address's country. In the US, this is the state.
        - `administrative_district_level_2` string — A civil entity within the address's `administrative_district_level_1`. In the US, this is the county.
        - `administrative_district_level_3` string — A civil entity within the address's `administrative_district_level_2`, if any.
        - `country` string — The address's country, in ISO 3166-1-alpha-2 format.
        - `first_name` string — Optional first name when it's representing recipient.
        - `last_name` string — Optional last name when it's representing recipient.
        - `locality` string — The city or town of the address.
        - `organization` string — Optional organization name when it's representing recipient.
        - `postal_code` string — The address's postal code.
        - `sublocality` string — A civil region within the address's `locality`, if any.
        - `sublocality_2` string — A civil region within the address's `sublocality`, if any.
        - `sublocality_3` string — A civil region within the address's `sublocality_2`, if any.
      - `bin` string — The first six digits of the card number, known as the Bank Identification Number (BIN). Only the Payments API returns this field.
      - `card_brand` string — The card's brand.
      - `card_type` string — The type of the card. The Card object includes this field only in response to Payments API calls.
      - `cardholder_name` string — The name of the cardholder.
      - `customer_id` string — The ID of a customer created using the Customers API to be associated with the card.
      - `enabled` boolean — Indicates whether or not a card can be used for payments.
      - `exp_month` integer — The expiration month of the associated card as an integer between 1 and 12.
      - `exp_year` integer — The four-digit year of the card's expiration date.
      - `fingerprint` string — __Not currently set.__ Intended as a Square-assigned identifier, based on the card number, to identify the card across multiple locations within a single application.
      - `id` string — Unique ID for this card. Generated by Square.
      - `last_4` string — The last 4 digits of the card number.
      - `prepaid_type` string — Indicates whether the Card is prepaid or not. The Card object includes this field only in response to Payments API calls.
      - `reference_id` string — An optional user-defined reference ID that associates this card with another entity in an external system. For example, a customer ID from an external customer management system.
      - `version` integer — Current version number of the card. Increments with each card update. Requests to update an existing Card object will be rejected unless the version in the request matches the current version for the Card.
    - `company_name` string — A business name associated with the customer profile.
    - `created_at` string — The timestamp when the customer profile was created, in RFC 3339 format.
    - `creation_source` string — A creation source represents the method used to create the customer profile.
    - `email_address` string — The email address associated with the customer profile.
    - `family_name` string — The family (i.e., last) name associated with the customer profile.
    - `given_name` string — The given (i.e., first) name associated with the customer profile.
    - `group_ids` string[] — The IDs of customer groups the customer belongs to.
    - `id` string — A unique Square-assigned ID for the customer profile.
    - `nickname` string — A nickname for the customer profile.
    - `note` string — A custom note associated with the customer profile.
    - `phone_number` string — The 11-digit phone number associated with the customer profile.
    - `preferences` CustomerPreferences — Represents communication preferences for the customer profile.
      - `email_unsubscribed` boolean — 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.
    - `reference_id` string — An optional second ID used to associate the customer profile with an entity in another system.
    - `segment_ids` string[] — The IDs of segments the customer belongs to.
    - `updated_at` string — The timestamp when the customer profile was last updated, in RFC 3339 format.
    - `version` integer — 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 and cards on file.
  - `errors` Error[] — Any errors that occurred during the request.
    - `category` string, required — The high-level category for the error.
    - `code` string, required — The specific code of the error.
    - `detail` string — A human-readable description of the error for debugging purposes.
    - `field` string — The name of the field provided in the original request (if any) that the error pertains to.

---

[API](https://skmtc.net/square/apis/squareup.md) · [All operations](https://skmtc.net/square/apis/squareup/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/square/squareup/revisions/8d95e3639487/schema)
