# Delete Data

**Action ID:** `delete_dataset_rows`

## Description

Delete rows from a dataset that match filter conditions.

## Input Parameters

| Name       | Type     | Required | Default | Description                                                           |
| ---------- | -------- | :------: | ------- | --------------------------------------------------------------------- |
| dataset    | dropdown |     ✓    | -       | The dataset to delete rows from.                                      |
| conditions | array    |     -    | \[]     | Filter conditions to select rows to delete (empty = delete all rows). |
| logic      | dropdown |     -    | and     | How to combine filter conditions (AND/OR). Options: and, or           |

### Filter Condition Structure

Each condition in the `conditions` array contains:

| Field    | Type     | Description                                                                               |
| -------- | -------- | ----------------------------------------------------------------------------------------- |
| column   | string   | Column name to filter by                                                                  |
| operator | dropdown | Comparison operator: equals, not\_equals, contains, greater\_than, less\_than, in         |
| value    | string   | Value to compare against. For 'in' operator, provide comma-separated values or JSON array |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Delete Dataset Rows node input.",
  "properties": {
    "dataset": {
      "description": "The dataset to delete rows from.",
      "title": "Dataset",
      "type": "string"
    },
    "conditions": {
      "default": [],
      "description": "Filter conditions to select rows to delete (empty = delete all rows).",
      "items": {
        "properties": {
          "column": {
            "description": "Column name to filter by",
            "title": "Column",
            "type": "string"
          },
          "operator": {
            "default": "equals",
            "description": "Comparison operator",
            "enum": ["equals", "not_equals", "contains", "greater_than", "less_than", "in"],
            "title": "Operator",
            "type": "string"
          },
          "value": {
            "description": "Value to compare against. For 'in' operator, provide comma-separated values or JSON array",
            "title": "Value",
            "type": "string"
          }
        },
        "required": ["column", "value"],
        "type": "object"
      },
      "title": "Filter Conditions",
      "type": "array"
    },
    "logic": {
      "default": "and",
      "description": "How to combine filter conditions (AND/OR).",
      "enum": ["and", "or"],
      "title": "Logic Operator",
      "type": "string"
    }
  },
  "required": ["dataset"],
  "title": "DeleteDatasetRowsNodeInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name           | Type    | Description                       |
| -------------- | ------- | --------------------------------- |
| deleted\_count | integer | Number of rows that were deleted. |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Delete Dataset Rows node output.",
  "properties": {
    "deleted_count": {
      "description": "Number of rows that were deleted.",
      "title": "Deleted Count",
      "type": "integer"
    }
  },
  "required": ["deleted_count"],
  "title": "DeleteDatasetRowsNodeOutput",
  "type": "object"
}
```

</details>

## How It Works

This node deletes rows from a dataset based on filter conditions. It evaluates each row against the specified conditions using the chosen logic operator (AND/OR). Matching rows are permanently removed from the dataset. The node validates the dataset ID format (26-character ULID) before execution and returns the count of deleted rows. If no conditions are provided, all rows in the dataset will be deleted.

## Usage Examples

### Example 1: Delete Inactive Users

**Input:**

```
dataset: "01K8ZM9T72FNBZAGA629KZFXR5"
conditions: [
  {
    "column": "status",
    "operator": "equals",
    "value": "inactive"
  }
]
logic: "and"
```

**Output:**

```
deleted_count: 47
```

### Example 2: Delete Old Records

**Input:**

```
dataset: "01K8ZM9T72FNBZAGA629KZFXR5"
conditions: [
  {
    "column": "created_date",
    "operator": "less_than",
    "value": "2023-01-01"
  }
]
logic: "and"
```

**Output:**

```
deleted_count: 1250
```

### Example 3: Delete Multiple Status Types

**Input:**

```
dataset: "01K8ZM9T72FNBZAGA629KZFXR5"
conditions: [
  {
    "column": "status",
    "operator": "in",
    "value": "deleted,archived,expired"
  }
]
logic: "and"
```

**Output:**

```
deleted_count: 328
```

### Example 4: Delete with Multiple Conditions (AND)

**Input:**

```
dataset: "01K8ZM9T72FNBZAGA629KZFXR5"
conditions: [
  {
    "column": "status",
    "operator": "equals",
    "value": "pending"
  },
  {
    "column": "age_days",
    "operator": "greater_than",
    "value": "90"
  }
]
logic: "and"
```

**Output:**

```
deleted_count: 156
```

### Example 5: Delete with OR Logic

**Input:**

```
dataset: "01K8ZM9T72FNBZAGA629KZFXR5"
conditions: [
  {
    "column": "email",
    "operator": "contains",
    "value": "spam"
  },
  {
    "column": "valid",
    "operator": "equals",
    "value": "false"
  }
]
logic: "or"
```

**Output:**

```
deleted_count: 89
```

## Common Use Cases

* **Data Cleanup**: Remove outdated, invalid, or obsolete records from datasets
* **User Management**: Delete inactive or suspended user accounts
* **Compliance**: Remove data past retention period for GDPR/privacy compliance
* **Quality Control**: Delete records that failed validation or processing
* **Batch Operations**: Remove multiple records matching specific criteria in one operation
* **Status-Based Deletion**: Clean up records in terminal states like "completed", "failed", or "cancelled"
* **Archive Management**: Remove archived records from active datasets
* **Test Data Cleanup**: Clear test or demo data from production datasets

## Error Handling

| Error Type          | Cause                                | Solution                                                          |
| ------------------- | ------------------------------------ | ----------------------------------------------------------------- |
| Dataset Not Found   | Dataset ID doesn't exist             | Verify the dataset ID is correct and the dataset exists           |
| Invalid Dataset ID  | Dataset ID format is incorrect       | Ensure dataset ID is a 26-character ULID                          |
| Dataset ID Required | Dataset parameter is empty           | Provide a valid dataset ID                                        |
| Invalid Column      | Column name doesn't exist in dataset | Check the dataset schema for available column names               |
| Invalid Operator    | Operator not in allowed list         | Use: equals, not\_equals, contains, greater\_than, less\_than, in |
| Malformed Condition | Missing required fields              | Ensure each condition has column, operator, and value             |
| Permission Denied   | Insufficient permissions             | Verify you have delete permissions on the dataset                 |
| Delete Failed       | Server error during deletion         | Retry the operation or check server logs                          |

## Notes

* **Permanent Operation**: Deleted rows cannot be recovered. Use with caution and consider backing up data first.
* **Empty Conditions Warning**: If conditions array is empty, ALL rows in the dataset will be deleted. Double-check before execution.
* **Validation**: The node validates dataset ID format (must be 26-character ULID) before attempting deletion.
* **Atomic Operation**: The delete operation is atomic, ensuring data consistency.
* **Performance**: Deleting large numbers of rows may take time. Monitor the deleted\_count in the output.
* **Filter First**: Consider using the Query Data node to preview matching rows before deletion.
* **Audit Trail**: Keep logs of delete operations for compliance and troubleshooting purposes.
* **Conditional Logic**: Use AND logic to narrow down deletion criteria, OR logic to broaden the scope.
* **Batch Processing**: For very large deletions, consider breaking them into smaller batches to avoid timeout issues.
* **Dependencies**: Ensure no other workflows or processes depend on the rows being deleted.
* **Cascade Effects**: Be aware of any relationships or references that might be affected by row deletion.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/delete_data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
