I prefer:
HEAD /users/email/foo@bar.com
Explanation: You are trying to find through all the users someone that are using the e-mail foo@bar.com
. 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/foo@bar.com
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/foo@bar.com
if the HEAD /users/email/foo@bar.com
conflict with an existing rest resource, like a GET /users/email/foo@bar.com
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/foo@bar.com
is a good option too if the e-mail is the "key" of the users
, because you (probably) have a GET /users/foo@bar.com
.