POST /v1/agents/runtime/{runtime_id}/files/delete
from gravixlayer import GravixLayer
client = GravixLayer() # defaults to cloud="aws", region="us-east-1"
sandbox = client.runtime.create() # defaults to template="base-small"
# Create the file first so we have something to delete
sandbox.file.write("/workspace/temp.txt", "temporary\n")
response = sandbox.file.delete("/workspace/temp.txt")
print(response.message)
# A directory requires recursive=True
sandbox.file.delete("/workspace/tmp", recursive=True)
sandbox.kill()
import { GravixLayer } from 'gravixlayer';
const client = new GravixLayer(); // defaults to cloud="aws", region="us-east-1"
const sandbox = await client.runtime.create(); // defaults to template="base-small"
// Create the file first so we have something to delete
await sandbox.file.write("/workspace/temp.txt", "temporary\n");
const response = await sandbox.file.delete("/workspace/temp.txt");
console.log(response.message);
// A directory requires recursive: true
await sandbox.file.delete("/workspace/tmp", { recursive: true });
await sandbox.kill();
gravixlayer runtime files rm "$RT" /tmp/hello.txt
# Directories need --recursive (-r); -y skips the confirmation prompt
gravixlayer runtime files rm "$RT" /workspace/tmp -r -y
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/files/delete" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "/tmp/hello.txt"}'
# A directory needs "recursive": true
curl -X POST "https://api.gravixlayer.ai/v1/agents/runtime/$RT/files/delete" \
-H "Authorization: Bearer $GRAVIXLAYER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"path": "/workspace/tmp", "recursive": true}'
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
path | string | Yes | File or directory path |
recursive | boolean | No | Required to delete a directory and its contents (default false) |
Response
| Field | Type | Description |
|---|---|---|
message | string | Confirmation message |
path | string | Deleted path |