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

# Parse a document (sync)

> Upload a document and block until parsing is complete. Returns the full parsed result.



## OpenAPI

````yaml /api-v2.json post /documents/process
openapi: 3.1.0
info:
  title: Meibel AI API
  summary: Meibel Gateway Service
  description: >-
    Our API allows you to interact with our services. Read the
    [docs](https://docs.meibel.ai) to learn how to use it.
  version: 0.6.4
servers:
  - url: https://api.meibel.ai/v2
    description: Meibel API (v2)
  - url: https://api.dev.meibel.ai/v2
    description: Meibel Dev API (v2)
  - url: http://localhost:8000/v2
    description: Local Development
security: []
tags:
  - name: Datasources
    description: v2 datasource management
  - name: Data Elements
    description: v2 data element CRUD and search
  - name: File Upload
    description: Upload files to a datasource and track upload progress
  - name: Ingest
    description: Trigger and monitor datasource ingestion
  - name: Datasource Downloads
    description: Export all datasource content as a zip archive
  - name: Table Descriptions
    description: v2 table and column descriptions
  - name: Metadata Model Catalog
    description: v2 metadata model catalog
  - name: Confidence Scoring
    description: v2 confidence scoring jobs and summaries
  - name: Documents
    description: Parse and transform documents into structured data
  - name: Agents
    description: Agent definition management
  - name: Sessions
    description: Agent session (execution) management and chat
  - name: Execution Policies
    description: Data access and tool usage constraints scoped to agent sessions
  - name: Artifact Schemas
    description: Agent artifact schema management
paths:
  /documents/process:
    post:
      tags:
        - Documents
      summary: Parse a document (sync)
      description: >-
        Upload a document and block until parsing is complete. Returns the full
        parsed result.
      operationId: processDocument
      parameters:
        - name: format
          in: query
          required: false
          schema:
            type: string
            description: 'Result format: markdown, annotated, docling, json'
            default: markdown
            title: Format
          description: 'Result format: markdown, annotated, docling, json'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: The document file to process
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcessDocumentResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
      x-codeSamples:
        - lang: Python
          label: Python
          source: |-
            import os
            from meibel import MeibelClient

            client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])

            with open("invoice.pdf", "rb") as file:
                response = client.documents.process(
                    file=file,
                    format="meibel",
                )

            print(f"job_id={response.job_id} status={response.status}")

            result = response.result
            print(f"pages={result.pages} tables={result.tables}")

            for element in result.elements[:5]:
                print(f"[{element.type}] {element.text}")
        - lang: TypeScript
          label: TypeScript
          source: >-
            import fs from "fs";

            import { MeibelClient } from "meibel";


            const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY
            });


            const response = await client.documents.process({
              file: fs.createReadStream("./contracts/acme-msa-2024.pdf"),
              format: "meibel",
            });


            console.log(`Job ${response.job_id} status: ${response.status}`);


            if (typeof response.result !== "string") {
              console.log(`Parsed ${response.result.pages} pages, ${response.result.tables} tables`);
              const firstHeading = response.result.elements.find((el) => el.type === "heading");
              console.log(firstHeading?.text);
            }
        - lang: Go
          label: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\tv2 \"github.com/meibel-ai/meibel-go/v2\"\n)\n\nfunc main() {\n\tclient := v2.NewClient(v2.WithAPIKey(os.Getenv(\"MEIBEL_API_KEY\")))\n\n\tfile, err := os.Open(\"invoice.pdf\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer file.Close()\n\n\tresp, err := client.Documents.Process(context.Background(), v2.BodyProcessDocument{\n\t\tFile:     file,\n\t\tFileName: \"invoice.pdf\",\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfmt.Printf(\"job %s status %s\\n\", resp.JobID, resp.Status)\n\n\tif result, ok := resp.Result.(v2.MeibelDocumentResult); ok {\n\t\tfmt.Printf(\"parsed %d pages, %d tables, %d elements\\n\", result.Pages, result.Tables, len(result.Elements))\n\t}\n}"
components:
  schemas:
    ProcessDocumentResponse:
      properties:
        job_id:
          type: string
          title: Job Id
        status:
          type: string
          title: Status
          description: '''completed'''
        result:
          anyOf:
            - $ref: '#/components/schemas/MeibelDocumentResult'
            - type: string
          title: Result
          description: MeibelDocumentResult for meibel format, str for markdown
      type: object
      required:
        - job_id
        - status
        - result
      title: ProcessDocumentResponse
      description: Returned from POST /documents/process (sync).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MeibelDocumentResult:
      properties:
        elements:
          items:
            $ref: '#/components/schemas/DocumentElement'
          type: array
          title: Elements
        pages:
          type: integer
          title: Pages
        tables:
          type: integer
          title: Tables
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
      type: object
      required:
        - elements
        - pages
        - tables
      title: MeibelDocumentResult
      description: Full structured parse result (meibel format).
    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
    DocumentElement:
      properties:
        type:
          type: string
          title: Type
          description: heading | paragraph | table | list_item | image | code_block | ...
        text:
          anyOf:
            - type: string
            - type: 'null'
          title: Text
        level:
          anyOf:
            - type: integer
            - type: 'null'
          title: Level
          description: Heading level (1-6)
        table:
          anyOf:
            - $ref: '#/components/schemas/Table'
            - type: 'null'
        bbox:
          anyOf:
            - $ref: '#/components/schemas/BoundingBox'
            - type: 'null'
        confidence:
          anyOf:
            - type: number
            - type: 'null'
          title: Confidence
        page:
          anyOf:
            - type: integer
            - type: 'null'
          title: Page
      type: object
      required:
        - type
      title: DocumentElement
      description: A structural element in a parsed document.
    Table:
      properties:
        cells:
          items:
            $ref: '#/components/schemas/TableCell'
          type: array
          title: Cells
        rows:
          type: integer
          title: Rows
        cols:
          type: integer
          title: Cols
        bbox:
          anyOf:
            - $ref: '#/components/schemas/BoundingBox'
            - type: 'null'
      type: object
      required:
        - cells
        - rows
        - cols
      title: Table
    BoundingBox:
      properties:
        x:
          type: number
          title: X
        'y':
          type: number
          title: 'Y'
        width:
          type: number
          title: Width
        height:
          type: number
          title: Height
        page:
          type: integer
          title: Page
      type: object
      required:
        - x
        - 'y'
        - width
        - height
        - page
      title: BoundingBox
    TableCell:
      properties:
        text:
          type: string
          title: Text
        row:
          type: integer
          title: Row
        col:
          type: integer
          title: Col
        row_span:
          type: integer
          title: Row Span
          default: 1
        col_span:
          type: integer
          title: Col Span
          default: 1
        bbox:
          anyOf:
            - $ref: '#/components/schemas/BoundingBox'
            - type: 'null'
      type: object
      required:
        - text
        - row
        - col
      title: TableCell
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Meibel-API-Key

````