Trying to find a way how to integrate Magento 2 via cURL to search for a customer.

For Example the below command is able to bring the customer details of 8

curl -X GET "http://example.com/index.php/rest/V1/customers/8" 
     -H "Authorization: Bearer myaccesstoken"

In the similar fashion how can I construct the search URL with Search Criteria

I spent a day with this website and no luck.

curl -X GET http://example.com/index.php/rest/V1/customers/search 
     -H "Authorization: Bearer xxxxxxx" 
     -d '{"searchCriteria":{"filterGroups":[{"filters":[{"field":"email","value":"[email protected]","condition_type":"eq"}]}]}}'

And I got the error

{"message":"%fieldName is a required field.","parameters":{"fieldName":"searchCriteria"}}

There is something wrong in my request...

  • cyrillschumacher.com/2015/01/02/…
    – B00MER
    Commented Jan 19, 2016 at 14:37
  • @B00MER i spent a day with the website and no luck... Update my question with few code snippet now. Commented Jan 19, 2016 at 14:43
  • Sorry didn't realize you had already posted this link in your question, added an answer.
    – B00MER
    Commented Jan 19, 2016 at 15:27

2 Answers 2


Finally after 3 days of struggle got the answer how to put the search criteria in cURL

curl -X GET "http://example.com/index.php/rest/V1/customers/search
    &searchCriteria[filterGroups][0][filters][0][value][email protected]
    -H "Authorization: Bearer xxxxxx" 
    -H "Content-type: application/json" -g 

The above command will just connect to my store and search for the customer who is having the exact email address.


Try a JSON Request like so:


...and for further reference:

  • @BOOMER Sorry, i dont have any clue how to use this JSON along with the curl. The magento document says GET, but the example shows PUT... Is it possible to put a full URL like the one I asked in my question. Commented Jan 19, 2016 at 15:37
  • Updated to one liner
    – B00MER
    Commented Jan 19, 2016 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.