---
title: "Delete image from storage"
description: "Delete an image file from Cloudflare R2 storage.\nIncludes security checks to ensure the file belongs to the specified workspace.\n"
---

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

Path: Channel Automation API › Media

`DELETE /api/media/delete`

Delete an image file from Cloudflare R2 storage.
Includes security checks to ensure the file belongs to the specified workspace.

## Authentication

Requires one of the following:

- `bearerAuth`
- `apiKey`

## Request body

_Required._

- `fileName` (`delete/api/media/delete.fileName`; string, required) — File name/key to delete
  - example `"sequences/workspace123/abc123-def456.jpg"`
- `workspaceId` (`delete/api/media/delete.workspaceId`; string, required) — Workspace ID for authorization
  - example `"workspace-123"`

## Example request

```json
{
  "fileName": "sequences/workspace123/abc123-def456.jpg",
  "workspaceId": "workspace-123"
}
```

## Code samples

### cURL

```bash
curl --request DELETE \
  --url https://api.channelautomation.com/api/media/delete \
  --header 'Content-Type: application/json' \
  --data '
{
  "fileName": "sequences/workspace123/abc123-def456.jpg",
  "workspaceId": "workspace-123"
}
'
```

### TypeScript

```typescript
const url = 'https://api.channelautomation.com/api/media/delete';
const options = {
  method: 'DELETE',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    fileName: 'sequences/workspace123/abc123-def456.jpg',
    workspaceId: 'workspace-123'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.channelautomation.com/api/media/delete"

payload = {
    "fileName": "sequences/workspace123/abc123-def456.jpg",
    "workspaceId": "workspace-123"
}
headers = {"Content-Type": "application/json"}

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

print(response.text)
```

## Responses

### 200

Image deleted successfully

#### Example

```json
{
  "success": true,
  "fileName": "sequences/workspace123/abc123-def456.jpg"
}
```

- `success` (`delete/api/media/delete.response.200.success`; boolean, optional) — Whether the deletion was successful
- `fileName` (`delete/api/media/delete.response.200.fileName`; string, optional) — Name of the deleted file

### 400

Bad request

#### Example

```json
{
  "success": false,
  "error": "File name is required"
}
```

- `success` (`delete/api/media/delete.response.400.success`; boolean, optional)
  - example `false`
- `error` (`delete/api/media/delete.response.400.error`; string, optional) — Error message

### 403

Unauthorized - file doesn't belong to workspace

#### Example

```json
{
  "success": false,
  "error": "Unauthorized: File does not belong to this workspace"
}
```

- `success` (`delete/api/media/delete.response.403.success`; boolean, optional)
  - example `false`
- `error` (`delete/api/media/delete.response.403.error`; string, optional) — Error message

### 500

Server error

#### Example

```json
{
  "success": false,
  "error": "Failed to delete image"
}
```

- `success` (`delete/api/media/delete.response.500.success`; boolean, optional)
  - example `false`
- `error` (`delete/api/media/delete.response.500.error`; string, optional) — Error message


Source: https://developer.channelautomations.com/api/delete-api-media-delete/index.md
