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

# Extract Custom Metadata

> Extract metadata with custom schema from files<br>



## OpenAPI

````yaml https://document-assistant.us.aodocs.app/openapi.json post /assistant/api/v1/tenants/{tenant}/metadata:extractCustom
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}/metadata:extractCustom:
    post:
      tags:
        - metadata
      summary: Extract Custom Metadata
      description: Extract metadata with custom schema from files<br>
      operationId: >-
        extract_custom_metadata_assistant_api_v1_tenants__tenant__metadata_extractCustom_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/CustomMetadataExtractRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                title: >-
                  Response Extract Custom Metadata Assistant Api V1 Tenants 
                  Tenant  Metadata Extractcustom Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CustomMetadataExtractRequest:
      properties:
        llm_provider:
          anyOf:
            - $ref: '#/components/schemas/LlmProvider'
            - type: 'null'
          description: >-
            The LLM provider to use. If not provided, the default provider will
            be used.
        llm_model_prefix:
          anyOf:
            - type: string
            - type: 'null'
          title: Llm Model Prefix
          description: >-
            The prefix of the LLM model name to use. If not provided, the
            default model will be used.
          examples:
            - gemini-2.5-pro
            - gemini-2.5-pro-preview-05-06
            - gpt-4.1
        document_id:
          type: string
          title: Document Id
          description: The document ID of the files
        attachment_filters:
          anyOf:
            - items:
                $ref: '#/components/schemas/AttachmentFilter'
              type: array
            - type: 'null'
          title: Attachment Filters
          description: |-
            The attachments to extract metadata from.
                        If provided then only the attachments matching one of the rules are used.
                        If not provided then all attachments will be extracted.
                        Deprecated: use sources with an attachments entry instead. 
          deprecated: true
        sources:
          anyOf:
            - items:
                oneOf:
                  - $ref: '#/components/schemas/DescriptionExtractionSource'
                  - $ref: '#/components/schemas/AttachmentsExtractionSource'
                discriminator:
                  propertyName: type
                  mapping:
                    attachments:
                      $ref: '#/components/schemas/AttachmentsExtractionSource'
                    description:
                      $ref: '#/components/schemas/DescriptionExtractionSource'
              type: array
              minItems: 1
            - type: 'null'
          title: Sources
          description: |-
            The ordered document content sources to extract metadata from.
                        If omitted, attachment-only extraction is used for backward compatibility.
                        Description sources are opt-in. 
        instruction:
          anyOf:
            - type: string
            - type: 'null'
          title: Instruction
          description: The prompt extension for the metadata extraction
        provide_location:
          type: boolean
          title: Provide Location
          description: >-
            Whether to calculate and return page locations (bounding boxes) for
            the quote supporting each extracted field. Quotes are matched
            against textual and scanned PDF attachments plus PNG, JPEG, and WebP
            images without changing extracted values. Unsupported attachment
            types and quotes that do not occur verbatim after normalization do
            not produce boxes.
          default: false
        json_schema:
          $ref: '#/components/schemas/OpenAISchema'
          description: |-
            The metadata schema to be extracted.
                        It is the OpenAI supported subset of the JSON schema.
                        The additional_properties and required fields are automatically generated so their value is ignored.
        integer_decimal_handling:
          $ref: '#/components/schemas/IntegerDecimalHandling'
          description: >-
            How to coerce a decimal value the LLM returns for any integer-typed
            field in the schema: `truncate` drops the fractional part (3.7 → 3),
            `round` rounds to the nearest integer (3.5 → 4, 3.4 → 3), `roundup`
            always rounds up toward positive infinity (3.2 → 4), `error` raises
            an extraction error (default — current behavior). Applies uniformly
            to all integer fields in the JSON schema.
          default: error
      type: object
      required:
        - document_id
        - json_schema
      title: CustomMetadataExtractRequest
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LlmProvider:
      type: string
      enum:
        - OpenAI
        - Google
        - Altirnao
        - MistralAI
        - Anthropic
      title: LlmProvider
    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.
    DescriptionExtractionSource:
      properties:
        type:
          type: string
          const: description
          title: Type
          default: description
      type: object
      title: DescriptionExtractionSource
    AttachmentsExtractionSource:
      properties:
        type:
          type: string
          const: attachments
          title: Type
          default: attachments
        include:
          anyOf:
            - items:
                $ref: '#/components/schemas/AttachmentFilter'
              type: array
            - type: 'null'
          title: Include
          description: >-
            Attachment filters to include. If omitted, all attachments are
            included. If empty, no attachments are included.
        exclude:
          anyOf:
            - items:
                $ref: '#/components/schemas/AttachmentFilter'
              type: array
            - type: 'null'
          title: Exclude
          description: >-
            Attachment filters to exclude after applying include filters.
            Exclusion takes precedence over inclusion.
      type: object
      title: AttachmentsExtractionSource
    OpenAISchema:
      properties:
        $ref: da1486b2-12f0-4792-bb61-742b2764011b
        type:
          anyOf:
            - $ref: '#/components/schemas/JsonSchemaType'
            - items:
                $ref: '#/components/schemas/JsonSchemaType'
              type: array
            - type: 'null'
          title: Type
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        enum:
          anyOf:
            - items:
                anyOf:
                  - type: string
                  - type: integer
                  - type: number
                  - type: boolean
                  - type: 'null'
              type: array
            - type: 'null'
          title: Enum
        properties:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/OpenAISchema'
              type: object
            - type: 'null'
          title: Properties
        items:
          anyOf:
            - $ref: '#/components/schemas/OpenAISchema'
            - type: 'null'
        anyOf:
          anyOf:
            - items:
                $ref: '#/components/schemas/OpenAISchema'
              type: array
            - type: 'null'
          title: Anyof
        $defs:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/OpenAISchema'
              type: object
            - type: 'null'
          title: $Defs
        format:
          anyOf:
            - type: string
              enum:
                - date-time
                - time
                - date
                - duration
                - email
                - hostname
                - ipv4
                - ipv6
                - uuid
            - type: 'null'
          title: Format
        pattern:
          anyOf:
            - type: string
            - type: 'null'
          title: Pattern
        required:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Required
          description: If provided it must be equal to the keys of properties.
      additionalProperties: false
      type: object
      title: OpenAISchema
      description: |-
        Represents the OpenAI compatible subset of the JSON schema.
        The required and additionalProperties fields are automatically added
        because their values are always the same for OpenAI schemas.
    IntegerDecimalHandling:
      type: string
      enum:
        - truncate
        - round
        - roundup
        - error
      title: IntegerDecimalHandling
    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
    JsonSchemaType:
      type: string
      enum:
        - string
        - number
        - boolean
        - integer
        - object
        - array
        - 'null'
      title: JsonSchemaType
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````