I prefer:
HEAD /users/email/[email protected]
Explanation: You are trying to find through all the users someone that are using the e-mail [email protected]
. I'm assuming here that the e-mail is not the key of your resource and you would like to have some flexibility on your endpoint, because if you need another endpoint to check availability of another information from the user (like username, number, etc) , this approach can fit very well:
HEAD /users/email/[email protected]
HEAD /users/username/foobar
HEAD /users/number/56534324
As response, you only need to return 200
(exists, so it's not available) or 404
(not exists, so it's available) as http code response.
You can also use:
HEAD /emails/[email protected]
if the HEAD /users/email/[email protected]
conflict with an existing rest resource, like a GET /users/email/[email protected]
with a different business rule. As described on Mozilla's documentation:
The HEAD method asks for a response identical to that of a GET request, but without the response body.*.
So, have a GET
and HEAD
with different rules is not good.
A HEAD /users/[email protected]
is a good option too if the e-mail is the "key" of the users
, because you (probably) have a GET /users/[email protected]
.