When building a RESTful API and a user provides an id of resource that does not exist, should you return 404 Not Found
or 400 Bad Request
Should be 404 ( Not Found ). 400 is used if you can't fulfill the request due to bad syntax, however for your case, the syntax is correct, however there is no resource foobar.
You can use 400 if user uses non-existent API like below :
https://api.domain.com/v1/nonexistAPI/xyz/xyz
You can also refer to this REST API Design Blog which tell you how to design your REST error codes.