Skip to main content

Delete Files from Collection Node

Remove files from a Needle collection.

The Delete Files from Collection node permanently removes one or more files from a Needle collection by their file IDs. The associated document chunks and embeddings are also deleted. This node is useful for cleanup workflows, content rotation, or removing outdated documents.

Parameters

ParameterTypeRequiredDefaultDescription
collectionIdstringThe Needle collection to delete files from
fileIdsstring""JSON array of file IDs to delete (supports expressions)
instructionsstring""Additional instructions (template mode)
runModestringitemRun mode: item or input

collectionId

Type: string | Required:

The ID of the Needle collection. The user must have editor or owner access to the collection.

fileIds

Type: string | Required:

A JSON array of file IDs to delete. Each file ID must start with the fle_ prefix.

Examples:

  • Static: ["fle_01ABC123", "fle_02DEF456"]
  • Dynamic (expression): [item.fileId]
  • Dynamic (expression): input.filesToDelete.map(f => f.id)

instructions

Type: string | Required:

Additional natural language instructions. Evaluated in template mode.

runMode

Type: string | Required: ✅ | Default: item

Controls how the node processes input data:

  • item — Runs once per array element.
  • input — Runs once for the entire input.

Configuring This Node

When you click the Delete Files from Collection node in the workflow builder, a configuration panel appears with the following sections from top to bottom:

Run Mode & Continue on Error

At the top of the panel is a Run Mode dropdown with two options:

  • Item — The node executes once for every element in the input array. Use item in expressions to reference the current element.
  • Input — The node executes once for the entire input. Use input in expressions to reference the full input.

Next to the dropdown is a Continue on Error toggle. When enabled, the workflow continues executing downstream nodes even if this node fails. The error is captured in the node's output so downstream nodes can inspect and handle it.

Variables

A multi-select dropdown that lets you bind workflow-level variables to this node. Variables are defined at the workflow level and can hold string, number, boolean, or secret values. Once selected, the variables become available in expressions via the variables object (e.g., variables.myApiKey). You can also click the Create variable button to define a new variable without leaving the node configuration panel.

Collection

A dropdown that lists all Needle collections available to you. Select the collection from which files will be deleted. The selected collection's ID is used as the collectionId parameter.

Instructions

A template text area for optional AI instructions. Supports ${...} template literal syntax for inserting dynamic values. These instructions guide the AI agent in how to use the tool when the node is part of an AI-driven workflow.

Property Fields

The remaining parameters (fileIds) are displayed as property fields, organized into Required and Optional sections based on the node's schema. Each field has a mode toggle that lets you switch between three parameter modes:

  • Fixed — Enter a static value directly in the field.
  • Expression — Write a JavaScript expression that is evaluated at runtime. Expressions can reference input, item, variables, and other context objects.
  • AI Decide — Let the AI agent determine the value based on the surrounding context and instructions.

Examples

1. Delete Specific Files

Remove known files from a collection:

Parameters:

{
"runMode": "input",
"collectionId": "<your-collection-id>",
"fileIds": "[\"fle_01ABC123\", \"fle_02DEF456\"]"
}

2. Delete Files from Previous Node Output

Delete files identified by a previous node:

Parameters:

{
"runMode": "input",
"collectionId": "<your-collection-id>",
"fileIds": "input.outdatedFiles.map(f => f.id)",
"parameterMode": {
"fileIds": "expression"
}
}

3. Delete a Single File per Item

Process an array of files and delete each one:

Parameters:

{
"runMode": "item",
"collectionId": "<your-collection-id>",
"fileIds": "[item.id]",
"parameterMode": {
"fileIds": "expression"
}
}

Output Structure

The node returns confirmation of the deletion:

{
"deletedFileIds": ["fle_01ABC123", "fle_02DEF456"]
}

Important Notes

  • Irreversible: File deletion is permanent. Deleted files and their associated chunks cannot be recovered.
  • Editor access required: The user must have editor or owner permissions on the collection.
  • File ID format: File IDs must start with fle_. Invalid IDs will cause an error.
  • Batch deletion: You can delete multiple files in a single call by providing an array of file IDs.
  • Continue on Error: Use the toggle at the top of the configuration panel to allow the workflow to continue even if this node fails. The error details are captured in the node's output for downstream handling.
  • Workflow Variables: You can bind workflow-level variables (string, number, boolean, or secret) to this node using the Variables multi-select. Selected variables are accessible in expressions via the variables object.
  • Parameter modes: Each property field can be switched between Fixed (static value), Expression (runtime JavaScript expression), and AI Decide (let the AI agent choose the value) modes using the toggle on the field.