Applies to: Customers API | Cards API | Terminal API | Web Payments SDK | In-App Payments SDK | Payments API
Learn more about how the Customers API processes information.
The Customers API is a RESTful web service hosted on Square servers. You can use the Customers API to create and manage customer profiles for Square sellers, including membership in customer groups.
Creating a customer profile typically includes the following steps:
-
The frontend collects customer information with the customer's consent using a form created by the developer. Square doesn't provide a prebuilt form for this purpose. For more information, see Best Practices for Collecting Information.
-
The backend packages the customer's phone number or email address as a
SearchCustomersrequest object and sends it to the SearchCustomers endpoint. This step is recommended to avoid creating duplicate customer profiles. -
Square processes the request:
- If the request succeeds, Square returns a list of matching
Customerobjects or an empty object ({}) if none are found. - If the request fails, Square returns any errors that occurred as an
Error[].
- If the request succeeds, Square returns a list of matching
-
If no matching customer profiles are found, the backend packages the customer information as a
CreateCustomerrequest object and sends it to the CreateCustomer endpoint. -
Square processes the request:
- If the request succeeds, Square returns a
Customerobject and invokes acustomer.createdwebhook event. - If the request fails, Square returns any errors that occurred as an
Error[].
- If the request succeeds, Square returns a
-
The frontend displays results for the customer.

For more information about creating and managing customer profiles, including example requests and responses, see Manage Customer Profiles. Or, check out the getCustomerID function in the Bookings API Sample App (Node.js) to see a sample implementation of this workflow.
Warning
Using the Customers API to manage credit and debit cards on file is deprecated. To save a card on file, you should use CreateCard in the Cards API or CreateTerminalAction in the Terminal API. For more information, see the deprecated CreateCustomerCard endpoint migration notes.
You can save a card on file for a particular customer by sending a card_nonce and customer_id to the CreateCustomerCard endpoint (deprecated). You can then use the returned card ID to process payments. The Web Payments SDK or In-App Payments SDK, Customers API, and CreatePayment endpoint from the Payments API work together to process card-on-file payments.
Important
Your application must use the Web Payments SDK or In-App Payments SDK to collect card information.
Saving a card on file typically includes the following steps:
-
The frontend uses the Web Payments SDK or In-App Payments SDK to collect card information and generate a secure payment token. The frontend should also collect contact information for the customer at this point. Customers must consent to saving their card and contact information.
-
The backend packages the contact information as a
CreateCustomerrequest object and sends it to the CreateCustomer endpoint. -
Square returns a
Customerobject with anid. This value is used as thecustomer_idin theCreatePaymentrequest. -
The backend packages a
CreateCustomerCardrequest object containing thecustomer_idandcard_nonceand sends it to the CreateCustomerCard endpoint (deprecated). Thecard_noncevalue is the payment token generated in step 1. -
Square returns a
CustomerCardobject with anid. This value is used as thecustomer_card_idin theCreatePaymentrequest. -
The backend packages a
CreatePaymentrequest object with thecustomer_card_idand acustomer_idand sends it to the CreatePayment endpoint.To link a customer to a payment or save a card on file, you must create or retrieve a customer profile before packaging the
CreatePaymentrequest. Customer profiles cannot be linked to completed payments.
