Upload files
Use this action to upload one or more files from Home Assistant to your WebDAV server, for example to keep a copy of your camera snapshots.
The destination folder is relative to the URL you configured for the integration, not to the backup path. It is created if it does not exist yet. Files that already exist at the destination are overwritten.
Home Assistant can only upload files from folders it can read. By default, these are your media folders and the www folder in your configuration folder. Files in the www folder can be opened by anyone who can reach your Home Assistant without signing in. Store private files, like camera snapshots, in a media folder. To upload files from another folder, add it to allowlist_external_dirs in your configuration.yaml file.
This action can return data that you can use in later steps of the same automation or script.
Using this action from the user interface
If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.
To upload files from an automation or a script:
- Go to Settings > Automations & scenes.
- Open an existing automation or script, or select Create automation > Create new automation.
- If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
- In the Then do section, select Add action.
- From the search box, search for and select WebDAV: Upload files.
- Select the WebDAV server in Config entry ID, enter the Filenames to upload, and the Destination folder.
- Select Save.
This action does not support targets. In the UI, you are not prompted to choose an area, device, entity, or label.
Options in the UI
Using this action in YAML
If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required. For how an automation or a script is built in YAML, refer to Automations in YAML and Scripts.
In YAML, refer to this action as webdav.upload. A basic example looks like this:
action: webdav.upload
data:
config_entry_id: a1bee602deade2b09bc522749bbce48e
filename: /media/image.jpg
destination_folder: Snapshots/2025
This uploads a single file to the Snapshots/2025 folder on your WebDAV server.
Options in YAML
One or more paths to the files you want to upload. Each file must be in a folder that Home Assistant is allowed to read: the www folder in your configuration folder, a media folder, or a folder listed in allowlist_external_dirs. Wildcards (glob patterns) are supported, so you can upload several files at once. When you use a wildcard, the folder part before the first wildcard must be an allowed folder.
Response data
This action can return data. The response variable is optional. If you set it, you can use the data in later steps of the same automation or script. For details, refer to Action response data.
When you provide a response variable, the action returns a files list. Each entry has a path with the full path of the uploaded file on the WebDAV server.
Good to know
- Only administrators can run this action.
- Every file must end up at a different path on the server. If two files are uploaded to the same path, for example, two files with the same name from different folders, the action stops with an error and uploads nothing.
Try it yourself
Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.
More examples
Real scenarios where this action shows up in automations and scripts. Copy any example and adapt it to your setup. In the visual editor, select the UI options listed in the example or paste the YAML code.
You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.
Automation: upload a snapshot when motion is detected
When motion is detected at the front door, take a snapshot and upload it to your WebDAV server, so you have a copy even if Home Assistant is offline. The snapshot uses the same filename each time, so each upload replaces the previous one on the server.
-
Trigger: State changed
- Entity: Front door motion sensor
- To: Detected
-
Action: Take camera snapshot
- Target: Front door camera
-
Filename:
/media/snapshots/front_door.jpg
-
Action: Upload files
- Config entry: Your WebDAV server
-
Filenames:
/config/www/snapshots/front_door.jpg -
Destination folder:
Snapshots
YAML example for uploading a snapshot on motion
alias: "Upload a snapshot when motion is detected"
triggers:
- trigger: state
entity_id: binary_sensor.front_door_motion
to: "on"
actions:
- action: camera.snapshot
target:
entity_id: camera.front_door
data:
filename: /config/www/snapshots/front_door.jpg
- action: webdav.upload
data:
config_entry_id: a1bee602deade2b09bc522749bbce48e
filename: /config/www/snapshots/front_door.jpg
destination_folder: Snapshots
Automation: Upload all snapshots every night
Every night, upload all snapshots from the snapshots folder to your WebDAV server. The wildcard picks up every JPG file in the folder, so you don’t need to list each file.
-
Trigger: Time
-
At time:
23:00
-
At time:
-
Action: Upload files
- Config entry: Your WebDAV server
-
Filenames:
/config/www/snapshots/*.jpg -
Destination folder:
Snapshots/Archive
YAML example for uploading all snapshots every night
alias: "Upload all snapshots every night"
triggers:
- trigger: time
at: "23:00:00"
actions:
- action: webdav.upload
data:
config_entry_id: a1bee602deade2b09bc522749bbce48e
filename: /config/www/snapshots/*.jpg
destination_folder: Snapshots/Archive
Upload multiple files
You can upload several files at once by passing a list of paths.
Upload multiple files
action: webdav.upload
data:
config_entry_id: a1bee602deade2b09bc522749bbce48e
filename:
- /media/image_1.jpg
- /media/image_2.jpg
destination_folder: Snapshots/2025
Upload files using wildcards
The filename option supports wildcards (glob patterns), so you can upload several files without listing each one:
-
*matches any number of characters within a single folder level. For example,/media/snapshots/*.jpguploads every JPG file in thesnapshotsfolder. -
**matches folders recursively. For example,/media/snapshots/**/*.jpguploads every JPG file in thesnapshotsfolder and all of its subfolders. -
?matches a single character. -
[starts a character range, such as[0-9].
When a wildcard matches files in subfolders, those subfolders are recreated inside the destination_folder on the WebDAV server, preserving the original structure.
If a wildcard pattern does not match any files, the action fails with an error listing the patterns that had no matches. The characters *, ?, and [ are treated as wildcards, unless a file with that exact name exists. In that case, the file is uploaded as is.
Upload files using a wildcard
action: webdav.upload
data:
config_entry_id: a1bee602deade2b09bc522749bbce48e
filename: /media/snapshots/**/*.jpg
destination_folder: Snapshots/2025
Still stuck?
To test the action on its own, run it in the automation editor with Run action, and check the message that it shows. To see what the action did when the automation ran, open the trace of that run. For details, refer to Testing automations. For common problems and their solutions, refer to Troubleshooting automations.
If that doesn’t help, the Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.
AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.