SteelReed

Search

Search posts, questions…

Web & REST APIQuestion 7 / 25

Junior

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.

createddeletedmissing or bad tokenno permissionserver errorrequest outcome201 + Location204 No Content4014035xx: retry + backoff

3 points to say:

  1. 201 with a Location header pointing at the new resource; 204 for success with no body.
  2. 401 missing/bad token; 403 authenticated but not allowed.
  3. 4xx: the client fixes the request before resending; 5xx may be retried with backoff; 429 comes with Retry-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.