{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cloudinary/json-schema/cloudinary-metadata-field-schema.json",
  "title": "metadata_field",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cloudinary-structured-metadata-openapi.yml#/components/schemas/metadata_field",
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "string",
        "integer",
        "date",
        "enum",
        "set"
      ],
      "description": "The type of the metadata field."
    },
    "external_id": {
      "type": "string",
      "maxLength": 255,
      "description": "The external ID of the metadata field."
    },
    "label": {
      "type": "string",
      "maxLength": 255,
      "description": "The label of the metadata field."
    },
    "mandatory": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Whether the metadata field is mandatory."
    },
    "default_value": {
      "type": [
        "string",
        "integer",
        "null"
      ],
      "description": "The default value of the metadata field."
    },
    "default_disabled": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Whether the field is disabled in the UI by default."
    },
    "validation": {
      "type": [
        "object",
        "null"
      ],
      "description": "The validation defined for the metadata field."
    },
    "restrictions": {
      "type": [
        "object",
        "null"
      ],
      "description": "Controls UI visibility and editability of the field. All three keys are always returned; any omitted key on input defaults to false.\n",
      "properties": {
        "readonly_ui": {
          "type": "boolean",
          "description": "Whether the field is read-only in the UI. When true, the field can only be updated via the API."
        },
        "hidden_ui": {
          "type": "boolean",
          "description": "Whether the field is hidden in the UI by default."
        },
        "excluded_from_search": {
          "type": "boolean",
          "description": "Whether the field is excluded from UI search by default."
        }
      }
    },
    "datasource": {
      "type": [
        "object",
        "null"
      ],
      "description": "The datasource defined for the metadata field.",
      "properties": {
        "values": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "external_id": {
                "type": "string",
                "description": "The external ID of the option."
              },
              "value": {
                "type": "string",
                "description": "The value of the option."
              },
              "position": {
                "type": "integer",
                "description": "The position of the option."
              },
              "state": {
                "$ref": "#/$defs/state_enum",
                "description": "The state of the option."
              }
            }
          }
        }
      }
    },
    "allow_dynamic_list_values": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "Whether the metadata field allows adding new options to the datasource dynamically."
    },
    "alphabetically_sorted": {
      "type": "boolean",
      "description": "Whether datasource values are maintained in case-insensitive alphabetical order. When true, values are automatically sorted on insert and update. Default false."
    }
  },
  "$defs": {
    "state_enum": {
      "type": "string",
      "enum": [
        "active",
        "inactive"
      ],
      "description": "The active or inactive state."
    }
  }
}