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

# Delete File

> Delete one or more files from a namespace in document storage (S3).

## Overview

Deletes one or more files from a namespace in document storage (S3). The namespace must belong to the authenticated user. Supports **single-file** or **multiple-file** deletion in one request.

<Warning>
  Deletion is permanent (S3 DeleteObject). Deleted files are not moved to a trash. You can only delete files in namespaces you own.
</Warning>

## Authentication

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json` when using a JSON body
</ParamField>

## Path Parameters

<ParamField path="namespace_name" type="string" required>
  The namespace that contains the file(s). You must own this namespace.
</ParamField>

## Body Parameters

You can specify files in the body and/or via query; all are collected and deleted in one call. At least one of: body `file_name`, body `file_names`, or query `file_name` is required.

<ParamField body="file_name" type="string">
  Single file to delete (e.g. `"document.pdf"`). Can be combined with `file_names`.
</ParamField>

<ParamField body="file_names" type="array">
  Multiple files to delete (e.g. `["a.pdf", "b.docx"]`). Can be combined with `file_name`.
</ParamField>

## Query Parameters

<ParamField query="file_name" type="string">
  Alternative way to specify a single file (e.g. `?file_name=report.pdf`). Can be combined with body.
</ParamField>

<Note>
  Preferred field names are snake\_case. Legacy camelCase (`fileName`, `fileNames`) is still accepted for backward compatibility and returns deprecation headers (`Deprecation`, `Sunset`, `Warning`). CamelCase support is deprecated and scheduled for removal on **1 May 2026**.
</Note>

## Request Examples

<RequestExample>
  ```bash Single file theme={null}
  curl -X DELETE "https://api.moorcheh.ai/v1/namespaces/my-namespace/delete-file" \
    -H "x-api-key: your-api-key-here" \
    -H "Content-Type: application/json" \
    -d '{"file_name": "document.pdf"}'
  ```

  ```bash Multiple files theme={null}
  curl -X DELETE "https://api.moorcheh.ai/v1/namespaces/my-namespace/delete-file" \
    -H "x-api-key: your-api-key-here" \
    -H "Content-Type: application/json" \
    -d '{"file_names": ["doc1.pdf", "doc2.docx", "notes.txt"]}'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - OK theme={null}
  {
    "success": true,
    "message": "File deletion process completed.",
    "namespace": "my-namespace",
    "results": [
      { "file_name": "document.pdf", "status": "deleted", "message": "File deletion initiated successfully" },
      { "file_name": "missing.pdf", "status": "error", "message": "File not found" }
    ]
  }
  ```

  ```json 400 - Bad Request theme={null}
  {
    "error": "Missing namespace in path or no file_name/file_names provided"
  }
  ```

  ```json 401 - Unauthorized theme={null}
  {
    "error": "Missing or invalid API key"
  }
  ```

  ```json 404 - Not Found theme={null}
  {
    "error": "Namespace not found or you do not own it"
  }
  ```

  ```json 429 - Too Many Requests theme={null}
  {
    "error": "API/credit limit exceeded"
  }
  ```
</ResponseExample>

#### Success Response (200 OK)

<ResponseField name="success" type="boolean">
  Always `true` when the request completes
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable confirmation message
</ResponseField>

<ResponseField name="namespace" type="string">
  Name of the namespace the files were deleted from
</ResponseField>

<ResponseField name="results" type="array">
  One entry per file. Each has `file_name`, `status` (`"deleted"` or `"error"`), and `message`. If a file does not exist, that entry has `status: "error"` and `message: "File not found"`; other files are still processed.
</ResponseField>

## Notes

* Only **DELETE** is supported for this action.
* Files are stored under `userId/namespace_name/file_name`; you can only delete files in namespaces you own.
* Each request counts as one API call for usage and credit limits, even when deleting multiple files.
* Deleting multiple files in one request is more efficient than separate calls.

## Related Endpoints

* [List Files](/api-reference/files/list-files) - List file objects in storage for a namespace
* [Get Upload URL](/api-reference/files/upload-file-url) - Upload files to a namespace
* [Get Documents](/api-reference/data/get-documents) - Retrieve text documents items by ID
* [Delete Data](/api-reference/data/delete) - Delete documents/vectors by ID
