rest - RESTful API PUT/PATCH to flip boolean -


what proper way flip boolean on restful api?

consider, example, users/toggle_middle_name endpoint. default, each user not have or middle name displayed, unless opted in hitting endpoint.

obviously, not get endpoint, you'd writing information database. but, in patch/put request, it's general understanding 1 should send parameters, signifying data being set to. so, example, 1 send {show_middle_name: true}. since boolean being flipped server-side, ideally, wouldn't need know whether send true or false prior call. hit endpoint, , flips 1 other, without value being sent.

the question becomes, okay hit put/patch endpoint without parameters, , return result in response? or parameter-less put/patch api calls discouraged? why or why not?

simply said: don't

in opinion there should no specialized resource flipping boolean because boolean in not define self contained entity.

instead make attribute of user , patch on /users/john_doe

{   "show_middle_name": true/false } 

as comment jonrsharpe applies.