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

← All HTTP methods · HTTP status codes · HTTP headers