Downloading into a folder that does not exist yet normally needs an extra mkdir -p line first. curl can create the folder for you.
With --create-dirs, curl creates the missing directories of the path you give to -o (--output):
curl --create-dirs -o /mnt/user/appdata/<app>/downloads/2026/data.zip \
https://example.com/data.zip
If the folders already exist, or the output name has no folder in it, nothing is created and the option does no harm. That makes it safe to leave on in a script that runs every day.
It combines with --output-dir. The manual says the created directories are the output path joined with whatever --output-dir points at:
curl --output-dir /mnt/user/appdata/<app>/downloads --create-dirs \
-O https://example.com/reports/may.pdf
Without --create-dirs, a missing target directory makes the transfer fail, which is the documented behaviour of --output-dir.
Two caveats from the manual. First, on Unix-style systems curl creates the folders with mode 0750, so if other users or a container with a different user need to read them, check the permissions afterwards. Second, --output-dir does not clean up ../ in the path. If any part of the path comes from user input or from a server, I would validate it before it reaches curl, otherwise a download could end up outside the folder you meant.
The option only covers local folders. For SFTP or FTP uploads, the manual points to --ftp-create-dirs instead.
Further reading: curl man page: –create-dirs and –output-dir