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

# Classify document (async)

> Initiates an asynchronous document classification process based on provided schemas. Returns an ID to track the async result.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/samplehc/openapi.documented.yml post /api/v2/documents/classify
openapi: 3.0.3
info:
  title: Sample Healthcare API
  description: API for Sample Healthcare
  version: 1.0.0
servers: []
security: []
paths:
  /api/v2/documents/classify:
    post:
      tags:
        - Document
      summary: Classify document (async)
      description: >-
        Initiates an asynchronous document classification process based on
        provided schemas. Returns an ID to track the async result.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                document:
                  type: object
                  properties:
                    id:
                      type: string
                    fileName:
                      type: string
                  required:
                    - id
                    - fileName
                  additionalProperties: false
                  description: The document to be classified.
                labelSchemas:
                  type: array
                  items:
                    type: object
                    properties:
                      label:
                        type: string
                      description:
                        type: string
                        default: ''
                      keywords:
                        type: array
                        items:
                          type: string
                        default: []
                    required:
                      - label
                    additionalProperties: false
                  description: An array of label schemas to classify against.
                priority:
                  type: string
                  enum:
                    - interactive
                    - background
                  default: interactive
                  description: >-
                    Priority of the classification job. Use 'background' for
                    non-interactive, lower-priority jobs.
              required:
                - document
                - labelSchemas
              additionalProperties: false
        required: true
      responses:
        '202':
          description: Accepted. Document classification process initiated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  asyncResultId:
                    type: string
                    description: The ID to track the asynchronous classification task.
                required:
                  - asyncResultId
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: The error message.
                  message:
                    type: string
                    description: The message.
                  statusCode:
                    type: number
                    description: The status code.
                  details:
                    type: object
                    additionalProperties: {}
                    description: The details of the error
                additionalProperties: true
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: >-
                      Not Found, the specified document to classify does not
                      exist.
                required:
                  - error
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Internal server error while initiating classification.
                required:
                  - error
                additionalProperties: false
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from samplehc import SampleHealthcare

            client = SampleHealthcare(
                api_key=os.environ.get("SAMPLEHC_API_KEY"),  # This is the default and can be omitted
            )
            response = client.v2.documents.classify(
                document={
                    "id": "id",
                    "file_name": "fileName",
                },
                label_schemas=[{
                    "label": "label"
                }],
            )
            print(response.async_result_id)

````