Create custom metadata field
post
https://api.imagekit.io
/v1/customMetadataFields
Add custom metadata field

Allowed values in the schema object

Parameter name
Type
Required
Descriptions
type
enum
Yes
Type of the field Allowed values - Text, Textarea, Number, Date, Boolean, SingleSelect, MultiSelect
Date value should be an ISO8601 string
selectOptions
An array consisting values of type string, number or boolean
Only if type is SingleSelect or MultiSelect
An array of options to select from. Example - ["small", "medium", "large", 30, 40, true]
defaultValue
string
Only if type is isValueRequired
The default value for the field
type constraints :
Should be of the same type as that provided in thetype enum.
For SingleSelect, should be one of the values provided in selectOptions
For MultiSelect, should be an array containing only values provided in selectOptions
For Date or Number, should be >= minValue (if provided) and <= maxValue (if provided)
For Text or Textarea, should be >= minLength (if provided) and <= maxLength (if provided)``
isValueRequired
boolean
No
Sets field as required
minValue
string
No
Minimum value of the field
Allowed only if type is Date or Number
maxValue
string
No
Maximum value of the field
Allowed only if type is Date or Number
minLength
number
No
Minimum length of string
Allowed only if type is Text or Textarea
maxLength
number
No
Maximum length of string
Allowed only if type is Text or Textarea

Examples

Here is the example request to understand the API usage.
cURL
1
# The unique id of the created custom metadata schema is returned with this api along with key name and schema object.
2
curl -X POST "https://api.imagekit.io/v1/customMetadataFields" \
3
-H 'Content-Type: application/json' \
4
-u your_private_key:
5
-d'
6
{
7
"name": "price",
8
"label": "price",
9
"schema": {
10
"type": "Number",
11
"minValue": 1000,
12
"maxValue": 3000
13
}
14
}
15
'
Copied!
Last modified 27d ago