Which status codes should a REST API return for create, delete, auth failures and server errors?
Short answer
Creating returns 201 Created with Location, a successful delete returns 204 No Content. 401 means not authenticated, 403 means we know who you are but you lack permission.
3 points to say:
201with aLocationheader pointing at the new resource;204for success with no body.401missing/bad token;403authenticated but not allowed.4xx: the client fixes the request before resending;5xxmay be retried with backoff;429comes withRetry-After.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.