Pick the fix
A logged-in user requests another customer's invoice they may not see. Which response?
Hint 1 of 1
Is the problem who they are, or what they may do?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A 403 Forbidden, or 404 if you don't want to reveal the invoice exists
Correct. Authenticated but not allowed; 404 hides existence.
401 asks the client to authenticate and 403 says who they are is known but the answer is no. Some APIs answer 404 instead, so a caller can't probe which invoice ids exist.
Why not the others?
- B 401 Unauthorized. 401 means 'authenticate'; they already did.
- C 400 Bad Request. The request is well-formed.
- D 200 with an empty body. Hides a denial as success and confuses clients.