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
| Safe | No | Safe methods don't change server state. They are read-only. |
| Idempotent | Yes | Idempotent methods produce the same result if called once or multiple times. |
| Cacheable | No | Cacheable responses may be stored and reused for equivalent requests. |
| Request Body | Yes | Whether a request body is allowed / expected. |
| Response Body | No | Whether 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"}