FROM CACHE - en_header

Find a Customer by Email via API Call

Rich_Borek
Shopify Partner
58 0 12

Hey Guys,

In todays ever expanding market email is beginning to surpass phone number as the preferred method to uniquely identify a person, just go to your local big box store and you will see they are asking for your email not phone number.  So when tying systems together it is common to find a customer by email to link accounts, this example is for all those looking to do just that.  I myself looked here on the forums when trying to get this information so I hope this helps someone else.

Expected Result is a JSON payload like so

{ "customers": [ { "email": "name@domain.com", "id": 2116792913 } ] }

If you attempt to get this using the endpoint like so, you will get all customers on your store

store.myshopify.com/admin/customers.json?email=name@domain.com;fields=email,id

The proper way to do this is to make the call like so

store.myshopify.com/admin/customers/search.json?query=email:name@domain.com;fields=email,id

[UPDATE] Per comments below it seems both semicolon and ampersand are legal delimiters for an HTTP request so here is the other format with ampersand

store.myshopify.com/admin/customers/search.json?query=email:name@domain.com&fields=email,id

Simple and clean just like Shopify, Cheers!

Rich Borek

Efficiency through Simplicity is the only way to design...
Replies 5 (5)
Christian_Joud2
Shopify Staff (Retired)
Shopify Staff (Retired)
59 0 13

Hi Rich,

That's odd. I thought searching customers by e-mail could be done via the search.json end-point.

I'll look into this and get back to you.

- Christian

Christian_Joud2
Shopify Staff (Retired)
Shopify Staff (Retired)
59 0 13

Hi Rich,

You can use the /admin/customers/search.json end-point to find customers by e-mail.

Here's an example:

/admin/customers/search.json?query=email:"email@domain.com"&fields=id,email

Hope that answers your question!

- Christian

Rich_Borek
Shopify Partner
58 0 12

Hey Christian,

Note the second part of my post noted "The proper way to do this is to make the call like so"

The purpose of the post wasn't as much for an answer but rather answers future reuests.

Sorry for any confusion, Cheers!

Rich

Efficiency through Simplicity is the only way to design...
Christian_Joud2
Shopify Staff (Retired)
Shopify Staff (Retired)
59 0 13

Ahhh, gotcha! 🙂

I replied because there was a typo in your URL, which is why I thought it was a question: 

store.myshopify.com/admin/customers/search.json?query=email:name@domain.com;fields=email,id

The ";" should be "&" before fields.

Have a great day!

- Christian

Rich_Borek
Shopify Partner
58 0 12

Good point, didn't see the typo because it worked.  I did a little research and it seems that both are legal for delimiters see this wiki.

http://en.wikipedia.org/wiki/Query_string

for clarity I agree the "&" looks  a lot better and easier to pickup when reading.  

Good catch, Cheers!

-Rich

Efficiency through Simplicity is the only way to design...