Customers API

Manage Customers and Integrate With Other Services

The Customers API lets you programmatically manage customer profiles in a Square account. This includes creating, looking up, updating, and removing a customer profile. As such, the API lets applications integrate relevant customer information with other services to provide seamlessly transaction experiences for both sellers and their customers. For example, you can link a customer to a order to make the order searchable by the customer ID. You can also save customer's cards on file for contactless payments for future and recurring transactions.

Requirements and limitations
Permalink Get a link to this section

  • Email receipts ask customers whether their experience was positive or negative. Customer objects returned by the API do not include this customer experience data on payments.

  • The Customers API cannot be used to send emails to customers.

  • The Customers API does not check for duplicate records during profile creation.

  • The Customers API cannot link customers to payments processed through the Checkout API.

  • The Customers API cannot filter customer records by location or the employee who created the record.

Product components
Permalink Get a link to this section

The Customers API works with the following primary data types:

  • Customer. Represents a single customer profile and contains contact information such as name, address, email, and phone number. It can also have one or more associated cards on file.

  • Address. A collection of strings representing a physical address.

  • CustomerGroup. Represents a group of customer profiles created explicitly.

  • CustomerSegment. Represents a group of customer profiles matching one or more predefined filter criteria.

  • CustomerPreferences. Represents a customer's preference for receiving marketing emails and contains a single field that can have a true or false value.

A Customer object needs at least one of the following:

  • A first or last name.

  • The name of the company where the customer works.

  • An email address. Email addresses must have the @ symbol and a valid domain.

  • A phone number. Phone numbers must have a valid area code and 9 – 15 numbers. Square uses the libphonenumber library from Google to validate phone numbers.

Customer objects can also contain:

  • An address.

  • A note about the customer that the Customers API has read and write access to its text value. This is not the same as the rich Notes feature on the Square Seller Dashboard, which does not provide any API access.

  • A reference ID to associate the customer with an entity in another system.

Note that the CreateCustomer endpoint permits creating duplicate customer profiles. Before creating a new customer profile, you should call the SearchCustomers endpoint to search by phone number, email address, or reference ID to determine whether a profile of the customer already exists.

Sorting and searching customer profiles
Permalink Get a link to this section

The Customers API provides two ways to return a list of customers:

  • ListCustomers returns an unfiltered list of customer profiles in sorted order.

  • SearchCustomers returns a filtered list of customer profiles in sorted order.

Sorting
Permalink Get a link to this section

By default, customer profiles are sorted alphanumerically by concatenating the name files. If neither name field is set, the following fields are compared in order: company_name, email, and phone_number.

Searching
Permalink Get a link to this section

The SearchCustomers endpoint accepts one or more supported query filters to search for customer profiles. Supported query filters are based on the creation source, create date, update date, IDs of groups, email address, and phone number.

When multiple filter criterion are provided, they are combined as an and statement. For example, consider the following set of customer profiles, all of which were updated in the last week:

  • Customer A. Their profile was created one year ago through an eCommerce site using the Customers API.

  • Customer B. Their profile was created two months ago through an eCommerce site using the Customers API.

  • Customer C. Their profile was created two weeks ago through the Square Point of Sale application.

A customer query that includes the following restrictions only returns the Customer B profile, because it is the only profile that satisfies all three filters:

  • Include customer profiles created through the Customers API.

  • Include customer profiles created in the last six months.

  • Include customer profiles updated in the last week.

A customer query that includes the following restrictions returns the Customer A and Customer B profiles:

  • Include customer profiles created through the Customers API.

  • Include customer profiles updated in the last week.

A customer query that only filters profiles based on the last update date returns all three customer profiles:

  • Include customer profiles updated in the last week.

Retrieving a customer profile by ID
Permalink Get a link to this section

You can use the Customers API to retrieve a customer profile of a given customer_id.

When duplicate customer profiles are identified and merged, either manually or by way of automated detection, the existing profiles are merged into a single profile with a new customer_id. If you specify any of the old customer_id values to retrieve the customer profile, you receive the merged profile of the new customer_id.

For example, if customer profiles with customer_id_a (A) and customer_id_b (B) are merged, a new customer profile with customer_id_c (C) is created. If you call the Customers API to retrieve either customer profile A or B, you get customer profile C.

Instant profiles
Permalink Get a link to this section

Instant profiles are customer profiles that are automatically created following a payment. The creation_source attribute of the Customer resource for an instance profile is set to INSTANT_PROFILE.

If a customer's name is collected from a payment card and a matching profile does not already exist within your directory, Square creates an instant customer profile. Future purchases made with that card update the customer's profile with new payment details and other activity with your business.

While instant profiles can be merged with manually created customer profiles in the Square Seller Dashboard, merging does not retroactively link completed transactions to the newly created profile (the customer_id field is still empty).

Customer profiles and cash transactions
Permalink Get a link to this section

The Square Point of Sale application attempts to implicitly link cash tenders to existing customer profiles based on the provided receipt email or phone number. Implicit links to customer profiles shows up in the Square Point of Sale application and the Square Seller Dashboard.