> ## 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.

# Find Similar

> Finds similar documents to the given document ID within the tenant's document repository.
    When searching by document, exact attachment-MD5 matches are prioritized and semantic matches fill any
    remaining result slots up to `max_results`.



## OpenAPI

````yaml https://document-assistant.us.aodocs.app/openapi.json post /assistant/api/v1/tenants/{tenant}/documents:findSimilar
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}/documents:findSimilar:
    post:
      tags:
        - document_similarity
      summary: Find Similar
      description: >-
        Finds similar documents to the given document ID within the tenant's
        document repository.
            When searching by document, exact attachment-MD5 matches are prioritized and semantic matches fill any
            remaining result slots up to `max_results`.
      operationId: >-
        find_similar_assistant_api_v1_tenants__tenant__documents_findSimilar_post
      parameters:
        - name: tenant
          in: path
          required: true
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The domain of the customer
            examples:
              - example.com
            title: Tenant
          description: The domain of the customer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FindSimilarRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FindSimilarResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    FindSimilarRequest:
      properties:
        document_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Document Id
          description: >-
            The document ID to find similar documents for. Mutually exclusive
            with text.
        attachment_filters:
          anyOf:
            - items:
                $ref: '#/components/schemas/AttachmentFilter'
              type: array
            - type: 'null'
          title: Attachment Filters
          description: >-
            List of attachment filters within the document to consider for
            finding similar documents. If provided then only the attachments
            matching one of the rules are used otherwise all attachments will be
            used. It can be used only if the document_id field is provided.
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
          description: >-
            Finds similar documents to this text. Mutually exclusive with
            document_id.
        libraries:
          anyOf:
            - items:
                $ref: '#/components/schemas/LibraryFilter'
              type: array
            - type: 'null'
          title: Libraries
          description: >-
            List of libraries to limit the search for similar documents. If
            None, then all libraries will be searched. 
        similarity_threshold:
          type: number
          maximum: 1
          minimum: 0
          title: Similarity Threshold
          description: >-
            The similarity threshold (between 0 and 1) above which documents are
            considered similar. Higher values mean more similar documents.
            Ignored when 'absolute_duplicates_only' is true.
          default: 0.7
        absolute_duplicates_only:
          type: boolean
          title: Absolute Duplicates Only
          description: >-
            If true, return only absolute duplicates (documents sharing an
            attachment MD5 checksum with the source document);
            'similarity_threshold' is ignored. If false, absolute duplicates are
            returned first and semantically-similar matches are used to fill any
            remaining result slots up to 'max_results'. Can only be used
            together with 'document_id'.
          default: false
        max_results:
          type: integer
          exclusiveMinimum: 0
          title: Max Results
          description: The maximum number of similar documents to return.
          default: 10
        include:
          $ref: '#/components/schemas/DocumentSimilarityInclude'
          description: Which fields to include in the results
      type: object
      title: FindSimilarRequest
    FindSimilarResponse:
      properties:
        similar_documents:
          items:
            $ref: '#/components/schemas/SimilarDocument'
          type: array
          title: Similar Documents
          description: List of similar documents found.
      type: object
      required:
        - similar_documents
      title: FindSimilarResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AttachmentFilter:
      properties:
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: The name of the attachment to match (it can be a regular expression)
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: The id of the matched attachment
        mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Mime Type
          description: The mimetype of the matched attachment
      type: object
      title: AttachmentFilter
      description: Match an attachment by identifier, MIME type, or name expression.
    LibraryFilter:
      properties:
        id:
          type: string
          title: Id
          description: The ID of the library to filter similar documents from.
        document_classes:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Document Classes
          description: >-
            List of document class IDs to limit the search for similar documents
            within this library. If None, then all document classes within the
            library will be searched. 
      type: object
      required:
        - id
      title: LibraryFilter
    DocumentSimilarityInclude:
      properties:
        text:
          type: boolean
          title: Text
          description: Whether to include text snippets in the results
          default: true
      type: object
      title: DocumentSimilarityInclude
    SimilarDocument:
      properties:
        library_id:
          type: string
          title: Library Id
          description: The library ID of the similar document
        document_id:
          type: string
          title: Document Id
          description: The document ID of the similar document
        document_title:
          type: string
          title: Document Title
          description: Title of the similar document
        document_link:
          type: string
          title: Document Link
          description: Link to the similar document
        quoted_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Quoted Text
          description: Quoted text from the similar document
        attachment_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Attachment Id
          description: The attachment ID of the similar document
        attachment_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Attachment Name
          description: The attachment name of the similar document
        attachment_mime_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Attachment Mime Type
          description: The attachment mime type of the similar document
        attachment_link:
          anyOf:
            - type: string
            - type: 'null'
          title: Attachment Link
          description: The attachment link of the similar document
        location_info:
          anyOf:
            - type: string
            - type: 'null'
          title: Location Info
          description: Location of the quoted text on the similar document (optional)
        location_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Location Type
          description: Type of the location of the quoted text on the similar document
        similarity_score:
          type: number
          title: Similarity Score
          description: The similarity score between 0 and 1.
        absolute_duplicate:
          type: boolean
          title: Absolute Duplicate
          description: >-
            True if this document is an absolute duplicate (matched by
            attachment MD5 checksum). False for semantic-only matches.
          default: false
      type: object
      required:
        - library_id
        - document_id
        - document_title
        - document_link
        - similarity_score
      title: SimilarDocument
    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

````