MockFoxAdvertise

HTTP 201 Created

Updated Free mock REST & WebSocket APIs

HTTP 201 Created — The request succeeded and created a new resource, usually identified by the Location header.

Class
2xx Success
Defined in
RFC 9110 §15.3.2
Official
Yes (IANA registry)
Cacheable by default
No (unless Cache-Control/Expires say so)

Try it: get a real 201 response

Our test endpoint answers every request with 201 Created.

curl -i https://mockfox.dev/api/status/201

Use it in tests, health-check monitors or to see how your client handles a 201. Add ?delay=2000 to slow it down.

What does HTTP 201 mean?

201 Created means the request succeeded and resulted in one or more new resources. The primary new resource is identified by the Location response header (or, if absent, the request URL itself).

The response body usually contains a representation of the new resource — including server-generated fields such as id and createdAt — so the client doesn't need a second request.

When is 201 used?

  • POST to a collection creates an item: POST /users → 201 with Location: /users/42.
  • PUT to a URL that didn't exist yet creates it (if PUT updates an existing resource, use 200 or 204).
  • Uploading a file creates a new stored object.

Why you're seeing 201

  • The server created the resource successfully — this is a success status, not an error.

What to do about 201

If you're visiting the site

  1. Nothing to do: 201 confirms your submission created something (an account, an order, a post).

If you run the site or API (developers)

  1. Include a Location header with the URL of the new resource.
  2. Return the created object in the body, with its id, so clients can update their UI immediately.
  3. If creation happens later in a background job, return 202 Accepted instead — 201 means the resource exists now.
  4. For idempotent retries, consider an Idempotency-Key header so a retried POST doesn't create duplicates (and return the original 201 or a 409).

Sending 201: server examples

Express

app.post("/api/users", async (req, res) => {
  const user = await db.users.create(req.body);
  res.status(201).location(`/api/users/${user.id}`).json(user);
});

Next.js

// app/api/example/route.ts (Next.js App Router)
export async function POST(req: Request) {
  const user = await createUser(await req.json());
  return Response.json(user, {
    status: 201,
    headers: { Location: `/api/users/${user.id}` },
  });
}

fetch (client)

const res = await fetch("/api/users", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name: "Ada" }),
});
if (res.status === 201) console.log("created at", res.headers.get("Location"));

Example 201 response

HTTP/1.1 201 Created
Location: /api/users/42
Content-Type: application/json; charset=utf-8

{"id":42,"name":"Ada","createdAt":"2026-10-18T10:00:00Z"}

Related status codes

Related tools

Frequently asked questions

Should a 201 response include a body?

It's optional, but returning the created resource is a widely followed convention (and what most API clients expect). At minimum send the Location header.

201 or 200 for POST?

Use 201 when the POST creates a resource. Use 200 when a POST performs an action that doesn't create anything addressable, like a search or a calculation.

201 or 202?

201 means the resource already exists when you respond. 202 Accepted means you've queued the work and it may complete (or fail) later.