Box Developer Documentation
Latest version

Delete file

delete
https://api.box.com/2.0
/files/:file_id

This endpoint is in the version 2024.0. No changes are required to continue using it. For more details, see Box API versioning.

Deletes a file, either permanently or by moving it to the trash.

The enterprise settings determine whether the item will be permanently deleted from Box or moved to the trash.

Request

bearer [ACCESS_TOKEN]
application/json

Request Headers

stringin headeroptional
1

Ensures this item hasn't recently changed before making changes.

Pass in the item's last observed etag value into this header and the endpoint will fail with a 412 Precondition Failed if it has changed since.

Path Parameters

stringin pathrequired
12345

The unique identifier that represents a file.

The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL https://*.app.box.com/files/123 the file_id is 123.

Response

none

Returns an empty response when the file has been successfully deleted.

application/jsonClient error

Returned when the access token provided in the Authorization header is not recognized or not provided.

application/jsonClient error

Returned if the file is not found or has already been deleted, or the user does not have access to the file.

application/jsonClient error

Returned if the file_id is not in a recognized format.

application/jsonClient error

Returns an error when the If-Match header does not match the current etag value of the file. This indicates that the file has changed since it was last requested.

application/jsonClient error

An unexpected client error.

delete
Delete file
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

Learn more about Box SDK versioning strategy.


cURL
curl -i -X DELETE "https://api.box.com/2.0/files/12345" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
Node/TypeScript v10
await client.files.deleteFileById(thumbnailFile.id);
Python v10
client.files.delete_file_by_id(thumbnail_file.id)
.NET v10
await client.Files.DeleteFileByIdAsync(fileId: thumbnailFile.Id);
Swift v10
try await client.files.deleteFileById(fileId: thumbnailFile.id)
Java v10
client.getFiles().deleteFileById(thumbnailFile.getId())
Java v4
BoxFile file = new BoxFile(api, "id");
file.delete();
Python v3
client.file(file_id='11111').delete()
.NET v5
await client.FilesManager.DeleteAsync(id: "11111");
Node v3
client.files.delete('11111', { etag: '5' })
	.then(() => {
		// File successfully deleted
	})
	.catch(err => {
		if (err.statusCode === 412) {
			// Precondition failed — the file was modified before the deletion was processed
			// Read the file again to ensure it is safe to delete and then retry
		}
	});