Repaso
Español
Backend & APIsCoreAPI-04

A successful POST /users that creates a user should ideally return…

Options

  1. 200 OK with an empty body and no extra headers
  2. 201 Created with a Location header for the new resource (Correct option)
  3. 204 No Content with no body and no headers
  4. 302 Found with a redirect to the list of users

Answer

201 Created with a Location header pointing to the new resource

Why

201 Created tells the client precisely that something new was created.

The Location header gives the URL of the new resource (e.g. /users/42), and the body usually contains the created user.

200 means generic success; 204 means success with no body (common for DELETE).

Remember

Created something → 201 + Location.

Key terms

Practice this question in Repaso