openapi: 3.1.0
info:
  title: Cloudinary Structured Metadata API
  version: 0.5.5
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  contact:
    name: Cloudinary Support
    email: support@cloudinary.com
    url: https://support.cloudinary.com
  termsOfService: https://cloudinary.com/tou
servers:
  - url: https://{region}.cloudinary.com
    description: Regional API endpoints for optimal performance.
    variables:
      region:
        default: api
        description: Regional endpoint selection
        enum:
          - api
          - api-eu
          - api-ap
  - url: https://{host}
    description: Custom domains for enterprise deployments.
    variables:
      host:
        default: api.cloudinary.com
        description: API host domain.
security:
  - basicAuth: []
  - oauth2:
      - asset_management
      - upload
tags:
  - name: metadata_fields
    description: Enables you to manage structured metadata fields.
  - name: metadata_rules
    description: Enables you to set up dependencies and relationships between structured metadata fields and options.
paths:
  /v1_1/{cloud_name}/metadata_fields:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
    post:
      x-speakeasy-mcp:
        name: create-metadata-field
        scopes:
          - admin
        title: Create Metadata Field
      operationId: createMetadataField
      summary: Creates a new structured metadata field in your account
      description: Creates a new metadata field with the specified properties and configuration.
      tags:
        - metadata_fields
      responses:
        '200':
          description: metadata field created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field'
        '400':
          description: validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
      requestBody:
        description: The metadata field definition.
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/metadata_field'
                - required:
                    - type
                    - label
    get:
      x-speakeasy-mcp:
        name: list-metadata-fields
        scopes:
          - builder
        title: List Metadata Fields
        readOnlyHint: true
        idempotentHint: true
      operationId: listMetadataFields
      summary: Lists all structured metadata fields defined in your Cloudinary product environment
      description: Retrieves a list of all metadata fields in the product environment based on the provided filters.
      tags:
        - metadata_fields
      parameters:
        - name: external_ids
          in: query
          required: false
          schema:
            type: array
            items:
              type: string
          description: The external IDs of the metadata fields to retrieve. if not provided, all metadata fields will be returned.
      responses:
        '200':
          description: metadata fields retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_fields_list_response'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/{external_id}:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
      - name: external_id
        in: path
        required: true
        schema:
          type: string
        description: The external ID of the metadata field.
    get:
      x-speakeasy-mcp:
        name: get-metadata-field
        scopes:
          - admin
        title: Get Metadata Field
        readOnlyHint: true
        idempotentHint: true
      operationId: getMetadataField
      summary: Retrieves the definition of a specific structured metadata field by its identifier (external_id)
      description: Retrieves detailed information about the specified metadata field.
      tags:
        - metadata_fields
      responses:
        '200':
          description: metadata field retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
    put:
      x-speakeasy-mcp:
        name: update-metadata-field
        scopes:
          - admin
        title: Update Metadata Field
        idempotentHint: true
      operationId: updateMetadataField
      summary: Updates the configuration of an existing metadata field
      description: Updates the properties and configuration of the specified metadata field.
      tags:
        - metadata_fields
      requestBody:
        description: The updated metadata field definition.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/metadata_field'
      responses:
        '200':
          description: metadata field updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field'
        '400':
          description: validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
    delete:
      x-speakeasy-mcp:
        name: delete-metadata-field
        scopes:
          - builder
        title: Delete Metadata Field
        destructiveHint: true
        idempotentHint: true
      operationId: deleteMetadataField
      summary: Deletes a structured metadata field definition from your account
      description: Permanently deletes the specified metadata field and all its associated data.
      tags:
        - metadata_fields
      responses:
        '200':
          description: metadata field deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/message_response'
        '400':
          description: validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/datasource/search:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
    post:
      operationId: searchMetadataFieldDatasource
      summary: Search across all metadata field datasources
      description: Performs a search across all metadata field datasources to find matching values.
      tags:
        - metadata_fields
      requestBody:
        description: The datasource search query.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/datasource_search_request'
      responses:
        '200':
          description: search results
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/datasource_search_result'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/order:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
    put:
      operationId: reorderMetadataFields
      summary: Reorder all metadata fields
      description: Changes the display order of all metadata fields based on specified criteria.
      tags:
        - metadata_fields
      requestBody:
        description: The new ordering for metadata fields.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/reorder_metadata_fields_request'
      responses:
        '200':
          description: metadata fields reordered
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_fields_list_response'
        '400':
          description: invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/{external_id}/reorder:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
      - name: external_id
        in: path
        required: true
        schema:
          type: string
        description: The external ID of the metadata field to reorder.
    put:
      operationId: reorderMetadataField
      summary: Change position of metadata field
      description: Changes the display position of a specific metadata field within the list.
      tags:
        - metadata_fields
      requestBody:
        description: The new position for the metadata field.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/reorder_metadata_field_request'
      responses:
        '200':
          description: metadata fields reordered
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_fields_list_response'
        '400':
          description: invalid position
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/{external_id}/datasource:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
      - name: external_id
        in: path
        required: true
        schema:
          type: string
        description: The external ID of the metadata field to update the datasource for.
    put:
      x-speakeasy-mcp:
        name: update-metadata-datasource-values
        scopes:
          - builder
        title: Update Metadata Datasource Values
        idempotentHint: true
      operationId: updateMetadataFieldDatasource
      summary: Updates the allowed values (the datasource) for a specified metadata field
      description: Updates the values in a metadata field's datasource, including adding, modifying, or changing the order of values.
      tags:
        - metadata_fields
      requestBody:
        description: The updated datasource values.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/update_datasource_request'
      responses:
        '200':
          description: datasource updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field_datasource_values_array'
        '400':
          description: invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '420':
          description: metadata field is already updating
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
    delete:
      x-speakeasy-mcp:
        name: delete-metadata-datasource-values
        scopes:
          - builder
        title: Delete Metadata Datasource Values
        destructiveHint: true
        idempotentHint: true
      operationId: deleteMetadataFieldDatasource
      summary: Removes one or more allowed values from a metadata field's datasource
      description: Removes specific values from a metadata field's datasource by their external IDs.
      tags:
        - metadata_fields
      requestBody:
        description: The datasource entry external IDs to delete.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/datasource_external_ids_request'
      responses:
        '200':
          description: datasource values deleted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field_datasource_values_array'
        '400':
          description: invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/{external_id}/datasource/search:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
      - name: external_id
        in: path
        required: true
        schema:
          type: string
        description: The external ID of the metadata field to search the datasource for.
    post:
      operationId: searchDatasourceInMDField
      summary: Search datasource values in a metadata field
      description: Performs a search within a specific metadata field's datasource to find matching values, with support for exact or partial matches.
      tags:
        - metadata_fields
      parameters:
        - name: max_results
          in: query
          required: false
          schema:
            type: integer
            default: 255
          description: The maximum number of results to return.
        - name: term
          in: query
          required: false
          schema:
            type: string
          description: The term to search for. can be any substring of the value.
        - name: exact_match
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: Whether to search for an exact match.
      requestBody:
        description: The datasource search query for this field.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/datasource_search_in_field_request'
      responses:
        '200':
          description: search results
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field_datasource_values_array'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_fields/{external_id}/datasource_restore:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
      - name: external_id
        in: path
        required: true
        schema:
          type: string
        description: The external ID of the metadata field to restore the datasource values for.
    post:
      operationId: restoreMetadataFieldDatasource
      summary: Restore datasource values
      description: Restores datasource values that have been deleted.
      tags:
        - metadata_fields
      requestBody:
        description: The datasource entry external IDs to restore.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/datasource_external_ids_request'
      responses:
        '200':
          description: datasource values restored
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_field_datasource_values_array'
        '400':
          description: invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata field not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_rules:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
    post:
      x-speakeasy-mcp:
        name: create-metadata-rule
        scopes:
          - builder
        title: Create Metadata Rule
      operationId: createMetadataRule
      summary: Creates a new conditional metadata rule
      description: Creates a new metadata rule with the specified properties and configuration.
      tags:
        - metadata_rules
      responses:
        '200':
          description: metadata rule created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_rule_response'
        '400':
          description: validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
      requestBody:
        description: The metadata rule to create.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/metadata_rule_create'
    get:
      x-speakeasy-mcp:
        name: list-metadata-rules
        scopes:
          - builder
        title: List Metadata Rules
        readOnlyHint: true
        idempotentHint: true
      operationId: listMetadataRules
      summary: Retrieves a list of all conditional metadata rules defined in your account
      description: Retrieves a list of all metadata rules in the cloud.
      tags:
        - metadata_rules
      responses:
        '200':
          description: metadata rules retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_rules_list_response'
        '401':
          description: authentication error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
  /v1_1/{cloud_name}/metadata_rules/{external_id}:
    parameters:
      - $ref: '#/components/parameters/cloud_name'
      - name: external_id
        in: path
        required: true
        schema:
          type: string
        description: The unique identifier of the metadata rule.
    put:
      x-speakeasy-mcp:
        name: update-metadata-rule
        scopes:
          - builder
        title: Update Metadata Rule
        idempotentHint: true
      operationId: updateMetadataRule
      summary: Updates an existing conditional metadata rule's definition
      description: Updates the properties and configuration of an existing metadata rule.
      tags:
        - metadata_rules
      requestBody:
        description: The updated metadata rule definition.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/metadata_rule_update'
      responses:
        '200':
          description: metadata rule updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/metadata_rule_response'
        '400':
          description: validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata rule not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
    delete:
      x-speakeasy-mcp:
        name: delete-metadata-rule
        scopes:
          - builder
        title: Delete Metadata Rule
        destructiveHint: true
        idempotentHint: true
      operationId: deleteMetadataRule
      summary: Deletes a conditional metadata rule by its ID
      description: Permanently deletes a metadata rule.
      tags:
        - metadata_rules
      responses:
        '200':
          description: metadata rule deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/success_response'
        '400':
          description: validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '401':
          description: authentication error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '403':
          description: insufficient permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
        '404':
          description: metadata rule not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/api_error'
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
    oauth2:
      type: oauth2
      description: OAuth2 Authorization Code flow for user authentication
      flows:
        authorizationCode:
          authorizationUrl: https://oauth.cloudinary.com/oauth2/auth
          tokenUrl: https://oauth.cloudinary.com/oauth2/token
          scopes:
            asset_management: Allows managing assets, including reading, updating, and deleting.
            upload: Allows uploading new assets.
  parameters:
    cloud_name:
      name: cloud_name
      in: path
      required: true
      schema:
        type: string
      description: The cloud name of your product environment.
      example: my_cloud
  schemas:
    state_enum:
      type: string
      enum:
        - active
        - inactive
      description: The active or inactive state.
    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.
          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: '#/components/schemas/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.
          example: true
    metadata_fields_list_response:
      type: object
      properties:
        metadata_fields:
          type: array
          items:
            $ref: '#/components/schemas/metadata_field'
    api_error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - error
    message_response:
      type: object
      properties:
        message:
          type: string
          description: A human-readable status message.
          example: updated
      required:
        - message
    datasource_search_request:
      type: object
      properties:
        term:
          type: string
          description: The term to search for. Can be any substring of the value.
        max_results:
          type: integer
          default: 100
          description: The maximum number of results to return.
    datasource_search_result:
      type: object
      properties:
        field_id:
          type: string
          description: The external ID of the metadata field.
        id:
          type: string
          description: The external ID of the option.
        value:
          type: string
          description: The value of the option.
    direction_enum:
      type: string
      enum:
        - asc
        - desc
      description: Sort direction.
    reorder_metadata_fields_request:
      type: object
      properties:
        order_by:
          type: string
          enum:
            - label
            - created_at
            - external_id
          description: The field to order by.
        direction:
          $ref: '#/components/schemas/direction_enum'
          description: The direction to order by.
      required:
        - order_by
    reorder_metadata_field_request:
      type: object
      properties:
        position:
          type: integer
          description: The position of the metadata field.
      required:
        - position
    datasource_value_input:
      type: object
      properties:
        external_id:
          type: string
          description: The external ID of the datasource value.
        value:
          type: string
          description: The value of the option.
        position:
          type: integer
          description: The position of the option.
        state:
          $ref: '#/components/schemas/state_enum'
          description: The state of the option.
    update_datasource_request:
      type: object
      properties:
        values:
          type: array
          items:
            $ref: '#/components/schemas/datasource_value_input'
    metadata_field_datasource_value:
      type: object
      properties:
        external_id:
          type: string
          description: The external ID of the datasource value.
        value:
          type: string
          description: The value of the option.
    metadata_field_datasource_values_array:
      type: object
      properties:
        values:
          type: array
          items:
            $ref: '#/components/schemas/metadata_field_datasource_value'
    datasource_external_ids_request:
      type: object
      properties:
        external_ids:
          type: array
          items:
            type: string
          description: The external IDs of the datasource values.
      required:
        - external_ids
    datasource_search_in_field_request:
      type: object
      properties:
        payload:
          type: object
          description: Metadata payload for rule-based inference.
    metadata_rule_apply_value:
      type: object
      description: Applies a specific value to the metadata field when the rule condition is met.
      required:
        - value
      properties:
        value:
          type:
            - string
            - 'null'
          description: The value to apply to the metadata field.
          example: my value
        mode:
          type: string
          enum:
            - default
            - override
            - append
          description: |
            How to apply the value. `default` sets it only when no value is already inferred; `override` always replaces any inferred value; `append` adds to an existing array value.
          example: default
    metadata_rule_activate_values:
      description: |
        Restricts which datasource option ids are active. Either the string "all" (activate every option) or an object listing the external ids to activate.
      oneOf:
        - type: string
          enum:
            - all
        - type: object
          required:
            - external_ids
          properties:
            external_ids:
              type:
                - array
                - 'null'
              items:
                type: string
              description: The datasource external ids to activate.
            mode:
              type: string
              enum:
                - override
                - append
              description: Whether to override the current active set or append to it. Defaults to append.
    metadata_rule_result:
      type: object
      description: The result to apply when the rule's condition is met. At least one property must be set.
      minProperties: 1
      properties:
        apply_value:
          $ref: '#/components/schemas/metadata_rule_apply_value'
        disable:
          type: boolean
          description: When true, disables the field in the UI (sets default_disabled). Preferred over the legacy enable action.
        enable:
          type: boolean
          deprecated: true
          description: When true, enables the field in the UI (clears default_disabled). Deprecated — prefer using disable with value false instead.
        hide:
          type: boolean
          description: When true, hides the field in the UI (sets hidden_ui).
        activate_values:
          $ref: '#/components/schemas/metadata_rule_activate_values'
        set_mandatory:
          type: boolean
          description: When true, makes the field mandatory; when false, makes it optional.
    metadata_rule_base:
      type: object
      properties:
        metadata_field_id:
          type: string
          description: The ID of the metadata field this rule applies to.
        name:
          type: string
          description: A descriptive name for the metadata rule.
        condition:
          type: object
          description: The condition that triggers this rule. Ensure it adheres to the metadata rule condition schema.
        result:
          $ref: '#/components/schemas/metadata_rule_result'
        state:
          $ref: '#/components/schemas/state_enum'
          description: The state of the rule.
        position:
          type: integer
          description: The position/order of this rule relative to other rules.
      example:
        metadata_field_id: smd-field-1
        name: My Rule
        condition:
          metadata_field_id: smd-field-2
          populated: true
        result:
          apply_value:
            value: my value
            mode: default
        state: active
        position: 1
    metadata_rule_response:
      allOf:
        - $ref: '#/components/schemas/metadata_rule_base'
        - type: object
          properties:
            external_id:
              type: string
              description: The unique identifier of the metadata rule.
            condition_signature:
              type: string
              description: A signature representing the condition structure.
      example:
        external_id: '1234567890'
        metadata_field_id: smd-field-1
        name: Disable field when other field is populated
        condition:
          metadata_field_id: smd-field-2
          populated: true
        condition_signature: dGhlIGZveCBqdW1wZWQgb3ZlciB0aGUgbGF6eSBkb2c
        result:
          disable: true
        state: active
        position: 1
    metadata_rules_list_response:
      type: object
      properties:
        metadata_rules:
          type: array
          items:
            $ref: '#/components/schemas/metadata_rule_response'
    metadata_rule_create:
      allOf:
        - $ref: '#/components/schemas/metadata_rule_base'
      required:
        - metadata_field_id
        - name
        - condition
        - result
      example:
        metadata_field_id: smd-field-1
        name: Disable field when other field is populated
        condition:
          metadata_field_id: smd-field-2
          populated: true
        result:
          disable: true
        state: active
        position: 1
    metadata_rule_update:
      allOf:
        - $ref: '#/components/schemas/metadata_rule_base'
      example:
        metadata_field_id: smd-field-1
        name: Disable field when other field is populated
        condition:
          metadata_field_id: smd-field-2
          populated: true
        result:
          disable: true
        state: active
        position: 1
    success_response:
      type: object
      properties:
        success:
          type: boolean
          description: Whether the operation was successful.
          example: true
      required:
        - success
x-speakeasy-globals:
  parameters: []
