Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is correct REST API Status Code for user did not exist

Tags:

node.js

Status code for object not found. I'm making GET users/57 REST API call and this user(id=57) doesn't exist. Shall I use 404 Status or what can be the status code used for this?

like image 869
Babu Balakrishnan Avatar asked Oct 28 '25 16:10

Babu Balakrishnan


1 Answers

I would use error code 401 for unknown user, and not 404. 404 means the resource (IE the API endpoint) was not found.

401: Either you need to provide authentication credentials, or the credentials provided aren't valid.

like image 144
andrebruton Avatar answered Oct 31 '25 06:10

andrebruton