Suppose that I've an API that publishes a post in my Facebook account. What HTTP code should I return if the user hasn't linked yet his FB account with my API server (it's just an example)? I found "412 Precondition Failed" but I think that this is not the right use case. So what is the best HTTP code for telling that you should do an action first?

EDIT: just to help who will read this post; I've found a nice article that helps to choose the right HTTP status code. https://www.loggly.com/blog/http-status-code-diagram/

  • I usually return 400 with a good message ...
    – luistm
    Jul 18, 2019 at 9:40
  • 1
    400 is used for "bad request". Actually the request is well formed but the condition is not satisfied. Jul 18, 2019 at 9:44

1 Answer 1


The response code "409 Conflict" appears to be the best matching code. The description states

The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough information for the user to recognize the source of the conflict.

The response should tell the user that they need to link a Facebook account to resolve the conflict state and be able to successfully re-submit the request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.