MKCOL
Creates a new collection (directory-like resource) at the target location, defined by WebDAV.
What it does
MKCOL creates a new collection — WebDAV's term for a directory-like resource that can contain other resources — at the target URI. It's the closest thing HTTP has to mkdir. Critically, the spec requires the parent collection to already exist; MKCOL won't create intermediate directories for you the way mkdir -p would.
Semantics
| Property | Value | Why it matters |
|---|---|---|
| Safe | No | Creates a new resource |
| Idempotent | Yes | Creating the same already-existing collection again fails predictably rather than duplicating anything |
| Cacheable | No | Not a read |
| Request body | No (in the base spec) | Some extensions allow a body to set initial properties, but plain MKCOL doesn't need one |
| Response body | Optional | Typically empty on success |
Syntax & example request
MKCOL /files/new-project/ HTTP/1.1
Host: dav.example.com
HTTP/1.1 201 Created
curl example
curl -X MKCOL https://dav.example.com/files/new-project/
Common status codes returned
- 201 Created — collection created successfully → see 201
- 405 Method Not Allowed — a resource already exists at that URI and isn't a collection → see 405
- 409 Conflict — the parent collection doesn't exist yet (no intermediate directory creation) → see 409
MKCOL vs PUT
| MKCOL | PUT | |
|---|---|---|
| Creates | A collection (directory-like) | A resource with content (file-like) |
| Requires parent to exist | Yes | Yes, typically |
| Body | Not required | Yes, the resource content |
WebDAV treats "make a folder" and "put a file in it" as genuinely distinct operations — MKCOL for the container, PUT for the contents.
Real-world usage
- WebDAV clients creating new folders when you hit "New Folder" in a mounted WebDAV share
- Provisioning scripts setting up a directory structure on a WebDAV-backed storage system before uploading files into it
Security considerations
Like any resource-creation endpoint, MKCOL needs write-permission checks scoped to the parent collection — a common misconfiguration is allowing any authenticated WebDAV user to create collections anywhere in the tree rather than restricting creation to directories they actually own or have write access to.
FAQ
Does MKCOL create parent directories automatically?
No — per RFC 4918, the parent collection must already exist. Attempting to MKCOL into a non-existent parent path returns a 409 Conflict, not an automatic recursive creation.
What happens if I MKCOL a path that already has a file (not a collection) at it?
You get a 405 Method Not Allowed — MKCOL refuses to overwrite an existing non-collection resource.
Can MKCOL set initial properties on the new collection?
The base RFC 4918 MKCOL doesn't include a body, but RFC 5689 (Extended MKCOL) adds support for specifying resource type and initial properties in the request, useful when a WebDAV extension (like CalDAV) needs to create a specialized collection type in one step.
Fun fact
WebDAV's insistence on a separate method just for "create a folder" (rather than overloading PUT or POST for it) is part of why WebDAV-mounted drives feel so natural in Finder/Explorer — the protocol maps almost 1:1 onto filesystem operations users already understand, which is exactly the design goal RFC 4918 set out to achieve.