---
docId: doc_d457a12d1cc54effb7a42459fe5103ec
title: Delete a file
description: Delete a file from the workspace and disconnect it from all the agents that use it. It requires Integrations and the confirmationToken from the list of affected agents.
api:
  group: archivos
  auth: bearer
  operations:
    - operationId: deleteFile
      method: DELETE
      path: '/v1/files/{fileId}'
      postmanName: Delete a file
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Delete a file

Deletes the file from the workspace. **All the agents that use it stop using it**, and it cannot be undone. To remove it from a single agent and keep it in the workspace, use [Disconnect a file](/api-reference/agents/files/disconnect).

## Before you delete

1. Read the file with [`include=affectedAgents`](/api-reference/files/get) and follow `affectedAgents.nextPageToken` to the last page.
2. Show the person which agents use it and confirm with them.
3. Take the `confirmationToken` from the last page (valid for 10 minutes).

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X DELETE "https://api.platic.ai/v1/files/$FILE_ID" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "confirmationToken": "'"$CONFIRMATION_TOKEN"'" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.files.delete("file_123");
```

</Ways.Way>
</Ways>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `fileId` | string | The file | ✓ |

## Request body

```json
{ "confirmationToken": "del1...." }
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `confirmationToken` | string | `affectedAgents.confirmationToken` from the last page of [Get a file](/api-reference/files/get) | ✓ |

## Response

`202 Accepted` while it is being deleted:

```json
{
  "status": "success",
  "data": {
    "fileId": "fH3kL9mQ2xR7",
    "lifecycle": "deleting",
    "operationId": "deletion_5Gt2Rk9Mw1"
  }
}
```

From that moment no agent uses it and the file appears with `lifecycle: "deleting"`. When it finishes deleting, repeating the same request answers `204 No Content`, with no body, and reading it answers `410 FILE_DELETED`.

## Response fields

| Field | Type | Description |
|-------|------|-------------|
| `fileId` | string | The file. |
| `lifecycle` | string | Always `deleting`. |
| `operationId` | string | The delete operation. |

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_INPUT` | `confirmationToken` is missing. |
| `403` | `RESOURCE_NOT_ACCESSIBLE` | Integrations is missing. |
| `410` | `FILE_DELETED` | It was already deleted. |
| `409` | `CONFLICT` | Who uses the file changed or the `confirmationToken` expired. Request the list of agents again and confirm again. |

The ones that apply to all operations are in [common errors](/api-reference/files#common-errors).

## Notes

- In the [SDK](/sdk), `platic.files.delete(fileId)` gets the `confirmationToken` for you right before deleting. If you first want to show a person which agents use the file, call `platic.files.get(fileId, { include: ["affectedAgents"] })` and pass `{ confirmationToken }` to `delete`.

<Note type="warning">

There is no trash or history: the content is erased. Download links already issued may work until they expire (5 minutes).

</Note>
