patch
https://api.imagekit.io
/v1/files/{fileId}/details

This API updates the details or attributes of the current version of the file. You can update tags, customCoordinates, customMetadata, publication status, remove existing AITags and apply extensions using this API.

fileId
string
required

The unique fileId of the uploaded file. fileId is returned in list and search assets API and upload API.

(one of)
removeAITags

An array of AITags associated with the file that you want to remove, e.g. ["car", "vehicle", "motorsports"].

If you want to remove all AITags associated with the file, send a string - "all".

Note: The remove operation for AITags executes before any of the extensions are processed.

webhookUrl
string

The final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. Learn more about the webhook payload structure.

extensions
name
string
required

Specifies the background removal extension.

Allowed value:
remove-bg
options
object
tags
array[string] or null

An array of tags associated with the file, such as ["tag1", "tag2"]. Send null to unset all tags associated with the file.

Example:
["tag1","tag2"]
customCoordinates
string or null

Define an important area in the image in the format x,y,width,height e.g. 10,10,100,100. Send null to unset this value.

customMetadata
object

A key-value data to be associated with the asset. To unset a key, send null value for that key. Before setting any custom metadata on an asset you have to create the field using custom metadata fields API.

Auth
API key
:
Parameters
:
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 PATCH \
--url https://api.imagekit.io/v1/files/fileId/details \
--header 'Accept: application/json' \
--header 'Authorization: Basic 123' \
--header 'Content-Type: application/json' \
--data '{
"removeAITags": [
"car",
"vehicle",
"motorsports"
],
"webhookUrl": "https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a",
"extensions": [
{
"name": "remove-bg",
"options": {
"add_shadow": true
}
},
{
"name": "google-auto-tagging",
"minConfidence": 80,
"maxTags": 10
},
{
"name": "aws-auto-tagging",
"minConfidence": 80,
"maxTags": 10
}
],
"tags": [
"tag1",
"tag2"
],
"customCoordinates": "10,10,100,100",
"customMetadata": {
"brand": "Nike",
"color": "red"
}
}'

Updated file details object.

responses
/
200
fileId
string

Unique identifier of the asset.

type
string

Type of the asset.

Allowed values:
filefile-version
name
string

Name of the asset.

filePath
string

Path of the file. This is the path you would use in the URL to access the file. For example, if the file is at the root of the media library, the path will be /file.jpg. If the file is inside a folder named images, the path will be /images/file.jpg.

tags

An array of tags assigned to the file. Tags are used to search files in the media library.

AITags

An array of tags assigned to the file by auto tagging.

name
string

Name of the tag.

confidence
number

Confidence score of the tag.

source
string

Source of the tag. Possible values are google-auto-tagging and aws-auto-tagging.

versionInfo
object

An object with details of the file version.

id
string

Unique identifier of the file version.

name
string

Name of the file version.

isPrivateFile
boolean

Specifies if the file is private or not.

isPublished
boolean

Specifies if the file is published or not.

customCoordinates

An string with custom coordinates of the file.

url
string

URL of the file.

thumbnail
string

URL of the thumbnail image. This URL is used to access the thumbnail image of the file in the media library.

fileType
string

Type of the file. Possible values are image, non-image.

mime
string

MIME type of the file.

width
number

Width of the file.

height
number

Height of the file.

size
number

Size of the file in bytes.

hasAlpha
boolean

Specifies if the image has an alpha channel.

customMetadata
object

An object with custom metadata for the file.

createdAt
string

Date and time when the file was uploaded. The date and time is in ISO8601 format.

updatedAt
string

Date and time when the file was last updated. The date and time is in ISO8601 format.

