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

# Upload Document

> Upload a document for structured extraction.

Uploads a PDF document that can be used for structured data extraction. Only PDF files are supported.

Supported File Types:

1. PDF files only (`.pdf` extension)
2. Maximum file size: 50MB (recommended)
3. Documents are processed and validated upon upload

Document Processing:

1. File size and page count are automatically calculated
2. Document is validated for PDF format and readability
3. Metadata is extracted and stored for future reference
4. Document is stored securely and can be referenced by ID

Usage:

After uploading, you'll receive a `document_id` that can be used with:

1. `POST /jobs` endpoint to start extraction jobs
2. `GET /documents/{document_id}` to retrieve document information
3. `DELETE /documents/{document_id}` to remove the document

Example Response:
```json
{
  "document_id": "123e4567-e89b-12d3-a456-426614174000",
  "file_name": "financial_report.pdf",
  "file_size": 2048576,
  "page_count": 45,
  "uploaded_at": "2025-01-11T18:35:00Z",
  "status": "uploaded"
}
```



## OpenAPI

````yaml api-reference/openapi.json post /extract/documents/upload
openapi: 3.1.0
info:
  title: Endpoints
  version: '1.0'
servers:
  - url: https://api.contextual.ai/v1
security:
  - BearerAuth: []
paths:
  /extract/documents/upload:
    post:
      tags:
        - /extract
      summary: Upload Document
      description: >-
        Upload a document for structured extraction.


        Uploads a PDF document that can be used for structured data extraction.
        Only PDF files are supported.


        Supported File Types:


        1. PDF files only (`.pdf` extension)

        2. Maximum file size: 50MB (recommended)

        3. Documents are processed and validated upon upload


        Document Processing:


        1. File size and page count are automatically calculated

        2. Document is validated for PDF format and readability

        3. Metadata is extracted and stored for future reference

        4. Document is stored securely and can be referenced by ID


        Usage:


        After uploading, you'll receive a `document_id` that can be used with:


        1. `POST /jobs` endpoint to start extraction jobs

        2. `GET /documents/{document_id}` to retrieve document information

        3. `DELETE /documents/{document_id}` to remove the document


        Example Response:

        ```json

        {
          "document_id": "123e4567-e89b-12d3-a456-426614174000",
          "file_name": "financial_report.pdf",
          "file_size": 2048576,
          "page_count": 45,
          "uploaded_at": "2025-01-11T18:35:00Z",
          "status": "uploaded"
        }

        ```
      operationId: upload_document_extract_documents_upload_post
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_document_extract_documents_upload_post
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentUploadResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Body_upload_document_extract_documents_upload_post:
      properties:
        file:
          type: string
          format: binary
          title: File
      type: object
      required:
        - file
      title: Body_upload_document_extract_documents_upload_post
    DocumentUploadResponse:
      properties:
        document_id:
          type: string
          title: Document Id
          description: Unique ID of the uploaded document
        file_name:
          type: string
          title: File Name
          description: Original filename of the uploaded document
        file_size:
          type: integer
          title: File Size
          description: File size in bytes
        page_count:
          type: integer
          title: Page Count
          description: Number of pages in the document
        uploaded_at:
          type: string
          title: Uploaded At
          description: Timestamp when the document was uploaded
        status:
          type: string
          title: Status
          description: Upload status
      type: object
      required:
        - document_id
        - file_name
        - file_size
        - page_count
        - uploaded_at
        - status
      title: DocumentUploadResponse
      description: Response model for document upload.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````