Field Manual PHP / Laravel reference
← HTTP / API

Status codes

Status codes summarize the HTTP outcome.

What it is

Status codes summarize the HTTP outcome.

When to use it

Use consistent responses clients can interpret.

Syntax

200 OK
201 Created
204 No Content
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
409 Conflict
422 Unprocessable Content
429 Too Many Requests
500 Internal Server Error

Example

// Laravel:
return response()->json(["id" => $order->id], 201)
    ->header("Location", route("orders.show", $order));

Common mistakes

401 means missing/invalid authentication, 403 means forbidden; do not leak object existence unnecessarily.

Related topics

Browse HTTP / API