tencent cloud

Smart Media Hosting

Product Introduction
Product Overview
Feature Description
Product Strengths
Use Cases
Basic Concept
Purchase Guide
Quick Start
Create Media Library
Initiate request
Service Level API Document
History
Introduction
API Category
Making API Requests
PaaS Service APIs
Official Cloud Disk APIs
Data Types
Error Codes
Business Level API Document
Introduction
Access Token Operation API
Tenant Space Operation API
File Operation API
Directory or Album Operation API
Recycle Bin Operation API
Quota Operation API
Query Task Operation API
Search Operation API
Historical Version Operations API
Directory and File Batch Operation API
Collection Operation API
Error Codes
SDK Documentation
Android SDK
iOS SDK
HarmonyOS SDK
FAQs
Enterprise Network Disk
Product Introduction
Purchase Guide
Quick Start
FAQs
Service Level Agreement
Glossary

Deletes files

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-01-07 14:15:07

Description

Deleting files.
Note:
Required permissions: admin, space_admin, or delete_file (when the recycle bin is not enabled or Permanent is 0)/delete_file_permanent (when the recycle bin is enabled and Permanent is 1). For details about permissions, see Generate Access Token API.
If the media library has the recycle bin feature enabled, when the Permanent request parameter is not set to 1, this API does not permanently delete files but moves them to the recycle bin. You can permanently delete or restore files in the recycle bin, or directly empty the recycle bin using relevant APIs.

Request

Request Example

DELETE /api/v1/file/`{LibraryId}`/`{SpaceId}`/`{FilePath}`?permanent=`{Permanent}`&access_token=`{AccessToken}`&user_id=`{UserId}`

Request Parameter

Request parameters
Description
Type
Required or Not
LibraryId
Media Library ID, obtained after creating a media library in the media hosting console. See create media library
String
Yes
SpaceId
Space ID
If the media library is in single-tenant mode, then this parameter is fixed as a hyphen (`-`).
If the media library is in multi-tenant mode, this parameter is the space ID returned by the Create Tenant Space API.
String
Yes
FilePath
Complete file path, such as foo/bar2/file.docx. See View File Details
String
Yes
Permanent
When the media library enables the recycle bin, this parameter specifies whether to move the files to the recycle bin or permanently delete the files.
1: Permanently delete, 0: Move to recycle bin. Default is 0.
Integer
No
AccessToken
Access token, see Generate Access Token
String
Yes
UserId
User identity recognition. When the permission corresponding to the access token is administrator permission and the user identity recognition when applying for the access token is empty, it is used to temporarily specify user identity. For details, see Generate Access Token API.
String
No

Request Body

This request does not have a request body.

Response

Response code

Deleted successfully, returns HTTP 204 No Content (when recycle bin is not enabled or after permanent deletion) or HTTP 200 OK (when recycle bin is enabled and the file is moved to Recycle Bin).

Response Body

Empty, no response body (when recycle bin is not enabled or after permanent deletion) or application/json (when recycle bin is enabled and the file is moved to Recycle Bin).
Response body example: (move the file to Recycle Bin after enabling it)
{
"recycledItemId": 392
}
Response body field description:
Response Parameters
Description
Type
recycledItemId
Recycle bin project ID, used to permanently delete or restore a designated project from the recycle bin.
Integer

Error Code

This request operation has no special error messages. For common error messages, see Error Codes.

Practical Case

Case 1: Normal File Deletion in Media Library with Recycle Bin Enabled

Request

DELETE /api/v1/file/smhxxx/spacexxx/hello.txt?access_token=*** HTTP/1.1
Host: smhxxx.api.tencentsmh.cn
User-Agent: curl/8.5.0
Accept: */*


Response

HTTP/1.1 200 OK
Date: Thu, 13 Nov 2025 12:03:07 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 23
Server: nginx/1.29.0
X-Request-Id: 1134a11c72aae4f9436150715ffxxxxx

{"recycledItemId":1221}

Case 2: Permanent Deletion of Files in Media Library With Recycle Bin Feature Enabled

Request

DELETE /api/v1/file/smhxxx/spacexxx/hello.txt?permanent=1&access_token=*** HTTP/1.1
Host: smhxxx.api.tencentsmh.cn
User-Agent: curl/8.5.0
Accept: */*


Response

HTTP/1.1 204 No Content
Date: Thu, 13 Nov 2025 11:59:07 GMT
Server: nginx/1.29.0
X-Request-Id: 31cd0b6354901448bbfff8602fexxxxx


Case 3: Normal File Deletion in Media Library with Recycle Bin Feature Not Enabled

Request

DELETE /api/v1/file/smhxxx/spacexxx/hello.txt?access_token=*** HTTP/1.1
Host: smhxxx.api.tencentsmh.cn
User-Agent: curl/8.5.0
Accept: */*


Response

HTTP/1.1 204 No Content
Date: Thu, 13 Nov 2025 12:06:13 GMT
Server: nginx/1.29.0
X-Request-Id: 39c5971c236e7d49ddd4f383f15xxxxx


Case Four: Deleting a File That Does Not Exist in the Space

Request

DELETE /api/v1/file/smhxxx/spacexxx/path/to/non_existent_file.txt?access_token=*** HTTP/1.1
Host: smhxxx.api.tencentsmh.cn
User-Agent: curl/8.5.0
Accept: */*


Response

HTTP/1.1 404 Not Found
Date: Thu, 13 Nov 2025 12:07:28 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 141
Server: nginx/1.29.0
X-Request-Id: 7ed191d7a75dd90ccc8ff2905d8xxxxx

{"status":404,"code":"FileNotFound","message":"File not found.","requestId":"7ed191d7a75dd90xxxxxf2905d8b6ef1","qualifier":"","revision":""}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백