# deletedocuments: RAG – Delete Documents by Filter

> deletedocuments (RAG – Delete Documents by Filter) is a 1001fx API function in the group Knowledge bases (RAG): POST https://api.1001fx.com/rag/deletedocuments, 0 credits per call. It works as a ready-made module in Make or as a plain HTTP call.

Removes every document of a knowledge base whose metadata match the filter, e.g. all documents of a Drive folder. Needs a filter and confirm true; dryRun only counts. At most 1,000 per call – call again while remaining is above 0. Free.

- Group: Knowledge bases (RAG)
- Endpoint: `POST https://api.1001fx.com/rag/deletedocuments`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 0 credits per call
- Ready-made in: Make
- Docs: https://1001fx.com/functions/deletedocuments

## Parameters

- `knowledgeBase` (string, required) – Knowledge base: Name or ID of the knowledge base, e.g. "Support FAQ" or support-faq (same knowledge base). rag/adddocument creates it if it does not exist.
- `filter` (any, optional) – Filter: Only documents whose metadata match. Object {"department": "billing", "lastModified": {"$gte": "2026-01-01"}} (operators $eq $ne $in $nin $gt $gte $lt $lte $exists $contains, $and $or $not) or array [{"key", "operator", "value", "type"}] (all must match).
- `filterJson` (string, optional) – Filter (JSON): The filter as JSON text, e.g. for OR conditions from Make: {"$or": [{"department": "billing"}, {"department": "sales"}]}.
- `confirm` (boolean, optional, default `false`) – Confirm: Must be true to delete.
- `dryRun` (boolean, optional, default `false`) – Dry run: Only count and list the matching documents.

## Example: RAG – Delete Documents by Filter

```bash
curl -X POST 'https://api.1001fx.com/rag/deletedocuments' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"knowledgeBase":"Support FAQ","filter":{"driveFolder":"abc"},"dryRun":true}'
```
