write
HTTP COPY
WebDAV extension (RFC 4918) that copies a resource from the Request-URI to the URI given in the Destination header. Can copy collections recursively based on the Depth header.
COPY /source HTTP/1.1 Destination: /target Properties
| Property | Value / Meaning |
|---|---|
| Safe | No - it creates a new resource at the destination. |
| Idempotent | Yes - repeating the same COPY with Overwrite: T yields the same destination state. |
| Cacheable | No - COPY responses are not cached. |
| Has body | Optional - a body may carry a propertybehavior XML document; usually omitted. |
| Body in response | Optional - typically 201 Created or 204 No Content; 207 Multi-Status if partial failures occur. |
Examples
curl -X COPY -H 'Destination: https://dav.example.com/backup/file.txt' https://dav.example.com/file.txt Copy a single file to a new URI on the same server.
curl -X COPY -H 'Destination: /archive/2025/' -H 'Depth: infinity' https://dav.example.com/reports/2025/ Recursive copy of an entire collection.
curl -X COPY -H 'Destination: /a/b.txt' -H 'Overwrite: F' https://dav.example.com/a.txt Fail with 412 Precondition Failed if the destination already exists.
COPY /src.txt HTTP/1.1\nHost: dav.example.com\nDestination: /dst.txt\nOverwrite: T Raw WebDAV request replacing any existing destination.
Gotcha
COPY is a WebDAV verb, not core HTTP - plain REST servers will return 405. Depth defaults to infinity for collections; set Depth: 0 to copy only the collection resource itself.
Related methods
HTTP MOVE
WebDAV extension (RFC 4918) that moves a resource from the Request-URI to the Destination URI, equivalent to a COPY followed by a DELETE of the source. Preserves the resource across the rename or relocation.
HTTP PUT
Replaces the target resource entirely with the request payload, or creates it if it does not exist at the given URL. The client dictates the resource identifier, so PUT is idempotent.
HTTP DELETE
Removes the target resource, or requests its removal. Once deleted, subsequent requests typically return 404 or 410.
HTTP POST
Submits an entity to the specified resource, often causing a change in state or side effect on the server. Used for creating resources, form submissions, and RPC-style calls.
HTTP PATCH
Applies a partial modification to a resource, described by the patch document in the request body (e.g. JSON Patch or JSON Merge Patch). Only the specified fields change; the rest of the resource is untouched.