Skip to main content

DELETE /api/wallpapers/[public_id]

Delete a specific wallpaper from Cloudinary storage using its public ID.
This endpoint requires Cloudinary API credentials and is intended for administrative use only. Regular users should not have access to delete wallpapers.

Request

Path parameters

public_id
string
required
The Cloudinary public ID of the wallpaper to delete

Example request

cURL
curl -X DELETE https://wallwidgy.vercel.app/api/wallpapers/wallpapers/sample-wallpaper

Response

Success response

message
string
Success message confirming the wallpaper was deleted
{
  "message": "Wallpaper deleted successfully"
}

Error responses

{
  "error": "Failed to delete from Cloudinary"
}
Returned when the Cloudinary deletion operation fails.

Implementation

This endpoint uses the Cloudinary SDK to delete images:
const result = await cloudinary.uploader.destroy(params.public_id);

if (result.result === 'ok') {
  return NextResponse.json({ message: 'Wallpaper deleted successfully' });
} else {
  throw new Error('Failed to delete from Cloudinary');
}

Authentication

This endpoint requires valid Cloudinary API credentials configured in environment variables:
  • CLOUDINARY_CLOUD_NAME
  • CLOUDINARY_API_KEY
  • CLOUDINARY_API_SECRET
This is an administrative endpoint. In production, you should add authentication middleware to restrict access to authorized administrators only.

Build docs developers (and LLMs) love