Skip to main content
PATCH
/
sandboxes
/
{sandbox_id}
/
files
Rename / Move File
curl --request PATCH \
  --url https://api.declaw.ai/sandboxes/{sandbox_id}/files \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "old_path": "<string>",
  "new_path": "<string>",
  "username": "<string>"
}
'
Renames or moves a file or directory from old_path to new_path inside the sandbox. Works for both files and directories. If new_path is in a different directory, this is equivalent to a move.

Path Parameters

sandbox_id
string
required
The sandbox identifier. Format: sbx-<8 chars>.

Request Body

old_path
string
required
Current absolute path of the file or directory.Example: "/home/user/draft.py"
new_path
string
required
New absolute path (destination). Parent directories must already exist.Example: "/home/user/final.py"
username
string
Unix user performing the rename. Defaults to the envd default user.

Response

Returns the envd rename confirmation as a JSON object.

Example

curl -X PATCH https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/files \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "old_path": "/home/user/draft.py",
    "new_path": "/home/user/final.py"
  }'

Error Responses

StatusCause
400Invalid request body
401Missing or invalid API key
404Sandbox not found
502envd daemon unreachable
503Sandbox has no VM