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

# Generate Extraction Schema

> Analyze document and generate an extraction schema

<Note>
  This API requires authentication. See our [Authentication Guide](/common/authentication) for details.
</Note>

### Features

* Identifies document type (Invoice, PO, etc.)
* Generates field schema based on content
* Supports PDF and images (jpg, jpeg, png)
* Accepts URL or base64-encoded file content
* Maximum file size: 10MB

### Request Body

<ParamField body="document_url" type="string">
  URL of the document to analyze
</ParamField>

<ParamField body="file_content" type="string">
  Base64 encoded file content
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.appliedai.club/api/extractor/v1/generate-schema \
    -H "Authorization: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "document_url": "https://example.com/invoice.pdf"
    }'
  ```

  ```python Python theme={null}
  import requests
  import json

  url = "https://api.appliedai.club/api/extractor/v1/generate-schema"
  headers = {
      "Authorization": "YOUR_API_KEY",
      "Content-Type": "application/json"
  }
  payload = {
      "document_url": "https://example.com/invoice.pdf"
  }

  response = requests.post(url, headers=headers, json=payload)
  result = response.json()
  print(result)
  ```
</RequestExample>


## OpenAPI

````yaml POST /api/extractor/v1/generate-schema
openapi: 3.1.0
info:
  title: Image Extraction API
  description: Extract structured data from images and PDFs
  version: 1.0.0
servers: []
security:
  - APIKeyHeader: []
paths:
  /api/extractor/v1/generate-schema:
    post:
      tags:
        - extractor
      summary: Generate Extraction Schema from Document
      description: |-
        Analyze document and generate an extraction schema.
            
            Features:
            * Identifies document type (Invoice, PO, etc.)
            * Generates field schema based on content
            * Supports PDF and images (jpg, jpeg, png)
            * Accepts URL or base64-encoded file content
            * Maximum file size: 10MB
      operationId: generate_schema_api_extractor_v1_generate_schema_post
      requestBody:
        content:
          application/json:
            schema:
              type: object
              title: Request Data
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SchemaGenerationResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthError'
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
          description: Unprocessable Entity
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitError'
          description: Too Many Requests
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorDetail'
      security:
        - APIKeyHeader: []
components:
  schemas:
    SchemaGenerationResponse:
      properties:
        document_type:
          type: string
          title: Document Type
        extraction_schema:
          $ref: '#/components/schemas/ExtractionSchema'
        confidence:
          type: number
          maximum: 1
          minimum: 0
          title: Confidence
      type: object
      required:
        - document_type
        - extraction_schema
        - confidence
      title: SchemaGenerationResponse
    ErrorDetail:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: ErrorDetail
      description: Standard error response schema
    AuthError:
      properties:
        detail:
          type: string
          title: Detail
        error_code:
          type: string
          title: Error Code
          default: unauthorized
      type: object
      required:
        - detail
      title: AuthError
      description: Authentication error response schema
    ValidationError:
      properties:
        detail:
          items:
            type: object
          type: array
          title: Detail
      type: object
      required:
        - detail
      title: ValidationError
      description: Validation error response schema
    RateLimitError:
      properties:
        detail:
          type: string
          title: Detail
        retry_after:
          anyOf:
            - type: integer
            - type: 'null'
          title: Retry After
      type: object
      required:
        - detail
      title: RateLimitError
      description: Rate limit error response schema
    ExtractionSchema:
      properties:
        fields:
          items:
            $ref: '#/components/schemas/SchemaField'
          type: array
          title: Fields
        document_description:
          anyOf:
            - type: string
            - type: 'null'
          title: Document Description
      type: object
      required:
        - fields
      title: ExtractionSchema
    SchemaField:
      properties:
        name:
          type: string
          title: Name
        type:
          $ref: '#/components/schemas/SchemaFieldType'
        description:
          type: string
          title: Description
        required:
          type: boolean
          title: Required
          default: false
        isExpanded:
          type: boolean
          title: Isexpanded
          default: true
        children:
          anyOf:
            - items:
                $ref: '#/components/schemas/SchemaField'
              type: array
            - type: 'null'
          title: Children
      type: object
      required:
        - name
        - type
        - description
      title: SchemaField
    SchemaFieldType:
      type: string
      enum:
        - string
        - number
        - array
        - object
        - boolean
      title: SchemaFieldType
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization
      description: Enter your API key

````