patch
https://api.imagekit.io
/v1/customMetadataFields/{id}

This API updates the label or schema of an existing custom metadata field.

id
string
required

Should be a valid custom metadata field id.

label
string

Human readable name of the custom metadata field. This should be unique across all non deleted custom metadata fields. This name is displayed as form field label to the users while setting field value on an asset in the media library UI. This parameter is required if schema is not provided.

schema
object

An object that describes the rules for the custom metadata key. This parameter is required if label is not provided. Note: type cannot be updated and will be ignored if sent with the schema. The schema will be validated as per the existing type.

selectOptions
array

An array of allowed values. This property is only required if type property is set to SingleSelect or MultiSelect.

Example:
["small","medium","large",30,40,true]
defaultValue

The default value for this custom metadata field. This property is only required if isValueRequired property is set to true. The value should match the type of custom metadata field.

isValueRequired
boolean

Sets this custom metadata field as required. Setting custom metadata fields on an asset will throw error if the value for all required fields are not present in upload or update asset API request body.

minValue

Minimum value of the field. Only set this property if field type is Date or Number. For Date type field, set the minimum date in ISO8601 string format. For Number type field, set the minimum numeric value.

maxValue

Maximum value of the field. Only set this property if field type is Date or Number. For Date type field, set the minimum date in ISO8601 string format. For Number type field, set the minimum numeric value.

minLength
number

Minimum length of string. Only set this property if type is set to Text or Textarea.

maxLength
number

Maximum length of string. Only set this property if type is set to Text or Textarea.

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/customMetadataFields/id \
--header 'Accept: application/json' \
--header 'Authorization: Basic 123' \
--header 'Content-Type: application/json' \
--data '{
"label": "price",
"schema": {
"type": "Number",
"minValue": 1000,
"maxValue": 3000
}
}'

Custom metadata field updated successfully.

responses
/
200
id
string
required

Unique identifier for the custom metadata field. Use this to update the field.

name
string
required

API name of the custom metadata field. This becomes the key while setting customMetadata (key-value object) for an asset using upload or update API.

label
string
required

Human readable name of the custom metadata field. This name is displayed as form field label to the users while setting field value on the asset in the media library UI.

schema
object
required

An object that describes the rules for the custom metadata field value.

type
string
required

Type of the custom metadata field.

Allowed values:
TextTextareaNumberDateBooleanSingleSelectMultiSelect
selectOptions
array

An array of allowed values when field type is SingleSelect or MultiSelect.

Example:
["small","medium","large",30,40,true]
defaultValue

The default value for this custom metadata field. Date type of default value depends on the field type.

isValueRequired
boolean

Specifies if the this custom metadata field is required or not.

minValue

Minimum value of the field. Only set if field type is Date or Number. For Date type field, the value will be in ISO8601 string format. For Number type field, it will be a numeric value.

maxValue

Maximum value of the field. Only set if field type is Date or Number. For Date type field, the value will be in ISO8601 string format. For Number type field, it will be a numeric value.

minLength
number

Minimum length of string. Only set if type is set to Text or Textarea.

maxLength
number

Maximum length of string. Only set if type is set to Text or Textarea.

1
{
2
"id": "598821f949c0a938d57563dd",
3
"name": "price",
4
"label": "price",
5
"schema": {
6
"type": "Number",
7
"minValue": 1000,
8
"maxValue": 3000
9
}
10
}

Examples

Copy
curl -X PATCH "https://api.imagekit.io/v1/customMetadataFields/field_id" \
-H 'Content-Type: application/json' \
-u your_private_key: -d'
{
    "schema": {
        "minValue": 500,
        "maxValue": 2500
    }
}
'
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/"
});

var fieldId = "field_id";
imagekit.updateCustomMetadataField(
    fieldId,
    {
        schema: {
            minValue: 500,
            maxValue: 2500
        }
    }, 
    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/'
)

update_custom_metadata_fields = imagekit.update_custom_metadata_fields(field_id="id", 
                                                 options=UpdateCustomMetadataFieldsRequestOptions(label="test-update",
                                                  schema=CustomMetadataFieldsSchema(
                                                      min_value=100,
                                                      max_value=200))
)

print("Update custom metadata field-", update_custom_metadata_fields, end="\n\n")

# Raw Response
print(update_custom_metadata_fields.response_metadata.raw)

# print the label of updated custom metadata fields
print(update_custom_metadata_fields.label)

# print the schema's min value of updated custom metadata fields
print(update_custom_metadata_fields.schema.min_value)
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
);

$body = [
    "schema" => [
        "minValue" => 500
        "maxValue" => 2500
    ]
];

$customMetadataFieldId = 'field_id';
$updateCustomMetadataField = $imageKit->updateCustomMetadataField($customMetadataFieldId, $body);

echo("Update Custom Metadata Field : " . json_encode($updateCustomMetadataField));
CustomMetaDataFieldSchemaObject schemaObject = new CustomMetaDataFieldSchemaObject();
schemaObject.setMinValue(500);
schemaObject.setMaxValue(2500);

CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest();
customMetaDataFieldUpdateRequest.setId("field_id");
customMetaDataFieldUpdateRequest.setLabel("");
customMetaDataFieldUpdateRequest.setSchema(schemaObject);

ResultCustomMetaDataField resultCustomMetaDataField = ImageKit.getInstance().updateCustomMetaDataFields(customMetaDataFieldUpdateRequest);

imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
imagekitio.update_custom_metadata_field(
  id: 'field_id', #required
  schema: {   #required if label not available
    minValue: 500,
    maxValue: 2500
  }
)
// Atleast Label or Schema is required
resp, err := ik.Metadata.UpdateCustomField(ctx, "field_id", UpdateCustomFieldParam{
    Label: "Cost",
    Schema: {
        MinValue: 100,
        MaxValue: 2500,
    },
})
var imagekit = new ImageKit({
    publicKey : "your_public_api_key",
    privateKey : "your_private_api_key",
    urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
CustomMetaDataFieldUpdateRequest requestUpdateModel = new CustomMetaDataFieldUpdateRequest
{
    Id = "field_Id",
};
CustomMetaDataFieldSchemaObject updateschema = new CustomMetaDataFieldSchemaObject
{
    minValue = 500,
    maxValue = 2500
};
requestUpdateModel.schema = updateschema;
ResultCustomMetaDataField resultCustomMetaDataFieldUpdate = imagekit.UpdateCustomMetaDataFields(requestUpdateModel);