JavaScript
import GboxSDK from "gbox-sdk";
const gboxSDK = new GboxSDK({
apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});
async function main() {
const box = await gboxSDK.create({ type: "linux" });
// prepare: write a file
await box.fs.write({
path: "/tmp/example.txt",
content: "Hello, world!",
});
// Delete a file
const deleteResult = await box.fs.remove({
path: "/tmp/example.txt",
});
console.log("File deleted successfully:", deleteResult.message);
}
main();import os
from gbox_sdk import GboxSDK
def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])
box = gbox_sdk.create(type="linux")
# prepare: write a file
box.fs.write(
path="/tmp/example.txt",
content="Hello, world!"
)
# Delete a file
delete_result = box.fs.remove(
path="/tmp/example.txt"
)
print("File deleted successfully:", delete_result.message)
if __name__ == "__main__":
main()curl --request DELETE \
--url https://gbox.ai/api/v1/boxes/{boxId}/fs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": "/home/user/documents/output.txt"
}
'{
"message": "File/Directory deleted successfully"
}File System
Delete box file/dir
Deletes a file or a directory. If target path doesn’t exist, the delete will fail.
DELETE
/
boxes
/
{boxId}
/
fs
JavaScript
import GboxSDK from "gbox-sdk";
const gboxSDK = new GboxSDK({
apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});
async function main() {
const box = await gboxSDK.create({ type: "linux" });
// prepare: write a file
await box.fs.write({
path: "/tmp/example.txt",
content: "Hello, world!",
});
// Delete a file
const deleteResult = await box.fs.remove({
path: "/tmp/example.txt",
});
console.log("File deleted successfully:", deleteResult.message);
}
main();import os
from gbox_sdk import GboxSDK
def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])
box = gbox_sdk.create(type="linux")
# prepare: write a file
box.fs.write(
path="/tmp/example.txt",
content="Hello, world!"
)
# Delete a file
delete_result = box.fs.remove(
path="/tmp/example.txt"
)
print("File deleted successfully:", delete_result.message)
if __name__ == "__main__":
main()curl --request DELETE \
--url https://gbox.ai/api/v1/boxes/{boxId}/fs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"path": "/home/user/documents/output.txt"
}
'{
"message": "File/Directory deleted successfully"
}Authorizations
Enter your API Key in the format: Bearer . Get it from https://gbox.ai
Path Parameters
Box ID
Example:
"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"
Body
application/json
Request parameters for deleting a file/directory
Target path in the box. If the path does not start with '/', the file/directory will be deleted relative to the working directory. If the target path does not exist, the delete will fail.
Example:
"/home/user/documents/output.txt"
Working directory. If not provided, the file will be read from the box.config.workingDir directory.
Example:
"/home/user/documents"
Response
Delete file/dir
Response after deleting file/directory
Success message
Example:
"File/Directory deleted successfully"
Was this page helpful?