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

# Delete Object

Delete an object from Antryk Storage using a clean and RESTful API structure.

This endpoint allows you to permanently remove a file from a specific bucket by defining both the bucket name and file path directly in the URL. This eliminates the need for request bodies and simplifies the deletion process.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request DELETE \
    --url "https://storage.apis.antryk.com/api/v1/buckets/:yourBucketName/objects/:yourFilePath" \
    --header "x-access-key: YOUR_ACCESS_KEY" \
    --header "x-secret-key: YOUR_SECRET_KEY"
  ```

  ```javascript JavaScript theme={null}
  fetch(
    "https://storage.apis.antryk.com/api/v1/buckets/:yourBucketName/objects/:yourFilePath",
    {
      method: "DELETE",
      headers: {
        "x-access-key": "YOUR_ACCESS_KEY",
        "x-secret-key": "YOUR_SECRET_KEY",
      },
    },
  );
  ```

  ```javascript NodeJs theme={null}
  // npm i @antryk/sdk
  import { AntrykClient } from "@antryk/sdk";

  const client = new AntrykClient({
    accessKey: process.env.ANTRYK_ACCESS_KEY,
    secretKey: process.env.ANTRYK_SECRET_KEY,
  });

  async function deleteObject() {
    const result = await client.storage.delete({
      bucket: "upload-final-v1",
      key: "uploads/po.exe",
    });

    console.log(result);
  }

  deleteObject();
  ```

  ```python Python theme={null}
  # pip install requests
  import requests

  url = "https://storage.apis.antryk.com/api/v1/buckets/:yourBucketName/objects/:yourFilePath"

  headers = {
      "x-access-key": "YOUR_ACCESS_KEY",
      "x-secret-key": "YOUR_SECRET_KEY"
  }

  response = requests.delete(url, headers=headers)

  print(response.status_code)
  print(response.json())
  ```
</CodeGroup>

<Note>
  {" "}

  This endpoint does **not** accept a request body. All required information
  such as bucket name and object path must be passed via the URL, while
  authentication must be provided using headers.
</Note>

<Note>
  For Node.js applications, it is recommended to use the official
  [`@antryk/sdk`](https://www.npmjs.com/package/@antryk/sdk). The SDK abstracts
  authentication, request handling, and validation, allowing you to upload files
  using simple method calls instead of manually constructing HTTP requests.
</Note>

### New Delete Approach (Recommended)

This is the recommended and modern approach for deleting objects from Antryk Storage:

* No request body is required.
* The bucket name and object path are defined directly in the URL.
* Authentication is handled via headers:
  * x-access-key
  * x-secret-key

This approach improves API clarity, enhances security by avoiding sensitive data in the body, and aligns with RESTful best practices.

<Note>
  {" "}

  ⚠️ The older approach (sending `bucket`, `key`, `accessKey`, and `secretKey`
  in the body) may still be supported for backward compatibility, but it is
  **strongly recommended to migrate to this new method**
</Note>

## Request Parameters

<ParamField path="yourBucketName" type="string" required>
  {" "}

  The name of the storage bucket. This is specified directly in the URL.{" "}
</ParamField>

<ParamField path="yourFilePath" type="string" required>
  {" "}

  The full path (including filename) of the object you want to delete from the
  bucket.{" "}
</ParamField>

<ParamField header="x-access-key" type="string" required>
  {" "}

  Your Antryk access key used for authentication. You can obtain this from the
  Antryk Console.{" "}
</ParamField>

<ParamField header="x-secret-key" type="string" required>
  {" "}

  Your Antryk secret key used for authentication. Keep this secure and never
  expose it publicly.{" "}
</ParamField>

## Examples

<ParamField path="yourBucketName" type="string" required>
  {" "}

  **Example:** `upload-final-v1`{" "}
</ParamField>

<ParamField path="yourFilePath" type="string" required>
  {" "}

  **Example:** `uploads/po.exe`{" "}
</ParamField>

<ParamField header="x-access-key" type="string" required>
  {" "}

  **Example:** `YOUR_ACCESS_KEY`{" "}
</ParamField>

<ParamField header="x-secret-key" type="string" required>
  {" "}

  **Example:** `YOUR_SECRET_KEY`{" "}
</ParamField>

<Note>
  ### Additional Notes

  * Deleting an object is a permanent action and cannot be
    undone.
  * Ensure the file path is correct before making the request.
  * The yourFilePath should include the full directory structure along with the filename.
  * If the object does not exist, the API may return an error depending on implementation.
  * Always keep your access credentials secure and avoid exposing them in client-side code.
</Note>

## Response

Returns a JSON object confirming the deletion.

```json theme={null}
{
  "success": true,
  "message": "File deleted successfully",
  "data": {
    "key": "tutorial/docs/todo.txt"
  }
}
```
