A while back I wrote a library called rfunk. This library provides some functional programming concepts that you can give a try or contribute to if you like.
I know there are other libraries now out there and they might do a better job. Regardless I wanted to try it out to see how one might build an API that used these concepts.
Here you can find the controller that performs the action and the associated features to see it working. I think it clearly defines what a success case might be and what a failure is.
The whole repository is here if you want to check it out. Might add more features as I go along. I hope you enjoy it!