HTTP methods tell the server what kind of action the client wants. REST maps these to resource operations: read, create, full replace, partial update, delete.
Method semantics at a glance
flowchart TB
subgraph Safe["Safe (read-only)"]
GET[GET - Read]
end
subgraph Idempotent["Idempotent (same result if repeated)"]
PUT[PUT - Replace]
DELETE[DELETE - Remove]
end
subgraph NonIdempotent["Non-idempotent (can create new)"]
POST[POST - Create / action]
PATCH[PATCH - Partial update]
end
Method
Typical use
Body
Idempotent?
Safe?
GET
Read resource(s)
No
Yes
Yes
POST
Create or custom action
Yes
No
No
PUT
Replace resource (full)
Yes
Yes
No
PATCH
Partial update
Yes
Often
No
DELETE
Remove resource
Optional
Yes
No
PUT vs PATCH
PUT replaces the whole resource: same URL, same body → same result (idempotent). PATCH sends only changed fields; repeating the same PATCH can be idempotent if the operation is defined that way (e.g. “set status to X”).
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: PUT /users/1 - full replace
C->>S: { "name":"Alice", "email":"a@b.com" }
S->>S: Replace entire user
S-->>C: 200 OK
Note over C,S: PATCH /users/1 - partial update
C->>S: { "email":"new@b.com" }
S->>S: Update only email
S-->>C: 200 OK