> ## 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 Schema Asynchronously

> Analyze document and generate an extraction schema asynchronously

<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
* Returns immediately with a task\_id for status tracking
* Optional callback URL for webhook notification when processing completes

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

<ParamField body="callback_url" type="string">
  Optional URL for webhook notification when processing completes
</ParamField>

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

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

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

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


## OpenAPI

````yaml POST /api/extractor/v1/generate-schema-async
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-async:
    post:
      tags:
        - extractor
      summary: Generate Extraction Schema from Document Asynchronously
      description: |-
        Analyze document and generate an extraction schema asynchronously.
            
            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
            * Returns immediately with a task_id for status tracking
            * Optional callback URL for webhook notification when processing completes
      operationId: generate_schema_async_api_extractor_v1_generate_schema_async_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AsyncSchemaGenerationRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsyncSchemaGenerationResponse'
        '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:
    AsyncSchemaGenerationRequest:
      properties:
        document_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Document Url
        file_content:
          anyOf:
            - type: string
            - type: 'null'
          title: File Content
        provider:
          anyOf:
            - $ref: '#/components/schemas/LLMProvider'
            - type: 'null'
        callback_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Callback Url
      type: object
      title: AsyncSchemaGenerationRequest
      description: Request model for asynchronous schema generation
    AsyncSchemaGenerationResponse:
      properties:
        task_id:
          type: string
          title: Task Id
        status:
          $ref: '#/components/schemas/BatchProcessingStatus'
        message:
          type: string
          title: Message
      type: object
      required:
        - task_id
        - status
        - message
      title: AsyncSchemaGenerationResponse
      description: Response model for asynchronous schema generation request
    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
    LLMProvider:
      type: string
      enum:
        - openai
        - anthropic
        - gemini
      title: LLMProvider
    BatchProcessingStatus:
      type: string
      enum:
        - processing
        - retrying
        - completed
        - failed
      title: BatchProcessingStatus
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Authorization
      description: Enter your API key

````