CodePark/ questions / Methods, safety & idempotency
START PRACTICINGPRACTICE
Backend question · HTTP & API design › Methods, safety & idempotency

Which set lists exactly the methods that HTTP defines as safe?

GET, HEAD, OPTIONS, TRACE

A safe method has read-only meaning. The client does not ask the server to change anything. The safe methods are GET, HEAD, OPTIONS and TRACE.

The option "GET, HEAD, PUT, DELETE" is wrong. PUT and DELETE are idempotent, but they are not safe, because they change state on the server. The options with POST and PATCH are wrong for the same reason: both methods change state.