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

# Suggest

> Suggest a tag taxonomy based on file content and existing metadata.

## Request Body

| Field                   | Type                   | Description                                                                  |
|-------------------------|------------------------|------------------------------------------------------------------------------|
| `data_connector_name`   | `str`                  | Name of the data connector (vector database profile) to use.                 |
| `file_names`            | `Optional[List[str]]`  | List of specific files to analyze for the hierarchy suggestion.              |
| `dataslice_id`          | `Optional[str]`        | ID of a dataslice to pull files from for the suggestion.                     |
| `progress_tracking_id`  | `Optional[str]`        | Custom tracking ID for monitoring the suggestion progress.                   |
| `taxonomy_name`           | `Optional[str]`        | Name for the suggested schema/taxonomy.                                      |
| `current_tree`          | `Optional[Dict]`       | Existing hierarchy tree to build upon.                                       |
| `condition`             | `Optional[Condition]`  | Filtering condition to select specific files for analysis.                   |
| `node`                  | `Optional[GraphNode]`  | Node location in the existing hierarchy tree to build upon. Default: `{}`    |
| `user_context`          | `Optional[str]`        | User-provided context to guide the suggestion process.                       |
| `context_level`         | `Optional[str]`        | Level at which to analyze content: `file` or `chunk`. Default: `"file"`      |
| `max_height`            | `Optional[int]`        | Maximum depth of the generated hierarchy tree. Default: `2`                  |
| `use_existing_tags`     | `Optional[bool]`       | Whether to incorporate existing tags in suggestions. Default: `false`        |
| `use_extracted_tags`    | `Optional[bool]`       | Whether to use previously extracted tags. Default: `false`                   |
| `use_mix_llm_and_source`| `Optional[bool]`       | Whether to mix LLM-generated and source-based tags. Default: `false`         |

## Response

- **200**: Schema suggestion generated successfully  
    - Returns: `{ "status_code": int, "message": str, "suggestion": Dict, "suggested_tags": Optional[Dict], "node": Optional[GraphNode], "tag_not_found_rates": Optional[Dict] }`
- **500**: Internal Server Error

## Example

```json
{
  "data_connector_name": "my-connector",
  "file_names": ["document1.pdf", "document2.pdf"],
  "context_level": "file",
  "max_height": 3,
  "use_existing_tags": true,
  "user_context": "Suggest categories for financial documents"
}
```



## OpenAPI

