Skip to main content
PUTActive

PUT replaces a resource entirely with the supplied representation. It is idempotent – sending the same PUT request twice has the same effect as once. If the resource doesn't exist, PUT may create it (returning 201); if it does, it updates it (returning 200 or 204).

Properties

SafeNoSafe methods don't change server state. They are read-only.
IdempotentYesIdempotent methods produce the same result if called once or multiple times.
CacheableNoCacheable responses may be stored and reused for equivalent requests.
Request BodyYesWhether a request body is allowed / expected.
Response BodyNoWhether a response body is expected.

Description

The PUT method replaces all current representations of the target resource with the request payload. PUT is idempotent, meaning multiple identical requests leave the server in the same state – suitable for upsert operations.

Examples

Replace a user
http
PUT /api/users/42 HTTP/1.1
Host: api.example.com
Content-Type: application/json

{"id": 42, "name": "Alice Updated", "email": "[email protected]", "role": "admin"}

Specification

RFC 9110PUT method specification →