# Delete an uploaded file

DELETE /api/v1/files/{asset_id} permanently deletes a file you uploaded and the data derived from it: the stored bytes, extracted text, pages and units, embeddings, search entries and the cached read. Free.

Documentation index: https://webcite.co/llms.txt
Canonical page: https://webcite.co/api-docs/delete-file
API origin: https://api.webcite.co
Authentication: x-api-key header. Keep keys on your server.

## What it deletes

Send the `asset_id` that [upload](/api-docs/upload) or [upload from a URL](/api-docs/upload-url) returned. The call deletes the stored bytes, the file's source versions, extracted text, pages and units, embeddings, search index entries and the cached read of the file.

Verification results and document reviews that used the file stay until you delete them: see [delete a verification result](/api-docs/delete-citation), [delete results in bulk](/api-docs/delete-citations) and [delete document reviews](/api-docs/delete-document-reviews). When another file in your account shares the same stored object, the bytes stay for that file.

## Retry after a 503

Webcite removes the search index entries, cached reads and stored bytes first, retrying each step, and then removes the file's database records in one transaction. If an outside step still fails, the call returns 503 and no record is removed, so repeating the request finds the same file and finishes the deletion.

## Response example

Built from the response schema in the [OpenAPI file](/api-docs/openapi.json); identifiers are placeholders.

```json
{
  "asset_id": "00000000-0000-4000-8000-000000000019",
  "deleted": true
}
```

## Request

DELETE /api/v1/files/{asset_id}

Free. Deleting a file costs 0 credits.

### curl

```curl
curl --fail-with-body -X DELETE 'https://api.webcite.co/api/v1/files/YOUR_ASSET_ID' \
  -H "x-api-key: $WEBCITE_API_KEY"
```

### Node.js

```javascript
const response = await fetch("https://api.webcite.co/api/v1/files/YOUR_ASSET_ID", {
  method: "DELETE",
  headers: {
    "x-api-key": process.env.WEBCITE_API_KEY,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(await response.json());
```

### python

```python
import os
import requests

response = requests.delete(
    "https://api.webcite.co/api/v1/files/YOUR_ASSET_ID",
    headers={"x-api-key": os.environ["WEBCITE_API_KEY"]},
    timeout=(10, 300),
)
response.raise_for_status()
print(response.json())
```

## Response

HTTP 200 returns `asset_id`, the id you sent, and `deleted: true`. The file is gone at that point: a second call with the same `asset_id` returns 404.

## Errors

400: `asset_id` is not a UUID (`Invalid asset id`); nothing is deleted. 401: missing or invalid key. 403: app keys cannot use this endpoint. 404: no file with this `asset_id` in your account (`File not found`), which includes a file another account uploaded and one you already deleted. 503: part of the deletion failed after retries; repeat the same request to finish it.

## OpenAPI operation

```json
{
  "path": "/api/v1/files/{asset_id}",
  "method": "DELETE",
  "operation": {
    "description": "Permanently deletes a file you uploaded and everything derived from it: the stored bytes, extracted text, pages and units, embeddings, search index entries and the cached read. Free. Verification results and document reviews that used the file stay until you delete them. Repeating the call after a 503 finishes the deletion.",
    "operationId": "DataDeletionController_deleteFile",
    "parameters": [
      {
        "description": "The asset_id returned by POST /upload",
        "in": "path",
        "name": "asset_id",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    ],
    "responses": {
      "200": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/FileDeletedDto"
            }
          }
        },
        "description": ""
      },
      "404": {
        "description": "No file with this asset_id in your account"
      },
      "503": {
        "description": "Part of the deletion failed after retries; repeat the request to finish it"
      }
    },
    "security": [
      {
        "x-api-key": []
      },
      {
        "bearer": []
      }
    ],
    "summary": "Delete an uploaded file",
    "tags": [
      "Upload"
    ]
  },
  "schemas": {
    "FileDeletedDto": {
      "properties": {
        "asset_id": {
          "type": "string"
        },
        "deleted": {
          "example": true,
          "type": "boolean"
        }
      },
      "required": [
        "asset_id",
        "deleted"
      ],
      "type": "object"
    }
  }
}
```
