If you are modelling a resource which can be created in multiple ways, how do you best deal with that?
I can imagine doing POST to the same resource with a query param differentiating the different ways, something like
POST /logins?type=pwd with body { email, pwd } -> CREATED /logins/1
POST /logins?type=token with body { token } -> CREATED /logins/2
I think that a single POST /logins
should be enough. It can be called with a payload containing {email, pwd}
or {token}
only. The implementation of this endpoint should decide in which case we are and how to create the resource after making the necessary validation on the body (email + pwd provided or token only provided).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With