Stripe, is it possible to search a customer by their email?

Stripe now allows you to filter customers by email.

https://stripe.com/docs/api#list_customers

Map<String, Object> options = new HashMap<>();
options.put("email", email);
List<Customer> customers = Customer.list(options).getData();

if (customers.size() > 0) {
    Customer customer = customers.get(0);
    ...

This is important to help ensure you don't create duplicate customers. Because you can't put creating a customer in Stripe and the storage of the Stripe customer ID in your system inside a single transaction you need to build in some fail safes that check to see if a particular customer exists before you create a new one. Searching customers by email is important in that regard.


You need to retrieve and store the Stripe customer ID along with the other customer details in your database. You can then search for the email address in your database and retrieve the customer record from Stripe by using the Stripe customer ID.


I did this by using the following API request. This was not available in stripe docs.I got this by tracking down their search in the dashboard area using Browser Developer Tools.

    url :https://api.stripe.com/v1/search?query="+email+"&prefix=false",
    method: GET
    headers: {
      "authorization": "Bearer Your_seceret Key",
      "content-type": "application/x-www-form-urlencoded",
    }

Warning This uses an undocumented API that is specific to the dashboard. While it might work today, there is no guarantee it will continue to work in the future.