Update file details
patch
https://api.imagekit.io
/v1/files/:fileId/details
Update file details API

Response structure and status code

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

Examples

Tags and custom coordinate update

cURL
Node.js
Python
PHP
Java
Ruby
Go
# 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": [
"tag1", "tag2"
],
"customCoordinates": "10,10,100,100"
}
'
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);
});
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/'
)
updated_detail = imagekit.update_file_details(
file_id="file_id",
options=UpdateFileRequestOptions(remove_ai_tags=['remove-ai-tag-1', 'remove-ai-tag-2'],
webhook_url="url",
tags=["tag1", "tag2"], custom_coordinates="10,10,100,100",
custom_metadata={"test": 11})
)
print("Updated detail-", updated_detail, end="\n\n")
# Raw Response
print(updated_detail.response_metadata.raw)
# print that file's id
print(updated_detail.file_id)
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
);
// Update File Details
$updateData = [
"tags" => ["tag1", "tag2"],
"customCoordinates" => "10,10,100,100"
];
$updateFileDetails = $imageKit->updateFileDetails(
$fileId,
$updateData
);
echo("Updated File Details : " . json_encode($updateFileDetails));
FileUpdateRequest fileUpdateRequest =new FileUpdateRequest("file_id");
List<String> tags=new ArrayList<>();
tags.add("tag1");
tags.add("tag2");
fileUpdateRequest.setTags(tags);
fileUpdateRequest.setCustomCoordinates("10,10,100,100");
Result result=ImageKit.getInstance().updateFileDetail(fileUpdateRequest);
imagekitio = ImageKit::ImageKitClient.new("your_private_key", "your_public_key", "your_url_endpoint")
updated_detail = imagekitio.update_file_details(
"file_id",
{
"tags": ["tag1", "tag2"],
"custom_coordinates": "10,10,100,100"
}
)
resp, err := ik.Media.UpdateFile(ctx, "file_id", media.UpdateFileParam{
Tags: []string{"tag1", "tag2"},
CustomCoordinates: "10,10,100,100",
})

Applying extensions

Request

cURL
Node.js
Python
PHP
Java
Ruby
Go
# The unique fileId of the uploaded file. fileId is returned in response of list files API and upload API.
# Example of using the google-auto-tagging extension
curl -X PATCH "https://api.imagekit.io/v1/files/file_id/details" \
-H 'Content-Type: application/json' \
-u your_private_key: -d'
{
"extensions": [
{
"name": "google-auto-tagging",
"maxTags": 5,
"minConfidence": 95
}
]
}
'
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", {
extensions: [
{
name: "google-auto-tagging",
maxTags: 5,
minConfidence: 95
}
]
}, 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/'
)
updated_detail = imagekit.update_file_details(
file_id="file_id",
options=UpdateFileRequestOptions(extensions = [
{
"name": "google-auto-tagging",
"maxTags": 5,
"minConfidence": 95
}
])
)
print("Updated detail-", updated_detail, end="\n\n")
# Raw Response
print(updated_detail.response_metadata.raw)
# print that file's id
print(updated_detail.file_id)
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
);
// Update File Details
$updateData = [
"extensions" => [
[
"name" => "google-auto-tagging",
"maxTags" => 5,
"minConfidence" => 95
]
]
];
$updateFileDetails = $imageKit->updateFileDetails(
$fileId,
$updateData
);
echo("Updated File Details : " . json_encode($updateFileDetails));
JsonObject extension = new JsonObject();
extension.addProperty("name", "google-auto-tagging");
extension.addProperty("maxTags", 5);
extension.addProperty("minConfidence", 95);
JsonArray extensionArray = new JsonArray();
extensionArray.add(extension);
fileUpdateRequest.setExtensions(extensionArray);
Result result = ImageKit.getInstance().updateFileDetail(fileUpdateRequest);
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
updated_detail = imagekitio.update_file_details(
file_id: "file_id", #required
extension: [
{
name: 'google-auto-tagging',
maxTags: 5,
minConfidence: 95
}
]
)
import (
"github.com/imagekit-developer/imagekit-go/extension"
"github.com/imagekit-developer/imagekit-go/api/uploader"
)
const base64Image = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
resp, err := ik.Uploader.Upload(ctx, base64Image, uploader.UploadParam{
Extensions: []extension.IExtension{
extension.NewAutoTag(extension.GoogleAutoTag, 95, 5),
extension.NewRemoveBg(extension.RemoveBgOption{}),
},
})

Response

/*
"success" status for google-auto-tagging extension having
AITags field synchronously populated.
*/
{
"fileId" : "598821f949c0a938d57563bd",
"type": "file",
"name": "file1.jpg",
"filePath": "/images/products/file1.jpg",
"tags": null,
"AITags" [
{
"name": "saree",
"confidence": 96.2837328,
"source": "google-auto-tagging"
},
{
"name": "traditional clothing",
"confidence": 98.3732228,
"source": "google-auto-tagging"
},
{
"name": "women's wear",
"confidence": 97.7233283,
"source": "google-auto-tagging"
},
{
"name": "ethnic",
"confidence": 99.9928828,
"source": "google-auto-tagging"
}
]
"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",
"mime": "image/jpeg",
"width": 100,
"height": 100,
"size": 100,
"hasAlpha": false,
"createdAt": "2019-08-24T06:14:41.313Z",
"updatedAt": "2019-08-24T06:14:41.313Z",
"extensionStatus": {
"google-auto-tagging": "success"
}
}
Copy link
On this page
patch
Update file details API
Response structure and status code
Examples
Tags and custom coordinate update
Applying extensions