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

# Save Document Validation Custom Rule

> Create or update a tenant-scoped custom document validation rule.



## OpenAPI

````yaml https://document-assistant.us.aodocs.app/openapi.json put /assistant/api/v1/tenants/{tenant}/document_validation/rules/{rule_id}
openapi: 3.1.0
info:
  title: Document Assistant API
  description: |
    <p>
      The Document Assistant API enables developers to integrate document-based assistant
      functionalities into their applications using AODocs.
    </p>
    <p>
      The first step is to enable AIDA (AODocs Intelligent Document Assistant) in your tenant.
      The support team will provide you with the necessary information on how to get started.
    </p>
    <p>
      The second step is to enable AIDA on libraries. You need to be an administrator of the
      library to do this.<br />
      AIDA can answer questions only from those documents that are in an AIDA enabled
      library.<br />
      We create a vector store index for these documents. This can take some time. The get
      library API provides the status of the indexation and an estimate of the time
      remaining.<br />
      The content of the index is automatically kept up-to-date near real time with the
      content changes.
    </p>
    <p>
      The third step is to ask questions based on the AODocs documents.<br />
      AIDA automatically filters the results based on the user's permissions.
    </p>
    <p>
      <strong>Authentication:</strong> All API endpoints require a valid OAuth2 token in the
      Authorization header. Ensure the client ID of the OAuth2 token is whitelisted in AODocs.
    </p>
  version: 1.1.0
servers:
  - url: https://document-assistant.us.aodocs.app
    description: Production US
  - url: https://document-assistant.eu.aodocs.app
    description: Production EU
