Script Valley
REST API Development: Beginner to Production
HTTP Foundations and REST PrinciplesLesson 1.3

HTTP methods โ€” GET POST PUT PATCH DELETE explained

GET semantics, POST semantics, PUT vs PATCH, DELETE, idempotency, safe methods, method choosing rules

HTTP Methods and Their Semantics

Choosing the wrong HTTP method is the most common REST design mistake. Each method carries a defined semantic contract that clients, caches, and proxies rely on.

Method Definitions

GET โ€” Retrieve a resource. Safe and idempotent. Never modify state with GET.

POST โ€” Create a resource or trigger an action. Not idempotent. Calling twice creates two resources.

PUT โ€” Replace a resource entirely. Idempotent. Calling twice has the same result as calling once.

PATCH โ€” Partially update a resource. Send only the fields that change.

DELETE โ€” Remove a resource. Idempotent.

// PATCH โ€” update only the email field
PATCH /users/42
Content-Type: application/json

{ "email": "alice@new.com" }

// PUT โ€” replace entire user object
PUT /users/42
Content-Type: application/json

{ "name": "Alice", "email": "alice@new.com", "role": "admin" }

Idempotency Rule

An operation is idempotent when calling it N times produces the same result as calling it once. GET, PUT, DELETE, and PATCH are idempotent. POST is not. This matters for retry logic โ€” safe to retry idempotent methods on network failure; dangerous to retry POST blindly.

Up next

REST resource naming and URL design best practices

Sign in to track progress

HTTP methods โ€” GET POST PUT PATCH DELETE explained โ€” HTTP Foundations and REST Principles โ€” REST API Development: Beginner to Production โ€” Script Valley โ€” Script Valley