Update file details

patch
Update file details API

https://api.imagekit.io/v1/files/:fileId/details
Update file details such as tags and customCoordinates attribute using update file detail API.
Request
Response
Request
Path Parameters
fileId
required
string
The unique fileId of the uploaded file. fileId is returned in list files API and upload API.
Headers
Authorization
required
string
base64 encoding of your_private_api_key: Note the colon in the end.
Body Parameters
tags
optional
array
An array of tags associated with the file e.g. ["tag1", "tag2"]. If you want to unset it send null.
customCoordinates
optional
string
Define an important area in the image in the format x,y,width,height e.g. 10,10,100,100. If you want to unset this send null.
Response
200: OK
On success, you will receive the updated file details in the JSON-encoded response body.
{
"fileId" : "598821f949c0a938d57563bd",
"type": "file",
"name": "file1.jpg",
"filePath": "/images/products/file1.jpg",
"tags": ["t-shirt","round-neck","sale2019"],
"isPrivateFile" : false,
"customCoordinates" : null,
"url": "https://ik.imagekit.io/your_imagekit_id/images/products/file1.jpg",
"thumbnail": "https://ik.imagekit.io/your_imagekit_id/tr:n-media_library_thumbnail/images/products/file1.jpg",
"fileType": "image",
"createdAt": "2019-08-24T06:14:41.313Z"
}

Response structure and status code

In case of error, you will get an error code along with the error message. On success, you will receive a 200 status code with the updated file details in JSON-encoded response body.

Understanding response

Proper name

Description

fileId

The unique fileId of the uploaded file.

type

Type of item. It can either be file or folder.

name

Name of the file or folder.

filePath

The relative path of the file. In the case of an image, you can use this path to construct different transformations.

tags

Array of tags associated with the image. If no tags are set, this will be null.

isPrivateFile

Is the file marked as private. It can be either true or false.

customCoordinates

Value of custom coordinates associated with the image in format x,y,width,height. If customCoordinates are not defined, it will be null.

url

A publicly accessible URL of the file.

thumbnail

In case of an image, a small thumbnail URL.

fileType

The type of file, it could be either image or non-image.

createdAt

The date and time when the file was first uploaded. The format is YYYY-MM-DDTHH:mm:ss.sssZ

Examples

Here is the example request to understand the API usage.

cURL
Node.js
Python
PHP
Java
Ruby
cURL
# The unique fileId of the uploaded file. fileId is returned in response of list files API and upload API.
curl -X PATCH "https://api.imagekit.io/v1/files/fileId/details" \
-H 'Content-Type: application/json' \
-u your_private_key: -d'
{
"tags": [
"image_tag"
],
"customCoordinates": "10,10,100,100"
}
'
Node.js
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.updateFileDetails("file_id", {
tags : ['image_tag'],
customCoordinates : "10,10,100,100"
}, function(error, result) {
if(error) console.log(error);
else console.log(result);
});
Python
from imagekitio import ImageKit
​
imagekit = ImageKit(
private_key='your_public_api_key',
public_key='your_private_api_key',
url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
)
​
updated_detail = imagekit.update_file_details(
"file_id",
{"tags": ["image_tag"], "custom_coordinates": "10,10,100,100"},
)
​
print("Updated detail-", updated_detail, end="\n\n")
PHP
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
);
​
$updateFileDetails = $imageKit->updateFileDetails("file_id", array("tags" => ['image_tag'], "customCoordinates" => "10,10,100,100"));
​
echo("Updated detail : " . json_encode($updateFileDetails));
Java
FileUpdateRequest fileUpdateRequest =new FileUpdateRequest("file_id");
List<String> tags=new ArrayList<>();
tags.add("image_tag");
fileUpdateRequest.setTags(tags);
fileUpdateRequest.setCustomCoordinates("10,10,100,100");
Result result=ImageKit.getInstance().updateFileDetail(fileUpdateRequest);
Ruby
imagekitio = ImageKit::ImageKitClient.new("your_private_key", "your_public_key", "your_url_endpoint")
updated_detail = imagekitio.update_file_details(
"file_id",
{
"tags": ['image_tag'],
"custom_coordinates": "10,10,100,100"
}
)