> ## Documentation Index
> Fetch the complete documentation index at: https://docs.auxilian.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# delete_rows

> Permanently delete every row that matches all filters.

Deletes every row that matches the filters and returns how many were deleted. At least one filter is required.

| | |
| - | - |
| Scope | `mcp:write` |
| Annotations | `destructiveHint: true` |
| Activity event | `delete_rows` with `table` and `count` |

<Warning>
  Deleted rows can't be recovered. Run `list_rows` with the same filters first to check what matches.
</Warning>

## Parameters

<ParamField body="projectId" type="string" required>
  Project id from `list_projects`. You need write access.
</ParamField>

<ParamField body="table" type="string" required>
  Table name.
</ParamField>

<ParamField body="filters" type="object[]" required>
  At least one condition. Rows must match all of them. See [Filters](/mcp/filters).
</ParamField>

## Result

<ResponseField name="deleted" type="integer">
  The number of rows deleted from this table. Rows removed from other tables by `cascade` foreign keys aren't counted.
</ResponseField>

## Example

```json Arguments theme={null}
{
  "projectId": "01k7m3x9q2v8d4h6n1r5t0w2yz",
  "table": "contacts",
  "filters": [
    { "col": "email", "op": "ilike", "value": "%@test.example" }
  ]
}
```

```json Result theme={null}
{ "data": { "deleted": 4 } }
```

## Foreign keys

When other tables reference the rows you delete, each foreign key's `onDelete` rule applies:

| Rule | Effect |
| - | - |
| `restrict` (default) | The whole delete is refused with `Referenced row does not exist, or the row is still referenced by another table` |
| `cascade` | Referencing rows in the other table are deleted too |
| `set null` | The referencing column in the other table is set to `NULL` |

## Errors

| Code | When |
| - | - |
| `ACCESS_DENIED` | You don't have write access, or the connection is read-only |
| `VALIDATION` | No filters, unknown table or column, an invalid filter, or a `restrict` foreign key blocks the delete |

## Notes

Deleting rows works even when the project has reached its storage limit, but it doesn't reliably lower the measured size. See [How storage is measured](/reference/limits#how-storage-is-measured).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.