post
https://api.imagekit.io
/v1/files/move

This will move a file and all its versions from one folder to another.

Note: If any file at the destination has the same name as the source file, then the source file and its versions will be appended to the destination file.

sourceFilePath
string
required

The full path of the file you want to move.

Example:
/path/to/file.jpg
destinationPath
string
required

Full path to the folder you want to move the above file into.

Example:
/folder/to/move/into/
Auth
API key
:
Body
Note

Here, you can explore machine-generated code examples. For practical applications, refer to the examples section below, which includes detailed code snippets from the ImageKit SDKs.

curl --request POST \
--url https://api.imagekit.io/v1/files/move \
--header 'Accept: application/json' \
--header 'Authorization: Basic 123' \
--header 'Content-Type: application/json' \
--data '{
"sourceFilePath": "/path/to/file.jpg",
"destinationPath": "/folder/to/move/into/"
}'

File moved successfully.

1
{}

Examples

Here is the example request to understand the API usage.

Copy
curl -X POST "https://api.imagekit.io/v1/files/move" \
-H 'Content-Type: application/json' \
-u your_private_key: -d '
{
	"sourceFilePath" : "/path/to/file.jpg",
	"destinationPath" : "/folder/to/move/into/"
}
'
var ImageKit = require("imagekit");

var imagekit = new ImageKit({
    publicKey : "your_public_api_key",
    privateKey : "your_private_api_key",
    urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});

imagekit.moveFile({
     sourceFilePath: "/path/to/file.jpg",
     destinationPath: "/folder/to/move/into/"
}, function(error, result) {
    if(error) console.log(error);
    else console.log(result);
});
from imagekitio import ImageKit

imagekit = ImageKit(
    public_key='your_public_api_key',
    private_key='your_private_api_key',
    url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
)

move_file = imagekit.move_file(options=MoveFileRequestOptions(source_file_path="/file.jpg",
                                                              destination_path="/test"))

print("Move file-", move_file, end="\n\n")

# Raw Response
print(move_file.response_metadata.raw)
use ImageKit\ImageKit;

$public_key = "your_public_api_key";
$your_private_key = "your_private_api_key";
$url_end_point = "https://ik.imagekit.io/your_imagekit_id";

$imageKit = new ImageKit(
    $public_key,
    $your_private_key,
    $url_end_point
);

$sourceFilePath = '/path/to/file.jpg';
$destinationPath = '/folder/to/move/into/';
$moveFile = $imageKit->move([
    'sourceFilePath' => $sourceFilePath,
    'destinationPath' => $destinationPath
]);

echo("Move File : " . json_encode($moveFile));
MoveFileRequest moveFileRequest = new MoveFileRequest();
moveFileRequest.setSourceFilePath("/path/to/file.jpg");
moveFileRequest.setDestinationPath("/folder/to/move/into/");
ResultNoContent resultNoContent = ImageKit.getInstance().moveFile(moveFileRequest);
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
imagekitio.move_file(
  source_file_path: '/path/to/file.jpg',
  destination_path: '/folder/to/move/into/'
)
resp, err := ik.Media.MoveFile(ctx, media.MoveFileParam{
    SourcePath: "/path/to/file.jpg",
    DestinationPath: "/folder/to/move/into/",
})
var imagekit = new ImageKit({
    publicKey : "your_public_api_key",
    privateKey : "your_private_api_key",
    urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
MoveFileRequest moveFile = new MoveFileRequest
    {
        sourceFilePath = "/path/to/file.jpg",
        destinationPath = "/folder/to/copy/into/"
    };
ResultNoContent resultNoContentMoveFile = imagekit.MoveFile(moveFile);