---
title: "Delete a media item"
method: DELETE
path: "/buckets/{slug}/media/{media_id}"
tags: ["Media"]
---

# Delete a media item

`DELETE /buckets/{slug}/media/{media_id}`

## Request

- Base URL: `https://api.cosmicjs.com/v3`
- URL: `https://api.cosmicjs.com/v3/buckets/{slug}/media/{media_id}`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/cosmicjs/apis/cosmic-rest-api-v3/docs/buckets/:slug/media/:media_id/delete.ts> (a function with typed inputs; its response is checked against the schema)

Delete a media item from the Bucket. The file is removed from storage and the CDN caches are purged, so its URL stops working. Objects and Metafields that reference the media are not updated automatically: clear those references yourself. This is destructive and not reversible through the API.

## Query parameters

- `trigger_webhook` boolean

## Response `200`

The media item was deleted.

- MessageResponse: Returned by delete operations.
  - `message` string, required

## Other responses

- `401`: The access key is missing or incorrect.
- `402`: The Bucket needs to be upgraded before it can be used again.
- `404`: The addressed resource does not exist in this Bucket. Note that this covers a resource missing from a route that exists; an unrecognized route answers 200 with a `Route not found` body instead, as described in the API description above.
- `429`: Too many requests hit the API too quickly. Back off and retry.
- `500`: Something went wrong on the Cosmic side.

---

[API](https://skmtc.dev/cosmicjs/apis/cosmic-rest-api-v3.md) - [All operations](https://skmtc.dev/cosmicjs/apis/cosmic-rest-api-v3/llms.txt) - [OpenAPI document](https://skmtc.dev/cosmicjs/apis/cosmic-rest-api-v3/revisions/e0aa2a0913b3?raw)
