SyntaxStudy
Sign Up
REST API 2xx and 3xx Status Codes
REST API Beginner 1 min read

2xx and 3xx Status Codes

HTTP status codes communicate the result of a request in a machine-readable way. The 2xx range indicates success: 200 OK is the generic success, 201 Created should be returned after a successful POST that creates a resource (with a Location header pointing to the new resource), and 204 No Content is correct for DELETE and PUT requests that return no body. The 3xx range handles redirection. 301 Moved Permanently tells clients and search engines to update their bookmarks; 302 Found is a temporary redirect. 304 Not Modified is the conditional GET response that tells the client its cached copy is still fresh.
Example
# 200 OK — general success (GET, PUT, PATCH that return body)
HTTP/1.1 200 OK
Content-Type: application/json
{ "id": 42, "name": "Alice" }

# 201 Created — resource was created (POST)
HTTP/1.1 201 Created
Location: /users/42
Content-Type: application/json
{ "id": 42, "name": "Alice", "email": "alice@example.com" }

# 202 Accepted — request accepted, processing async
HTTP/1.1 202 Accepted
Location: /jobs/abc123
{ "jobId": "abc123", "status": "queued", "checkUrl": "/jobs/abc123" }

# 204 No Content — success with no body (DELETE, some PUT/PATCH)
HTTP/1.1 204 No Content

# 206 Partial Content — range request (video streaming, large downloads)
HTTP/1.1 206 Partial Content
Content-Range: bytes 0-1023/50000
Content-Length: 1024

# 301 Moved Permanently — update all links
HTTP/1.1 301 Moved Permanently
Location: https://api.example.com/v2/users/42

# 302 Found — temporary redirect
HTTP/1.1 302 Found
Location: /login

# 304 Not Modified — use cached version
HTTP/1.1 304 Not Modified
ETag: "abc123"