Path: blob/main/files/en-us/web/http/methods/put/index.md
6532 views
------{{HTTPSidebar}}
The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.
The difference between PUT and {{HTTPMethod("POST")}} is that PUT is idempotent: calling it once or several times successively has the same effect (that is no side effect), whereas successive identical {{HTTPMethod("POST")}} requests may have additional effects, akin to placing an order several times.
| Request has body | Yes |
|---|---|
| Successful response has body | May |
| {{Glossary("Safe/HTTP", "Safe")}} | No |
| {{Glossary("Idempotent")}} | Yes |
| {{Glossary("Cacheable")}} | No |
| Allowed in HTML forms | No |
Syntax
Example
Request
Responses
If the target resource does not have a current representation and the PUT request successfully creates one, then the origin server must inform the user agent by sending a {{HTTPStatus("201")}} (Created) response.
If the target resource does have a current representation and that representation is successfully modified in accordance with the state of the enclosed representation, then the origin server must send either a {{HTTPStatus("200")}} (OK) or a {{HTTPStatus("204")}} (No Content) response to indicate successful completion of the request.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{HTTPStatus("201")}}
{{HTTPStatus("204")}}