extensionStatus
object
google-auto-tagging
string
Allowed values:
successpendingfailed
aws-auto-tagging
string
Allowed values:
successpendingfailed
remove-bg
string
Allowed values:
successpendingfailed
1
{
2
"fileId": "598821f949c0a938d57563bd",
3
"type": "file",
4
"name": "file1.jpg",
5
"filePath": "/images/products/file.jpg",
6
"isPublished": true,
7
"tags": [
8
"t-shirt",
9
"round-neck",
10
"sale2019"
11
],
12
"AITags": [
13
{
14
"name": "Shirt",
15
"confidence": 90.12,
16
"source": "google-auto-tagging"
17
},
18
{
19
"name": "T-shirt",
20
"confidence": 80.12,
21
"source": "aws-auto-tagging"
22
}
23
],
24
"versionInfo": {
25
"id": "598821f949c0a938d57563bd",
26
"name": "Version 1"
27
},
28
"isPrivateFile": false,
29
"customCoordinates": null,
30
"url": "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313",
31
"thumbnail": "https://ik.imagekit.io/your_imagekit_id/images/products/file.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail",
32
"fileType": "image",
33
"mime": "image/jpeg",
34
"width": 100,
35
"height": 100,
36
"size": 100,
37
"hasAlpha": false,
38
"customMetadata": {
39
"brand": "Nike",
40
"color": "red"
41
},
42
"createdAt": "2019-08-24T06:14:41.313Z",
43
"updatedAt": "2019-08-24T06:14:41.313Z",
44
"extensionStatus": {
45
"google-auto-tagging": "success",
46
"remove-bg": "pending"
47
}
48
}

Webhook payload structure

When you include a webhookUrl parameter in your update or upload API calls, the final status of extensions after they have completed execution will be delivered to this endpoint as a POST request. The payload will contain the following fields:

Request Field Description
serviceName of the extension.
statusFinal status of the extension execution. Can be either SUCCESS or FAILURE.
fileObject
(for success responses only)
The result of a Get File Details API call that you would receive after completion of this extension.
fileId
(for failure responses only)
Unique id associated with the file on which the extension was attempted.
error
(for failure responses only)
Error object indicating the cause of failure.

ImageKit expects a response with a status code 200 from your webhook endpoint. Any other status code will be interpreted as a failure and may trigger a retry. Not receiving a response in 30 seconds will also be interpreted as a failure. ImageKit will attempt webhook retries for a maximum of 24 hours in spaced intervals.

See example payloads:

Copy
// A success webhook request for a background removal extension
{
    "service": "remove-bg",
    "status": "SUCCESS",
    "fileObject": {
        "fileId": "5effaa5662679b5af2c58829",
        /*
        ... rest of the fields in a file object
        */
    },
}

Examples

Tags and custom coordinate update

Copy
# 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",
})
var imagekit = new ImageKit({
    publicKey : "your_public_api_key",
    privateKey : "your_private_api_key",
    urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
FileUpdateRequest updateob = new FileUpdateRequest
{
    fileId = "fileId",
};
List<string> updatetags = new List<string>
{
    "tag1",
    "tag2"
};
updateob.tags = updatetags;
string updatecustomCoordinates = "10,10,100,100";
updateob.customCoordinates = updatecustomCoordinates;
Result updateresp = imagekit.UpdateFileDetail(updateob);

Changing the publication status of a file

Copy
# 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'
{
    "publish": {
        "isPublished": true,
        "includeFileVersions": false
    }
}
'

Applying extensions

Request

Copy
# 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{}),
    },
})

var imagekit = new ImageKit({
    publicKey : "your_public_api_key",
    privateKey : "your_private_api_key",
    urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
FileUpdateRequest updateob = new FileUpdateRequest
    {
     fileId = "fileId",
    };
List<Extension> extModel = new List<Extension>();
BackGroundImage bck = new BackGroundImage
    {
        name = "remove-bg",
        options = new options() { add_shadow = true, semitransparency = false, bg_color = "green" }
    };
extModel.Add(bck);
updateob.extensions = extModel;
Result updateresp = imagekit.UpdateFileDetail(updateob);

Response

Copy
/*
    "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?updatedAt=1566630881313",
    "thumbnail": "https://ik.imagekit.io/your_imagekit_id/images/products/file1.jpg?updatedAt=1566630881313&tr=n-ik_ml_thumbnail",
    "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"
    }
}