Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/web/http/methods/put/index.md
6532 views
---
title: PUT slug: Web/HTTP/Methods/PUT browser-compat: http.methods.PUT
---

{{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

PUT /new.html HTTP/1.1

Example

Request

PUT /new.html HTTP/1.1 Host: example.com Content-type: text/html Content-length: 16 <p>New File</p>

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.

HTTP/1.1 201 Created Content-Location: /new.html

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.

HTTP/1.1 204 No Content Content-Location: /existing.html

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{HTTPStatus("201")}}

  • {{HTTPStatus("204")}}