What are the main HTTP methods used in REST APIs and what do they do?
Answer
REST APIs use HTTP methods to indicate the desired action on a resource. GET retrieves a resource or collection — it must be safe (no side effects) and idempotent. POST creates a new resource or triggers an action — it is neither safe nor idempotent. PUT replaces a resource entirely with the provided representation — idempotent but not safe. PATCH applies a partial update to a resource — not required to be idempotent but often is. DELETE removes a resource — idempotent (deleting an already-deleted resource returns 404 or 204). HEAD is identical to GET but returns only headers (no body) — useful for checking resource existence or metadata. OPTIONS returns the HTTP methods supported by the endpoint — used by browsers in CORS preflight requests.
Previous
What is REST and what are its six architectural constraints?
Next
What is idempotency and which HTTP methods are idempotent?
More REST API Design Questions
View all →- Beginner What is REST and what are its six architectural constraints?
- Beginner What is idempotency and which HTTP methods are idempotent?
- Beginner What are the most important HTTP status codes in REST APIs?
- Beginner What are REST resource naming conventions?
- Beginner What is the difference between path parameters and query parameters?