> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/platform-resources/skill-library/document-skills/document-delete.md).

# Document Delete

**Document Delete** removes one or many documents in a single step. Its main job is cleaning up — temporary working copies and sensitive files that shouldn't outlive the process that needed them.

It deletes in batches and reports per item, so a partial failure is visible rather than silent.

## How it works

1. **Input resolution** — uses `$input` (the previous skill's output) and `$secret` (vault secrets).
2. **Processing** — expects an array of document descriptors:
   * Verifies ownership for `source: "conversation"` items.
   * Checks bucket ACLs for `source: "storage"` items.
   * Redacts IDs in logs.
3. **Execution** — blocking. Returns only after every item is processed.
4. **Response** — collects a per-item result array plus `deletedCount` and `failedCount`.

{% hint style="warning" %}
**A failed delete still returns `200`.** If some items fail, the skill reports success at the top level so the workflow can branch on `failedCount` rather than halting. If you need to know whether everything was removed — and for a PII cleanup you usually do — check `failedCount`, not `statusCode`.
{% endhint %}

## Worked example: securely deleting customer PII after archival

A workflow collects sensitive customer documents — ID proofs, financial statements — for a loan application. Once the agent has processed them and the final version is archived in the compliance system, the temporary copies sitting in the conversation cache and working storage should not remain.

**The problem.** Documents used during processing linger in temporary storage. Tracking and deleting them by hand invites compliance risk and unnecessary storage cost.

**The approach.** End the workflow with a Document Delete skill. Pass the `documentId` values carried forward from [Document Upload](/platform-resources/skill-library/document-skills/document-upload.md), set each item's `source` to where the copy lives, and the cleanup happens as part of the process rather than as a chore someone remembers later.

Then branch on `failedCount`: anything other than zero means a copy survived, which for PII is a result the workflow should act on rather than log.

<figure><img src="/files/Z382YneVtsJ0pSZETCXT" alt=""><figcaption><p>Listing the documents to delete and their source</p></figcaption></figure>

<figure><img src="/files/CVhpMMNvFg6Dx2hlLA9c" alt="" width="551"><figcaption><p>Document Delete batch processing</p></figcaption></figure>

## Configuration reference

| Field   | Type  | Required | Description          |
| ------- | ----- | -------- | -------------------- |
| `items` | array | ✅        | Documents to delete. |

**Each item (`DocumentRef`):**

| Property      | Type                        | Required                | Notes                                     |
| ------------- | --------------------------- | ----------------------- | ----------------------------------------- |
| `documentId`  | string                      | ✅                       | ID returned by Upload or Fetch.           |
| `source`      | `conversation` \| `storage` | ✅                       | Where the document resides.               |
| `storagePath` | string \| null              | when `source='storage'` | Optional; defaults to the root directory. |

## Output

| Field          | Type   | Always | Description                                   |
| -------------- | ------ | ------ | --------------------------------------------- |
| `deletedCount` | number | ✅      | How many documents were successfully deleted. |
| `failedCount`  | number | ✅      | How many deletions failed.                    |
| `items`        | array  | ✅      | Per-item status, in the order you supplied.   |
| `statusCode`   | number | ✅      | Overall status.                               |

**Each item (`DeleteResultItem`):**

| Property     | Type           | Description                              |
| ------------ | -------------- | ---------------------------------------- |
| `documentId` | string         | Echo of the input ID.                    |
| `deleted`    | boolean        | `true` if removed.                       |
| `statusCode` | number         | Upstream response — `204`, `404`, `403`. |
| `error`      | string \| null | Error message if this item failed.       |

## Errors

| Condition            | Node status | Notes                                                      |
| -------------------- | ----------- | ---------------------------------------------------------- |
| Some items fail      | `207`       | `4xx`/`5xx` on each failed entry. Branch on `failedCount`. |
| All items fail       | `400`       | `deletedCount = 0`, `failedCount >= 1`.                    |
| Success              | `200`       | Per item `204`. `deletedCount >= 1`, `failedCount = 0`.    |
| Invalid config shape | `400`       | The skill refuses to run.                                  |

## Security

* `$secret` bearer tokens are never logged.
* Document IDs and storage paths are redacted in logs.
* Conversation ownership is checked to block cross-tenant deletes.

## Testing in isolation

* **Path** — `/skill-runtime/workflows/nodes/DocumentDelete/execute`
* **Method** — `POST`
* **Body:**

```json
{
  "nodeType": "DOCUMENT_DELETE",
  "config": { },
  "input": { }
}
```

***

To add this skill to an agent, see [Adding a Skill to the Agent](/agent-builder/build/adding-a-skill-to-the-agent.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.uptiq.ai/platform-resources/skill-library/document-skills/document-delete.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
