TechnicalEasy HTTP & REST APIs

Explain the HTTP methods GET, POST, PUT, PATCH and DELETE. Which ones are idempotent?

Asked for Frontend Developer, Backend Developer, Full-Stack Developer, Mobile Developer

Why they ask this: Every developer calls or builds APIs; correct method use is a basic expectation.

Answer

MethodUseSafeIdempotent
GETread a resourceyesyes
POSTcreate a resource or trigger an actionnono
PUTreplace a resource completelynoyes
PATCHupdate part of a resourcenonot guaranteed
DELETEremove a resourcenoyes
  • Safe means the request does not change server data.
  • Idempotent means sending the same request several times leaves the server in the same state as sending it once. Two identical POST /orders calls can create two orders, while PUT /users/5 with the same body twice gives the same result.

This matters for retries: clients and proxies can safely retry idempotent requests after a network error. For payments, use an idempotency key to make POST safe to retry.

Can you explain this in your own words?

Back to question bank