I am building an API where the user can ask the server to perform multiple actions in one HTTP request. The result is returned as a JSON array, with one entry per action.
Each of these actions might fail or succeed independently of each other. For instance, the first action might succeed, the input to the second action might be poorly formated and fail to validate and the third action might cause an unexpected error.
If there was one request per action, I would return status codes 200, 422 and 500 respectively. But now when there is only one request, what status code do I return?
Some options:
- Always return 200, and give more detailed information in the body.
- Maybe follow the above rule only when there is more than one action in the request?
- Maybe return 200 if all requests succeed, otherwise 500 (or some other code)?
- Just use one request per action, and accept the extra overhead.
- Something completely different?