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

# Create And Autofill Form

> Create a new form and automatically populate it with AI-extracted data. Pass the `document_id` of the uploaded form along with either a `context` (background information), `instructions` (explicit filling rules), or `source_document_ids` (IDs of previously uploaded documents the AI will extract data from to fill the form).



## OpenAPI

````yaml post /v1/forms/autofill
openapi: 3.1.0
info:
  title: AI Form-Filler API
  version: 0.1.0
servers:
  - url: https://api.simplicity.ai
    description: Production
  - url: http://localhost:8000
    description: Local
security: []
paths:
  /v1/forms/autofill:
    post:
      tags:
        - forms
      summary: Create And Autofill Form
      description: >-
        Create a new form and automatically populate it with AI-extracted data.
        Pass the `document_id` of the uploaded form along with either a
        `context` (background information), `instructions` (explicit filling
        rules), or `source_document_ids` (IDs of previously uploaded documents
        the AI will extract data from to fill the form).
      operationId: create_and_autofill_form_v1_forms_autofill_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AutofillFormRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskCreateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    AutofillFormRequest:
      properties:
        form_file_document_id:
          type: string
          title: Form File Document Id
          description: The document ID of the PDF form to fill
        source_document_ids:
          items:
            type: string
          type: array
          title: Source Document Ids
          description: Array of document IDs containing data to extract
        instructions:
          anyOf:
            - type: string
            - type: 'null'
          title: Instructions
          description: Optional instructions to guide the AI filling process
        context:
          anyOf:
            - type: string
            - type: 'null'
          title: Context
          description: >-
            Optional text content to be used as context for filling the form
            using AI/LLM
      type: object
      required:
        - form_file_document_id
      title: AutofillFormRequest
      description: >-
        Request body for creating and autofilling a form from a PDF with source
        documents.
    TaskCreateResponse:
      properties:
        task_id:
          type: string
          title: Task Id
        status:
          $ref: '#/components/schemas/TaskStatus'
          default: processing
      type: object
      required:
        - task_id
        - status
      title: TaskCreateResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    TaskStatus:
      type: string
      enum:
        - pending
        - processing
        - completed
        - failed
      title: TaskStatus
    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
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````