401 Unauthorized means "I do not know who you are": no credentials, an expired token or a wrong password. Despite its name, it is about authentication. The response should include a WWW-Authenticate header, and the client may retry after logging in.
403 Forbidden means "I know who you are, but you are not allowed to do this". Logging in again will not help. Your user needs a different role or permission.
So for a logged-in user who lacks permission, 403 is correct. If the token were missing or expired, 401 would be correct.
Related codes worth knowing: 404 (not found), 409 (conflict), 422 (validation failed) and 429 (too many requests). Some APIs return 404 instead of 403 on purpose, to avoid revealing that a secret resource exists.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
So for a logged-in user who lacks permission, 403 is correct. If the token were missing or expired, 401 would be correct.
Related codes worth knowing: 404 (not found), 409 (conflict), 422 (validation failed) and 429 (too many requests). Some APIs return 404 instead of 403 on purpose, to avoid revealing that a secret resource exists.