Workspace Files block
Configure the Workspace Files block to read and write documents in Files from a workflow, with the operations and outputs it supports.
The Workspace Files block (type: "workspace_files") saves, reads, moves, lists and deletes files in Files, the document store your workflows share. The operation field picks what it does. For the plain-language guide, see Files: documents your workflows use.
When to use it
- Keep a copy of each downloaded statement, remittance or invoice PDF as support for the run.
- Hand a saved file to an AI Agent step as a short-lived link.
- Open a ZIP from a portal download and keep the PDF inside it.
Operations
operation | Editor label | What it does | Fields it needs |
|---|---|---|---|
saveFile | Save file | Saves content as a file. A file with the same name in the same folder is replaced. | file or content |
getFile | Get file | Reads a file back as base64, or as a signed URL. | fileId, or filename with a folder |
getMetadata | Get file metadata | Returns a file's details without reading its content. | fileId |
extractArchive | Extract archive | Takes one file out of a ZIP and saves it. A file that is not an archive is returned as is. | fileId, baseName |
createFolder | Create folder | Gets or creates a folder, or a whole folder path. | folderPath, or folderName |
listFolder | List folder | Lists the files and subfolders in a folder. | None (the root by default) |
listFiles | List files | Lists the files in a folder. | None (the root by default) |
moveFile | Move or rename file | Moves a file to another folder, renames it, or both. | fileId, and folderId or newFilename |
deleteFile | Delete file | Deletes a file. | fileId |
Configuration
Field (config key) | Editor label | Type | Used by | Meaning |
|---|---|---|---|---|
folderPath | Folder Path | string | Save, get, extract, create, list | A slash-separated path, such as Statements/{{input.period}}. saveFile and extractArchive create missing folders. |
folderId | Folder ID | string or null | Save, get, extract, create, list, move | An existing folder, used instead of folderPath. For moveFile, null (or the text null) moves to the root; leave it out to keep the folder. |
file | Downloaded File | object | saveFile | A file object with content, fileName, mimeType and sizeBytes, such as a Stagehand download result. |
content | Content | string | saveFile | The content, when you do not pass file. |
contentEncoding | Content Encoding | string | saveFile | base64 (default) or text. |
filename | Filename | string | saveFile, getFile | The file name. Overrides file.fileName. Default file. |
mimeType | MIME Type | string | saveFile | Such as application/pdf. Default application/octet-stream. |
fileId | File ID | string | Get, metadata, extract, move, delete | The file's id. |
mode | Return | string | getFile | content (default) returns base64. url returns a signed download link instead, which keeps large files out of the run. |
maxSizeBytes | Max Size (bytes) | number | getFile | Fail rather than load a larger file. Default 20971520 (20 MB). |
urlExpiresInSeconds | URL Expiry (seconds) | number | getFile | How long the link works: 60 to 3600, default 600. |
baseName | Extracted File Name | string | extractArchive | Name for the extracted file. Without an extension, one is taken from the content. A re-run replaces it. |
include | Keep Only These Types | string | extractArchive | Comma-separated MIME types to accept, such as application/pdf. Empty accepts any. |
allowMultiple | Allow Multiple Matches | boolean | extractArchive | Take the first match when the archive holds several. Off by default, which fails instead. |
folderName | Folder Name | string | createFolder | A single folder name, created inside folderId or the root. |
newFilename | New Filename | string | moveFile | The new name. Leave it out to keep the name. |
includeFiles, includeFolders | Include Files, Include Folders | boolean | listFolder | Both on by default. |
Output
| Operation | Fields |
|---|---|
saveFile | file (the saved file), folder, replaced |
getFile | file, mode, fileName, mimeType, sizeBytes; for content, content and contentEncoding; for url, url and expiresInSeconds |
getMetadata | file, fileId, fileName, folderId, mimeType, sizeBytes, status, metadata, checksum |
extractArchive | fileId, filePath, fileName, mimeType, sizeBytes, sourceMimeType, extracted (false when the file was not an archive) |
createFolder | folder, created, createdCount |
listFolder | folder, folders, files |
listFiles | folder, files |
moveFile | file, fileId, fileName, folderId, previousFileName, previousFolderId, changed |
deleteFile | fileId, deleted |
A file object has id, name, mimeType, sizeBytes, folderId, status, metadata, checksum, uploadedAt, createdAt and updatedAt. After saveFile, read the new file's id as {{steps.<step id>.file.id}}.
Example
This workflow saves a remittance PDF sent to an API trigger, then passes a link to it to an AI Agent step.
{
"name": "File and read remittance",
"trigger": { "type": "api" },
"steps": [
{
"id": "save_remittance",
"type": "workspace_files",
"name": "Save remittance",
"config": {
"operation": "saveFile",
"folderPath": "Remittances/{{input.customerId}}",
"filename": "remittance-{{input.paymentId}}.pdf",
"content": "{{input.pdfBase64}}",
"contentEncoding": "base64",
"mimeType": "application/pdf"
}
},
{
"id": "remittance_link",
"type": "workspace_files",
"name": "Get link",
"config": {
"operation": "getFile",
"fileId": "{{steps.save_remittance.file.id}}",
"mode": "url",
"urlExpiresInSeconds": 900
}
},
{
"id": "read_remittance",
"type": "agent",
"name": "List invoices paid",
"config": {
"prompt": "List each invoice number and amount paid in this remittance.",
"input": {
"documentUrl": "{{steps.remittance_link.url}}",
"documentMimetype": "application/pdf"
}
}
}
]
}Errors and limits
- A config that misses a field its operation needs fails the step, naming the field.
getFileandextractArchivefail withFile not foundfor an unknown or deleted id, and withFile is not uploadedwhen the file has not finished uploading.getFileincontentmode fails for a file larger thanmaxSizeBytes. Usemode: "url"for large files.saveFileneeds content, fromcontentorfile.content.extractArchivefails when the archive holds no matching file, or holds several andallowMultipleis off.deleteFileon a file that is already deleted returnsdeleted: falserather than failing.- Files are scoped to your company. A run cannot read another company's files.
Stagehand block
Configure the Stagehand browser block to act in a web portal from a workflow: the instructions, settings and output it returns to the run.
Integration action reference
Reference for integration actions: how action names are formed, how a step selects one, and how to list the live catalog from the API.
Loopfour