````yaml /deasy-openapi-stainless.yml post /suggest_schema
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: /rest/unstructured
security: []
paths:
  /suggest_schema:
    post:
      tags:
        - Taxonomies
      summary: Suggest
      description: >-
        Suggest a tag taxonomy based on file content and existing metadata.


        ## Request Body


        | Field                   | Type                   |
        Description                                                                 
        |

        |-------------------------|------------------------|------------------------------------------------------------------------------|

        | `data_connector_name`   | `str`                  | Name of the data
        connector (vector database profile) to use.                 |

        | `file_names`            | `Optional[List[str]]`  | List of specific
        files to analyze for the hierarchy suggestion.              |

        | `dataslice_id`          | `Optional[str]`        | ID of a dataslice
        to pull files from for the suggestion.                     |

        | `progress_tracking_id`  | `Optional[str]`        | Custom tracking ID
        for monitoring the suggestion progress.                   |

        | `taxonomy_name`           | `Optional[str]`        | Name for the
        suggested schema/taxonomy.                                      |

        | `current_tree`          | `Optional[Dict]`       | Existing hierarchy
        tree to build upon.                                       |

        | `condition`             | `Optional[Condition]`  | Filtering condition
        to select specific files for analysis.                   |

        | `node`                  | `Optional[GraphNode]`  | Node location in
        the existing hierarchy tree to build upon. Default: `{}`    |

        | `user_context`          | `Optional[str]`        | User-provided
        context to guide the suggestion process.                       |

        | `context_level`         | `Optional[str]`        | Level at which to
        analyze content: `file` or `chunk`. Default: `"file"`      |

        | `max_height`            | `Optional[int]`        | Maximum depth of
        the generated hierarchy tree. Default: `2`                  |

        | `use_existing_tags`     | `Optional[bool]`       | Whether to
        incorporate existing tags in suggestions. Default: `false`        |

        | `use_extracted_tags`    | `Optional[bool]`       | Whether to use
        previously extracted tags. Default: `false`                   |

        | `use_mix_llm_and_source`| `Optional[bool]`       | Whether to mix
        LLM-generated and source-based tags. Default: `false`         |


        ## Response


        - **200**: Schema suggestion generated successfully  
            - Returns: `{ "status_code": int, "message": str, "suggestion": Dict, "suggested_tags": Optional[Dict], "node": Optional[GraphNode], "tag_not_found_rates": Optional[Dict] }`
        - **500**: Internal Server Error


        ## Example


        ```json

        {
          "data_connector_name": "my-connector",
          "file_names": ["document1.pdf", "document2.pdf"],
          "context_level": "file",
          "max_height": 3,
          "use_existing_tags": true,
          "user_context": "Suggest categories for financial documents"
        }

        ```
      operationId: suggest_schema_route_suggest_schema_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MetadataSuggestionRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MetadataSuggestionResponse'
        '403':
          description: Missing token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '500':
          description: >-
            Internal Server Error. An unexpected error occurred while processing
            the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
      security:
        - BasicAuth: []
        - BearerAuth: []
          UserIdAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from unstructured import UnstructuredClient

            client = UnstructuredClient(
                username=os.environ.get("UNSTRUCTURED_USERNAME"),  # This is the default and can be omitted
                password=os.environ.get("UNSTRUCTURED_PASSWORD"),  # This is the default and can be omitted
            )
            response = client.taxonomy.suggest(
                data_connector_name="data_connector_name",
            )
            print(response.job_id)
        - lang: JavaScript
          source: >-
            import UnstructuredClient from 'unstructured-sdk';


            const client = new UnstructuredClient({
              authMethod: 'My Auth Method',
              username: process.env['UNSTRUCTURED_USERNAME'], // This is the default and can be omitted
              password: process.env['UNSTRUCTURED_PASSWORD'], // This is the default and can be omitted
            });


            const response = await client.taxonomy.suggest({
            data_connector_name: 'data_connector_name' });


            console.log(response.job_id);