security: []
paths:
  /assistant/api/v1/tenants/{tenant}/document_validation/rules/{rule_id}:
    put:
      tags:
        - document_validation
      summary: Save Document Validation Custom Rule
      description: Create or update a tenant-scoped custom document validation rule.
      operationId: >-
        save_document_validation_custom_rule_assistant_api_v1_tenants__tenant__document_validation_rules__rule_id__put
      parameters:
        - name: rule_id
          in: path
          required: true
          schema:
            type: string
            title: Rule Id
        - name: tenant
          in: path
          required: true
          schema:
            type: string
            description: The domain of the customer
            examples:
              - example.com
            title: Tenant
          description: The domain of the customer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/RegexRule'
                - $ref: '#/components/schemas/BlacklistRule'
                - $ref: '#/components/schemas/LlmRule'
              discriminator:
                propertyName: kind
                mapping:
                  regex:
                    $ref: '#/components/schemas/RegexRule'
                  blacklist:
                    $ref: '#/components/schemas/BlacklistRule'
                  llm:
                    $ref: '#/components/schemas/LlmRule'
              title: Request
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AvailableRuleDescriptor'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    RegexRule:
      properties:
        kind:
          type: string
          const: regex
          title: Kind
          default: regex
        rule_id:
          type: string
          title: Rule Id
          description: Stable rule ID supplied by the caller.
        display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Display Name
          description: Optional human-readable label for the rule.
        pattern:
          type: string
          title: Pattern
          description: Regular expression used to detect violations.
        flags:
          anyOf:
            - items:
                $ref: '#/components/schemas/RegexFlag'
              type: array
            - type: 'null'
          title: Flags
          description: Optional regular expression flags.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional human-readable description of the rule.
        include_violation_details:
          type: boolean
          title: Include Violation Details
          description: >-
            Whether the response should include matched_text and snippet for
            violations from this rule.
          default: true
      type: object
      required:
        - rule_id
        - pattern
      title: RegexRule
    BlacklistRule:
      properties:
        kind:
          type: string
          const: blacklist
          title: Kind
          default: blacklist
        rule_id:
          type: string
          title: Rule Id
          description: Stable rule ID supplied by the caller.
        display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Display Name
          description: Optional human-readable label for the rule.
        terms:
          items:
            type: string
          type: array
          minItems: 1
          title: Terms
          description: >-
            Exact terms that should trigger a violation when found in the
            document.
        case_sensitive:
          type: boolean
          title: Case Sensitive
          description: Whether blacklist matching should be case sensitive.
          default: false
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional human-readable description of the rule.
        include_violation_details:
          type: boolean
          title: Include Violation Details
          description: >-
            Whether the response should include matched_text and snippet for
            violations from this rule.
          default: true
      type: object
      required:
        - rule_id
        - terms
      title: BlacklistRule
    LlmRule:
      properties:
        kind:
          type: string
          const: llm
          title: Kind
          default: llm
        rule_id:
          type: string
          title: Rule Id
          description: Stable rule ID supplied by the caller.
        display_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Display Name
          description: Optional human-readable label for the rule.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: Optional human-readable description of the rule.
        rule_intent:
          type: string
          title: Rule Intent
          description: High-level purpose of the rule, shown to the LLM.
        violation_definition:
          type: string
          title: Violation Definition
          description: What counts as a violation for this rule.
        non_violation_definition:
          type: string
          title: Non Violation Definition
          description: What should not be flagged for this rule.
        requires_visual_processing:
          type: boolean
          title: Requires Visual Processing
          description: >-
            Whether this rule requires multimodal attachment input in addition
            to text.
          default: false
        include_violation_details:
          type: boolean
          title: Include Violation Details
          description: >-
            Whether the response should include matched_text and snippet for
            violations from this rule.
          default: true
      type: object
      required:
        - rule_id
        - rule_intent
        - violation_definition
        - non_violation_definition
      title: LlmRule
    AvailableRuleDescriptor:
      properties:
        rule_id:
          type: string
          title: Rule Id
          description: Stable rule ID.
        kind:
          $ref: '#/components/schemas/ValidationRuleKind'
          description: The executable rule kind.
        display_name:
          type: string
          title: Display Name
          description: Human-readable label for the UI.
        description:
          type: string
          title: Description
          description: Human-readable description of the rule.
        requires_visual_processing:
          type: boolean
          title: Requires Visual Processing
          description: Whether the rule requires multimodal attachment input.
        include_violation_details:
          type: boolean
          title: Include Violation Details
          description: >-
            Whether violation details (matched_text, snippet) are included by
            default for this rule.
          default: true
        can_update:
          type: boolean
          title: Can Update
          description: Whether the caller may modify the rule definition.
        can_delete:
          type: boolean
          title: Can Delete
          description: Whether the caller may delete the rule definition.
        pattern:
          anyOf:
            - type: string
            - type: 'null'
          title: Pattern
          description: Regex pattern for editable custom regex rules.
        flags:
          anyOf:
            - items:
                $ref: '#/components/schemas/RegexFlag'
              type: array
            - type: 'null'
          title: Flags
          description: Regex flags for editable custom regex rules.
        terms:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Terms
          description: Blacklist terms for editable custom blacklist rules.
        case_sensitive:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Case Sensitive
          description: Blacklist case-sensitivity for editable custom blacklist rules.
        rule_intent:
          anyOf:
            - type: string
            - type: 'null'
          title: Rule Intent
          description: High-level purpose of the rule, when LLM-based.
        violation_definition:
          anyOf:
            - type: string
            - type: 'null'
          title: Violation Definition
          description: What counts as a violation, when LLM-based.
        non_violation_definition:
          anyOf:
            - type: string
            - type: 'null'
          title: Non Violation Definition
          description: What should not be flagged, when LLM-based.
      type: object
      required:
        - rule_id
        - kind
        - display_name
        - description
        - requires_visual_processing
        - can_update
        - can_delete
      title: AvailableRuleDescriptor
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    RegexFlag:
      type: string
      enum:
        - IGNORECASE
        - MULTILINE
        - DOTALL
      title: RegexFlag
    ValidationRuleKind:
      type: string
      enum:
        - regex
        - blacklist
        - llm
      title: ValidationRuleKind
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````