Files: delete

Stay organized with collections Save and categorize content based on your preferences.

Permanently deletes a file by ID. Skips the trash. The currently authenticated user must own the file or be an organizer on the parent for shared drive files. Try it now or see an example.


HTTP request



Parameter name Value Description
Path parameters
fileId string The ID of the file to delete.
Optional query parameters
enforceSingleParent boolean Deprecated. If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root. (Default: false)
supportsAllDrives boolean Whether the requesting application supports both My Drives and shared drives. (Default: false)
supportsTeamDrives boolean Deprecated use supportsAllDrives instead. (Default: false)


This request requires authorization with at least one of the following scopes:


Some scopes are restricted and require a security assessment for your app to use them. For more information, see the authentication and authorization page.

Request body

Do not supply a request body with this method.


If successful, this method returns an empty response body.


Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).


Uses the Java client library.


// ...

public class MyClass {

  // ...

   * Permanently delete a file, skipping the trash.
   * @param service Drive API service instance.
   * @param fileId ID of the file to delete.
  private static void deleteFile(Drive service, String fileId) {
    try {
    } catch (IOException e) {
      System.out.println("An error occurred: " + e);

  // ...



Uses the .NET client library.

using Google.Apis.Drive.v2;
using Google.Apis.Drive.v2.Data;

using System.Net;
// ...

public class MyClass {

  // ...

  /// <summary>
  /// Permanently delete a file, skipping the trash.
  /// </summary>
  /// <param name="service">Drive API service instance.</param>
  /// <param name="fileId">ID of the file to delete.</param>
  public static void DeleteFile(DriveService service, String fileId) {
    try {
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);

  // ...



Uses the PHP client library.

 * Permanently delete a file, skipping the trash.
 * @param Google_Service_Drive $service Drive API service instance.
 * @param String $fileId ID of the file to delete.
function deleteFile($service, $fileId) {
  try {
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();


Uses the Python client library.

from apiclient import errors
# ...

def delete_file(service, file_id):
  """Permanently delete a file, skipping the trash.

    service: Drive API service instance.
    file_id: ID of the file to delete.
  except errors.HttpError, error:
    print 'An error occurred: %s' % error


Uses the JavaScript client library.

 * Permanently delete a file, skipping the trash.
 * @param {String} fileId ID of the file to delete.
function deleteFile(fileId) {
  var request ={
    'fileId': fileId
  request.execute(function(resp) { });


Uses the Go client library.

import (

// DeleteFile deletes a file, skipping the trash
func DeleteFile(d *drive.Service, fileId string) error {
  err := d.Files.Delete(fileId).Do()
  if err != nil {
    fmt.Printf("An error occurred: %v\n", err)
    return err
  return nil


Uses the Objective-C client library.

#import "GTLDrive.h"
// ...

+ (void)deleteFileWithService:(GTLServiceDrive *)service
                       fileId:(NSString *)fileId {
  GTLQueryDrive *query = [GTLQueryDrive queryForFilesDeleteWithFileId:fileId];
  // queryTicket can be used to track the status of the request.
  GTLServiceTicket *queryTicket =
    [service executeQuery:query
        completionHandler:^(GTLServiceTicket *ticket, id object,
                            NSError *error) {
          if (error != nil) {
            NSLog(@"An error occurred: %@", error);

// ...

Try it!

Use the APIs Explorer below to call this method on live data and see the response.