components:
  schemas:
    MetadataSuggestionRequest:
      properties:
        data_connector_name:
          type: string
          title: Data Connector Name
        file_names:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: File Names
        dataslice_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Dataslice Id
        progress_tracking_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Progress Tracking Id
        taxonomy_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Taxonomy Name
        current_tree:
          anyOf:
            - type: object
            - type: 'null'
          title: Current Tree
        condition:
          anyOf:
            - $ref: '#/components/schemas/Condition-Input'
            - type: 'null'
        node:
          anyOf:
            - $ref: '#/components/schemas/GraphNode'
            - type: 'null'
          default:
            label: Root
            path: []
        user_context:
          anyOf:
            - type: string
            - type: 'null'
          title: User Context
        context_level:
          anyOf:
            - type: string
            - type: 'null'
          title: Context Level
          default: file
        max_height:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Height
          default: 1
        use_existing_tags:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Existing Tags
          default: false
        use_extracted_tags:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Extracted Tags
          default: false
        use_mix_llm_and_source:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Mix Llm And Source
          default: false
        graph_tag_type:
          anyOf:
            - $ref: '#/components/schemas/GraphTagType'
            - type: 'null'
          default: open_ended
        min_tags_per_level:
          anyOf:
            - type: integer
            - type: 'null'
          title: Min Tags Per Level
          default: 1
        max_tags_per_level:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tags Per Level
          default: 10
        set_max_values:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Set Max Values
          default: true
        values_per_tag:
          anyOf:
            - type: integer
            - type: 'null'
          title: Values Per Tag
        auto_save:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Auto Save
          default: true
        validate_tags:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Validate Tags
          default: true
        validation_sample_size:
          anyOf:
            - type: integer
            - type: 'null'
          title: Validation Sample Size
          default: 10
        not_found_threshold:
          anyOf:
            - type: number
            - type: 'null'
          title: Not Found Threshold
          default: 1
        use_hierarchical_clustering:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Hierarchical Clustering
          default: true
        deep_suggestion_mode:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Deep Suggestion Mode
          default: false
      type: object
      required:
        - data_connector_name
      title: MetadataSuggestionRequest
    MetadataSuggestionResponse:
      properties:
        status_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Status Code
          default: 200
        message:
          anyOf:
            - type: string
            - type: 'null'
          title: Message
          default: ''
        job_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Job Id
        suggestion:
          anyOf:
            - type: object
            - type: 'null'
          title: Suggestion
        suggested_tags:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/Tag-Output'
              type: object
            - type: 'null'
          title: Suggested Tags
        node:
          anyOf:
            - $ref: '#/components/schemas/GraphNode'
            - type: 'null'
        tag_not_found_rates:
          anyOf:
            - additionalProperties:
                type: number
              type: object
            - type: 'null'
          title: Tag Not Found Rates
      type: object
      title: MetadataSuggestionResponse
    HTTPError:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: HTTPError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Condition-Input:
      properties:
        condition:
          anyOf:
            - $ref: '#/components/schemas/LogicCondition'
            - type: 'null'
        children:
          anyOf:
            - items:
                $ref: '#/components/schemas/Condition-Input'
              type: array
            - type: 'null'
          title: Children
        tag:
          anyOf:
            - $ref: '#/components/schemas/BaseTag'
            - type: 'null'
      type: object
      title: Condition
    GraphNode:
      properties:
        label:
          anyOf:
            - type: string
            - type: 'null'
          title: Label
          default: Root
        path:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Path
          default: []
      type: object
      title: GraphNode
      description: Legacy graph node model - kept for backwards compatibility
    GraphTagType:
      type: string
      enum:
        - open_ended
        - binary
        - mixed
        - defined_values
        - hierarchy
      title: GraphTagType
    Tag-Output:
      properties:
        tag_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Tag Id
        username:
          anyOf:
            - type: string
            - type: 'null'
          title: Username
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          default: ''
        output_type:
          anyOf:
            - $ref: '#/components/schemas/TagOutputType'
            - type: 'null'
          default: string
        available_values:
          anyOf:
            - items:
                anyOf:
                  - type: string
                  - type: number
                  - type: integer
              type: array
            - type: 'null'
          title: Available Values
          default: []
        examples:
          anyOf:
            - items:
                anyOf:
                  - type: string
                  - type: object
              type: array
            - type: 'null'
          title: Examples
          default: []
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
        tuned:
          anyOf:
            - type: integer
            - type: 'null'
          title: Tuned
          default: 0
        maxValues:
          anyOf:
            - type: integer
            - type: string
            - items: {}
              type: array
            - type: 'null'
          title: Maxvalues
        neg_examples:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Neg Examples
          default: []
        retry_feedback:
          anyOf:
            - type: object
            - type: 'null'
          title: Retry Feedback
        date_format:
          anyOf:
            - type: string
            - type: 'null'
          title: Date Format
        strategy:
          anyOf:
            - type: string
            - type: 'null'
          title: Strategy
          default: LLM
        scope:
          anyOf:
            - type: string
            - type: 'null'
          title: Scope
          default: ALL_PAGES
        truncated_available_values:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Truncated Available Values
          default: false
        enhance_file_metadata:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Enhance File Metadata
          default: true
        regex:
          anyOf:
            - type: string
            - type: 'null'
          title: Regex
        patterns:
          anyOf:
            - items:
                $ref: '#/components/schemas/RegexPattern'
              type: array
            - type: 'null'
          title: Patterns
          default: []
        visual_rules:
          anyOf:
            - items:
                $ref: '#/components/schemas/RuleBasedRule-Output'
              type: array
            - type: 'null'
          title: Visual Rules
          default: []
        group:
          anyOf:
            - type: string
            - type: 'null'
          title: Group
        min_confidence:
          anyOf:
            - type: number
            - type: 'null'
          title: Min Confidence
        collibra_asset_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Collibra Asset Id
        collibra_domain_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Collibra Domain Id
        source_asset_type:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Asset Type
        governance_metadata:
          anyOf:
            - $ref: '#/components/schemas/GovernanceMetadata'
            - type: 'null'
      type: object
      required:
        - name
      title: Tag
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    LogicCondition:
      type: string
      enum:
        - AND
        - OR
      title: LogicCondition
    BaseTag:
      properties:
        name:
          type: string
          title: Name
        values:
          items:
            anyOf:
              - type: string
              - type: number
              - type: integer
          type: array
          title: Values
          default: []
        operator:
          anyOf:
            - type: string
            - type: 'null'
          title: Operator
          default: any
      type: object
      required:
        - name
      title: BaseTag
    TagOutputType:
      type: string
      enum:
        - string
        - binary
        - number
        - date
      title: TagOutputType
    RegexPattern:
      properties:
        pattern:
          type: string
          title: Pattern
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        output_value:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Value
        confidence:
          anyOf:
            - type: number
            - type: 'null'
          title: Confidence
        validator:
          anyOf:
            - type: string
            - type: 'null'
          title: Validator
        active:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Active
          default: true
        context_items:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Context Items
        required_context_matches:
          anyOf:
            - type: integer
            - type: 'null'
          title: Required Context Matches
          default: 0
      type: object
      required:
        - pattern
      title: RegexPattern
      description: Model for regex pattern configuration in tags.
    RuleBasedRule-Output:
      properties:
        tag_value:
          anyOf:
            - type: string
            - type: number
            - type: integer
            - type: 'null'
          title: Tag Value
        condition:
          anyOf:
            - $ref: '#/components/schemas/Condition-Output'
            - type: 'null'
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        confidence:
          anyOf:
            - type: number
            - type: 'null'
          title: Confidence
      type: object
      title: RuleBasedRule
      description: Model for rule-based tag configuration.
    GovernanceMetadata:
      properties:
        record_code:
          type: string
          title: Record Code
          description: Unique identifier from the retention schedule (e.g., FIN-001)
        retention_period:
          type: string
          title: Retention Period
          description: How long to retain (e.g., '7 years', 'Permanent')
        retention_trigger:
          type: string
          title: Retention Trigger
          description: Event that starts the retention clock (e.g., 'Date of payment')
        disposition:
          type: string
          title: Disposition
          description: Action after retention expires (e.g., 'Destroy', 'Archive')
        ingestion_id:
          type: string
          title: Ingestion Id
          description: UUID grouping all tags from the same CSV upload
      type: object
      required:
        - record_code
        - retention_period
        - retention_trigger
        - disposition
        - ingestion_id
      title: GovernanceMetadata
      description: >-
        Structured metadata for retention/policy governance tags.


        Populated when a tag is ingested from a retention schedule (CSV or
        Collibra Standards).

        Stored as JSONB in the tagschemas table.
    Condition-Output:
      properties:
        condition:
          anyOf:
            - $ref: '#/components/schemas/LogicCondition'
            - type: 'null'
        children:
          anyOf:
            - items:
                $ref: '#/components/schemas/Condition-Output'
              type: array
            - type: 'null'
          title: Children
        tag:
          anyOf:
            - $ref: '#/components/schemas/BaseTag'
            - type: 'null'
      type: object
      title: Condition
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    UserIdAuth:
      type: apiKey
      in: header
      name: X-User-ID

````