REST API Response Codes

1xx – Informational

100 Continue

The server has received the request headers and the client should proceed to send the request body.

When to use

Used when the client sends large payloads and waits for server approval.

ExampleContinue sending request body.
101 Switching Protocols

The server is switching protocols as requested by the client.

When to use

Used during protocol upgrades like HTTP to WebSocket.

ExampleSwitching to WebSocket protocol.

2xx – Success

200 OK

The request was successful.

When to use

Standard response for successful GET, PUT, DELETE.

ExampleRequest completed successfully.
201 Created

A new resource was successfully created.

When to use

Use after successful POST requests.

ExampleUser created successfully.
202 Accepted

The request has been accepted for processing but not completed.

When to use

Use for async or background processing.

ExampleRequest accepted and will be processed later.
204 No Content

The request was successful but there is no response body.

When to use

Use after successful DELETE operations.

ExampleOperation successful. No content returned.

3xx – Redirection

301 Moved Permanently

The resource has been permanently moved to a new URL.

When to use

Use when URLs change permanently.

ExampleResource moved permanently.
302 Found

The resource is temporarily located at a different URL.

When to use

Temporary redirects.

ExampleResource temporarily moved.
304 Not Modified

The cached version of the resource is still valid.

When to use

Used with caching mechanisms.

ExampleCached version is valid.
307 Temporary Redirect

Temporary redirect without changing HTTP method.

When to use

Temporary redirects preserving request method.

ExampleTemporarily redirected.
308 Permanent Redirect

Permanent redirect without changing HTTP method.

When to use

Permanent redirects preserving request method.

ExamplePermanently redirected.

4xx – Client Errors

400 Bad Request

Invalid request syntax or data.

When to use

Validation or malformed request errors.

ExampleInvalid request payload.
401 Unauthorized

Authentication is required.

When to use

Missing or invalid authentication token.

ExampleAuthentication required.
403 Forbidden

User is authenticated but not authorized.

When to use

Access control violations.

ExampleAccess denied.
404 Not Found

The requested resource does not exist.

When to use

Invalid or missing endpoint.

ExampleResource not found.
405 Method Not Allowed

HTTP method is not supported for this endpoint.

When to use

Wrong HTTP method used.

ExampleMethod not allowed.
408 Request Timeout

The client took too long to send the request.

When to use

Client-side delays.

ExampleRequest timed out.
409 Conflict

Request conflicts with the current state of the resource.

When to use

Duplicate entries or version conflicts.

ExampleResource conflict detected.
413 Payload Too Large

Request entity is too large.

When to use

File upload size exceeded.

ExamplePayload too large.
415 Unsupported Media Type

Unsupported request content type.

When to use

Invalid Content-Type header.

ExampleUnsupported media type.
422 Unprocessable Entity

Validation errors in the request.

When to use

API validation failures.

ExampleValidation error.
429 Too Many Requests

Rate limit exceeded.

When to use

API throttling.

ExampleToo many requests. Try again later.

5xx – Server Errors

500 Internal Server Error

Generic server failure.

When to use

Unexpected server errors.

ExampleSomething went wrong.
501 Not Implemented

The server does not support the requested functionality.

When to use

Feature not implemented.

ExampleFeature not supported.
502 Bad Gateway

Invalid response from upstream server.

When to use

API gateway failures.

ExampleBad gateway response.
503 Service Unavailable

Server is temporarily unavailable.

When to use

Maintenance or overload.

ExampleService unavailable.
504 Gateway Timeout

Upstream server failed to respond in time.

When to use

Timeouts between services.

ExampleGateway timeout.