> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kadoa.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Upsert data quality rules

> Patch-merge the per-field data quality rules on a workflow; rules take effect on the next run



## OpenAPI

````yaml put /v4/workflows/{workflowId}/schema-validation-rules
openapi: 3.0.3
info:
  title: Kadoa API
  version: 3.0.0
  contact:
    name: Support
    email: support@kadoa.com
servers:
  - url: https://api.kadoa.com
security: []
paths:
  /v4/workflows/{workflowId}/schema-validation-rules:
    put:
      tags:
        - Data Quality
      summary: Upsert data quality rules for a workflow
      description: >
        Patch-merge the per-field data quality rules persisted on the workflow.
        Fields included in the

        request body replace any existing rules for those fields; fields not
        included are left untouched.

        To remove a field's rules, call the corresponding `DELETE` endpoint
        instead.

        Rule edits take effect on the next workflow run.
      parameters:
        - name: workflowId
          in: path
          required: true
          description: ID of the workflow
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowSchemaValidationRules'
      responses:
        '200':
          description: Rules updated successfully. Returns the merged ruleset.
          content:
            application/json:
              schema:
                type: object
                properties:
                  rules:
                    $ref: '#/components/schemas/WorkflowSchemaValidationRules'
        '400':
          description: Invalid workflow ID or invalid rule payload
        '401':
          description: Unauthorized
        '404':
          description: Workflow not found
        '500':
          description: Internal server error
      security:
        - ApiKeyAuth: []
components:
  schemas:
    WorkflowSchemaValidationRules:
      type: object
      description: >-
        Map keyed by schema field name, with the per-field data quality rules
        for that field.
      additionalProperties:
        $ref: '#/components/schemas/FieldValidationRules'
    FieldValidationRules:
      oneOf:
        - $ref: '#/components/schemas/StringFieldRules'
        - $ref: '#/components/schemas/NumberFieldRules'
      discriminator:
        propertyName: kind
    StringFieldRules:
      type: object
      required:
        - kind
      description: Validation rules for string fields.
      properties:
        kind:
          type: string
          enum:
            - STRING
        presence:
          $ref: '#/components/schemas/PresenceRule'
        uniqueness:
          $ref: '#/components/schemas/UniquenessRule'
        minLength:
          $ref: '#/components/schemas/StringLengthRule'
        maxLength:
          $ref: '#/components/schemas/StringLengthRule'
        format:
          $ref: '#/components/schemas/StringFormatRule'
    NumberFieldRules:
      type: object
      required:
        - kind
      description: Validation rules for number fields.
      properties:
        kind:
          type: string
          enum:
            - NUMBER
        presence:
          $ref: '#/components/schemas/PresenceRule'
        uniqueness:
          $ref: '#/components/schemas/UniquenessRule'
        minimum:
          $ref: '#/components/schemas/NumberBoundRule'
        maximum:
          $ref: '#/components/schemas/NumberBoundRule'
        maxDecimalPlaces:
          $ref: '#/components/schemas/NumberMaxDecimalPlacesRule'
    PresenceRule:
      description: Minimum percentage of rows that must have a value for this field.
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - target
          properties:
            target:
              type: integer
              enum:
                - 0
                - 20
                - 40
                - 60
                - 80
                - 100
    UniquenessRule:
      description: Minimum percentage of values that must be unique in this column.
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - target
          properties:
            target:
              type: integer
              enum:
                - 0
                - 20
                - 40
                - 60
                - 80
                - 100
    StringLengthRule:
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - value
          properties:
            value:
              type: integer
              minimum: 0
    StringFormatRule:
      description: >
        Format rule for string fields. The `kind` discriminator selects one of
        three shapes:
          - `FREE_TEXT` (see `StringFormatFreeTextRule`): a character-class restriction. Length rules apply only with this kind.
          - `FORMAT` (see `StringFormatFormatRule`): a named pattern preset or a custom regex.
          - `LIST` (see `StringFormatListRule`): a named enum preset or a custom list of allowed values.
      oneOf:
        - $ref: '#/components/schemas/StringFormatFreeTextRule'
        - $ref: '#/components/schemas/StringFormatFormatRule'
        - $ref: '#/components/schemas/StringFormatListRule'
      discriminator:
        propertyName: kind
    NumberBoundRule:
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - value
          properties:
            value:
              type: number
    NumberMaxDecimalPlacesRule:
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - value
          properties:
            value:
              type: integer
              minimum: 0
              maximum: 16
    Attribution:
      type: object
      required:
        - editedBy
        - editedAt
      description: Who last edited this specific rule and when.
      properties:
        editedBy:
          type: string
          enum:
            - default
            - llm
            - agent
            - ops
            - user
          description: Actor type that produced the last edit.
        editedByLabel:
          type: string
          description: >-
            Optional human-readable label for the editor (e.g. email for users,
            agent name for agents).
        editedAt:
          type: string
          format: date-time
          description: ISO-8601 timestamp of the last edit.
    StringFormatFreeTextRule:
      description: >-
        Free-text format. A character-class restriction; length rules apply only
        with this kind.
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - kind
            - charset
          properties:
            kind:
              type: string
              enum:
                - FREE_TEXT
            charset:
              type: object
              required:
                - kind
                - preset
              properties:
                kind:
                  type: string
                  enum:
                    - PRESET
                preset:
                  type: string
                  enum:
                    - natural_language
                    - alphanumeric
                    - alpha
    StringFormatFormatRule:
      description: >-
        Pattern format. Values must match a named pattern preset or a custom
        regular expression.
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - kind
            - source
          properties:
            kind:
              type: string
              enum:
                - FORMAT
            source:
              oneOf:
                - type: object
                  required:
                    - kind
                    - preset
                  properties:
                    kind:
                      type: string
                      enum:
                        - PRESET
                    preset:
                      type: string
                      enum:
                        - url
                        - email
                        - phone
                        - date
                        - datetime
                        - time
                        - uuid
                        - slug
                - type: object
                  required:
                    - kind
                    - pattern
                  properties:
                    kind:
                      type: string
                      enum:
                        - CUSTOM
                    pattern:
                      type: string
                      minLength: 1
                      description: Must be a valid regular expression.
              discriminator:
                propertyName: kind
    StringFormatListRule:
      description: List format. Values must come from a named enum preset or a custom list.
      allOf:
        - $ref: '#/components/schemas/Attribution'
        - type: object
          required:
            - kind
            - source
          properties:
            kind:
              type: string
              enum:
                - LIST
            source:
              oneOf:
                - type: object
                  required:
                    - kind
                    - preset
                  properties:
                    kind:
                      type: string
                      enum:
                        - PRESET
                    preset:
                      type: string
                      enum:
                        - language2
                        - country2
                        - country3
                        - currency3
                        - month3
                        - usState2
                - type: object
                  required:
                    - kind
                    - values
                  properties:
                    kind:
                      type: string
                      enum:
                        - CUSTOM
                    values:
                      type: array
                      items:
                        type: string
                        minLength: 1
                      minItems: 1
                      description: The closed set of allowed values.
              discriminator:
                propertyName: kind
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````