Documentation deprecated: This documentation is no longer being updated as of 3.8.0. For up-to-date information, see the guide information in the IBM Developer Community and the endpoint reference in IBM API Explorer.

/files/delete

Delete the specified paths and directories. To delete files by using bearer token authentication, use the /files endpoint.

Requirements
  • Available as of Enterprise Server version 3.0.0.
Access Control
  • HTTP Basic Auth
    Users who authenticate with Node API credentials can delete items in paths that are within their docroot. Access key users can delete items in paths that are within the path set in the access key.
URL
POST https://{domain}:9092/files/delete

Sample Request
curl -i -u user:secret -X POST https://{domain}:9092/files/delete \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d @request_body.json

Where request_body.json contains the following:
{
    "paths" : [
        {
            "path" : "/fullpath/file1"
        },
        {
            "path" : "/fullpath/directory1",
            "recursive_delete" : "false"
        }
    ]
}

Headers
Header Name Required Description Values
Content-Type Optional The format of the request data. application/json
Accept Optional The format of the response data. application/json
Request Body
Element Required Type Description
paths Required String JSON array of full paths to the files and directories to delete.
path Required String The full path to the file or directory to delete.
recursive_delete Optional Boolean Set the behavior for deleting non-empty directories. Default: true, to delete directories even if they are non-empty. Set to false to not delete non-empty directories and return an error.
Sample Response
HTTP/1.1 200 OK
{
    "paths" : [
        {
            "path" : "/fullpath/file1"
        },
        {
            "path" : "/fullpath/directory1",
            "error" : {
                "code" : 404,
                "reason" : "Not Found",
                "user_message" : "No such file or directory"
        },
    ]
}

Status Codes and Errors
Code Description Notes
200 OK Success The server responded to the request. Individual files and directories might not be deleted and are reported in the response body.
400 Bad Request Error Request contains a formatting or syntax error.
403 Error The directory cannot be deleted because it contains files that are in use.
404 Not Found Error The file could not be found.
409 Directory Not Empty Error The directory is not empty and recursive_delete is set to false.
500 Internal Server Error Error The server configuration is invalid.
Response
Element Type Description
paths String JSON array of full paths to the files and directories in the request body.
path String The full path to the file or directory.
error String If file or directory deletion fails, a JSON array that contains details about the error.
code Unsigned integer Error code.
reason String Short description of error.
user_message String Longer description of error.
Video player

Video

×