Delete file or folder

Delete a file or folder.

Note: Deleting a parent folder will automatically delete its contents

Request

  • Method: DELETE
  • Server: https://[app key here]-[site_ID here]-apps.worldsecuresystems.com. Take a look at the Authorize your API calls document for more info on how this URL is formed.
    • Note: When building apps always use relative request URLs. Do not use the "full" URL above because you might have problems running your app on a different site as the site_ID parameter will be different.
  • Path: /api/v2/admin/sites/{siteId}/storage/{path}?version=draft&force=true|false
  • Authorization header: This should contain the authorization token. Here is how to obtain the token.
  • Required Permissions: Can use SFTP & File Manager

Optional query params

Param name Values Description
version draft If the page has a draft version, then the draft will be deleted. If it is a folder or not a page, than it will be ignored
force true, false In case of folders, a value of false prevents folder delete if the folder is not empty. Error throws is 403, with sub error code 104024

Response

Returns a status Code

Accepts and returns JSON as Content-Type.

Request:

DELETE /api/v2/admin/sites/current/storage/images/cat.jpg HTTPS/1.1
Accept: application/json
Authorization: c50f6e6be0d1481ca0d8eb0c63642fdd171c17846af04cdd95676a0888141f73

Response:

HTTP/1.1 200 OK

Sample code

Delete a particular file

var request = $.ajax({
    url: "/api/v2/admin/sites/current/storage/images/testing/description2.txt",
    type: "DELETE",
    headers: {
        "Authorization": $.cookie('access_token')
    }    
});  

Delete a folder

var request = $.ajax({
    url: "/api/v2/admin/sites/current/storage/images/testing",
    type: "DELETE",
    headers: {
        "Authorization": $.cookie('access_token')
    }    
});  

Error codes

This method will return the following error codes:

  • 200 - OK
  • 400 - Bad request:
    • 104000 - Generic FileAPI error
    • 104001 - File not found
    • 104003 - Not enough privileges
    • 104004 - Invalid login multiple sites
    • 104009- Path not found
    • 104010 - Destination path not found
    • 104011 - Web page in workflow deleted, if trying to delete a page in workflow
    • 104014 - Name required
    • 104020 - Folder reserved
    • 104023 - Unauthorized access
    • 104024 - Folder not empty
  • 401- when authentication token is incorrect
  • 403 - sub error code 104024 when false flag was set to false, and you are attempting to delete a folder that is not empty
  • 404 - resource does not exist