Loopfour
Blocks

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

operationEditor labelWhat it doesFields it needs
saveFileSave fileSaves content as a file. A file with the same name in the same folder is replaced.file or content
getFileGet fileReads a file back as base64, or as a signed URL.fileId, or filename with a folder
getMetadataGet file metadataReturns a file's details without reading its content.fileId
extractArchiveExtract archiveTakes one file out of a ZIP and saves it. A file that is not an archive is returned as is.fileId, baseName
createFolderCreate folderGets or creates a folder, or a whole folder path.folderPath, or folderName
listFolderList folderLists the files and subfolders in a folder.None (the root by default)
listFilesList filesLists the files in a folder.None (the root by default)
moveFileMove or rename fileMoves a file to another folder, renames it, or both.fileId, and folderId or newFilename
deleteFileDelete fileDeletes a file.fileId

Configuration

Field (config key)Editor labelTypeUsed byMeaning
folderPathFolder PathstringSave, get, extract, create, listA slash-separated path, such as Statements/{{input.period}}. saveFile and extractArchive create missing folders.
folderIdFolder IDstring or nullSave, get, extract, create, list, moveAn existing folder, used instead of folderPath. For moveFile, null (or the text null) moves to the root; leave it out to keep the folder.
fileDownloaded FileobjectsaveFileA file object with content, fileName, mimeType and sizeBytes, such as a Stagehand download result.
contentContentstringsaveFileThe content, when you do not pass file.
contentEncodingContent EncodingstringsaveFilebase64 (default) or text.
filenameFilenamestringsaveFile, getFileThe file name. Overrides file.fileName. Default file.
mimeTypeMIME TypestringsaveFileSuch as application/pdf. Default application/octet-stream.
fileIdFile IDstringGet, metadata, extract, move, deleteThe file's id.
modeReturnstringgetFilecontent (default) returns base64. url returns a signed download link instead, which keeps large files out of the run.
maxSizeBytesMax Size (bytes)numbergetFileFail rather than load a larger file. Default 20971520 (20 MB).
urlExpiresInSecondsURL Expiry (seconds)numbergetFileHow long the link works: 60 to 3600, default 600.
baseNameExtracted File NamestringextractArchiveName for the extracted file. Without an extension, one is taken from the content. A re-run replaces it.
includeKeep Only These TypesstringextractArchiveComma-separated MIME types to accept, such as application/pdf. Empty accepts any.
allowMultipleAllow Multiple MatchesbooleanextractArchiveTake the first match when the archive holds several. Off by default, which fails instead.
folderNameFolder NamestringcreateFolderA single folder name, created inside folderId or the root.
newFilenameNew FilenamestringmoveFileThe new name. Leave it out to keep the name.
includeFiles, includeFoldersInclude Files, Include FoldersbooleanlistFolderBoth on by default.

Output

OperationFields
saveFilefile (the saved file), folder, replaced
getFilefile, mode, fileName, mimeType, sizeBytes; for content, content and contentEncoding; for url, url and expiresInSeconds
getMetadatafile, fileId, fileName, folderId, mimeType, sizeBytes, status, metadata, checksum
extractArchivefileId, filePath, fileName, mimeType, sizeBytes, sourceMimeType, extracted (false when the file was not an archive)
createFolderfolder, created, createdCount
listFolderfolder, folders, files
listFilesfolder, files
moveFilefile, fileId, fileName, folderId, previousFileName, previousFolderId, changed
deleteFilefileId, 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.
  • getFile and extractArchive fail with File not found for an unknown or deleted id, and with File is not uploaded when the file has not finished uploading.
  • getFile in content mode fails for a file larger than maxSizeBytes. Use mode: "url" for large files.
  • saveFile needs content, from content or file.content.
  • extractArchive fails when the archive holds no matching file, or holds several and allowMultiple is off.
  • deleteFile on a file that is already deleted returns deleted: false rather than failing.
  • Files are scoped to your company. A run cannot read another company's files.

On this page