Script Valley
REST API Development: Complete Course from Beginner to Production
API Basics: What Are APIs and Why They MatterLesson 1.3

HTTP Methods: GET, POST, PUT, DELETE, and More

GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, HTTP methods, idempotent, safe methods, CRUD mapping

HTTP Methods: GET, POST, PUT, DELETE, and More

HTTP methods tell the server what action to perform on a resource. REST API design maps these methods to CRUD operations โ€” Create, Read, Update, Delete โ€” creating a uniform, predictable interface that any developer can understand without reading custom documentation.

DiagramHTTP Methods and CRUD Mapping

IMAGE PROMPT (replace this block with your generated image):

Clean flat table-style infographic on white background. Title: HTTP Methods and CRUD Operations. Five rows, each a rounded pill or row card. Row 1: Badge GET (filled #3A5EFF, white text) | CRUD label Read | Example: GET /users or GET /users/42 | Safe: Yes | Idempotent: Yes | Returns: 200 OK. Row 2: Badge POST (filled #22c55e, white text) | Create | POST /users | Safe: No | Idempotent: No | Returns: 201 Created. Row 3: Badge PUT (filled #f59e0b, white text) | Replace | PUT /users/42 | Safe: No | Idempotent: Yes | Returns: 200 OK. Row 4: Badge PATCH (filled #8b5cf6, white text) | Partial Update | PATCH /users/42 | Safe: No | Idempotent: Yes | Returns: 200 OK. Row 5: Badge DELETE (filled #ef4444, white text) | Delete | DELETE /users/42 | Safe: No | Idempotent: Yes | Returns: 204 No Content. Column headers in bold. White background, alternating row tints using very light #3A5EFF tint (#f5f7ff).

GET: Reading Data

GET requests retrieve data from the server. They must never modify data. GET requests are both safe (no side effects) and idempotent (calling the same request multiple times produces the same result). Examples: GET /users returns a list of all users. GET /users/42 returns the specific user with ID 42. GET requests never have a request body โ€” all parameters go in the URL.

POST: Creating Data

POST requests submit data to the server to create a new resource. They are neither safe nor idempotent โ€” calling the same POST request twice creates two separate resources. The new resource's data is sent in the request body as JSON. A successful POST typically returns status 201 Created with the newly created resource in the response body and a Location header pointing to the new resource's URL.

PUT: Replacing Data

PUT requests replace an entire resource with the data in the request body. If the resource does not exist, some implementations will create it. PUT is idempotent โ€” sending the same PUT request multiple times always results in the same state. Use PUT when the client sends the complete representation of the resource.

PATCH: Partially Updating Data

PATCH requests apply a partial update to a resource. Only the fields included in the request body are modified. PATCH is more efficient than PUT when updating a single field in a large object because you do not need to send the entire resource.

PATCH /api/users/42
{
  "email": "newemail@example.com"
}

DELETE: Removing Data

DELETE requests remove a resource. A successful deletion typically returns status 204 No Content with no response body, or 200 OK with a confirmation message. DELETE is idempotent: deleting the same resource twice should not cause an error.

HEAD and OPTIONS

HEAD works exactly like GET but returns only the headers, not the body. It is used to check if a resource exists or to get its metadata without downloading its content. OPTIONS returns the HTTP methods allowed on a specific endpoint. Browsers use OPTIONS for CORS preflight checks โ€” automatically sent before cross-origin requests to verify permissions.

Up next

HTTP Status Codes Every API Developer Must Know

Sign in to track progress

HTTP Methods: GET, POST, PUT, DELETE, and More โ€” API Basics: What Are APIs and Why They Matter โ€” REST API Development: Complete Course from Beginner to Production โ€” Script Valley โ€” Script Valley