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

# Delete Media

> Delete an uploaded image or video from your account

## Request

### Headers

<ParamField header="Authorization" type="string" required>
  Your API key in the format: `Bearer imperial_live_xxxxxxxxxxxxx`
</ParamField>

### Path Parameters

<ParamField path="id" type="string" required>
  The unique identifier of the media to delete
</ParamField>

## Response

<ResponseField name="message" type="string">
  Confirmation message
</ResponseField>

## Example Requests

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://api.imperial.gay/images/67d8f9a1b2c3d4e5f6789012 \
    -H "Authorization: Bearer imperial_live_xxxxxxxxxxxxx"
  ```

  ```javascript Node.js theme={null}
  const axios = require("axios");

  const imageId = "67d8f9a1b2c3d4e5f6789012";

  const response = await axios.delete(`https://api.imperial.gay/images/${imageId}`, {
    headers: {
      Authorization: "Bearer imperial_live_xxxxxxxxxxxxx",
    },
  });

  console.log(response.data);
  ```

  ```python Python theme={null}
  import requests

  image_id = '67d8f9a1b2c3d4e5f6789012'
  url = f'https://api.imperial.gay/images/{image_id}'
  headers = {'Authorization': 'Bearer imperial_live_xxxxxxxxxxxxx'}

  response = requests.delete(url, headers=headers)
  print(response.json())
  ```
</CodeGroup>

## Example Response

```json theme={null}
{
  "message": "Image deleted successfully"
}
```

## What Gets Deleted

When you delete media, the following are removed:

* **The media file** from Cloudflare R2 storage
* **Video thumbnails** (if applicable)
* **Database records** associated with the upload
* **Storage quota** is freed up for new uploads

<Warning>
  Deletion is permanent and cannot be undone. The CDN URL will stop working immediately.
</Warning>

## Operations Count

Deleting media counts as **1 operation** towards your monthly limit. This ensures accurate tracking of all API activity.

## Bulk Deletion

To delete multiple files, make separate DELETE requests for each item:

```javascript Node.js theme={null}
const imageIds = [
  "67d8f9a1b2c3d4e5f6789012",
  "67d8f9a1b2c3d4e5f6789013",
  "67d8f9a1b2c3d4e5f6789014",
];

// Delete in parallel
await Promise.all(
  imageIds.map((id) =>
    axios.delete(`https://api.imperial.gay/images/${id}`, {
      headers: {
        Authorization: "Bearer imperial_live_xxxxxxxxxxxxx",
      },
    })
  )
);
```

## Error Responses

### Not Found

```json theme={null}
{
  "error": "Image not found",
  "statusCode": 404
}
```

### Unauthorized

```json theme={null}
{
  "error": "Unauthorized",
  "statusCode": 401
}
```

### Forbidden

If you try to delete media that doesn't belong to you:

```json theme={null}
{
  "error": "You don't have permission to delete this image",
  "statusCode": 403
}
```

## Storage Recovery

After deletion, your storage quota is immediately updated. You can verify this by checking your account statistics:

```bash theme={null}
curl -X GET https://api.imperial.gay/stats/overview \
  -H "Authorization: Bearer imperial_live_xxxxxxxxxxxxx"
```

## Best Practices

<Tip>
  **Storage Management**: Regularly delete unused media to free up storage space for new uploads.
</Tip>

<Warning>
  **External Links**: If you've shared CDN URLs externally (in websites, apps, etc.), deleting the
  media will break those links.
</Warning>

<Info>
  **Dashboard**: You can also delete media through the [Dashboard](https://app.imperial.gay/images)
  interface with bulk selection support.
</Info>
