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

# Extract from File or URL

The **Extract from File or URL** endpoint runs extraction on a document you send in the same request—either as an uploaded file or via a URL. No document is stored in ParDocs; you get OCR, markdown, and extracted results back immediately. Use this when you want to process a document once without creating a document record.

**Query Parameters:**

* `include_coordinates` (boolean, optional): When `true`, each extracted field in `result` includes the source location: `value`, `page`, and `bounding_box_coordinates` (normalized `[x1, y1, x2, y2]`). Default is `false`.
* `force_exclusive_template` (boolean, optional): When `true`, the first template's document type is used for the entire document instead of auto-splitting by type. Default is `false`.
* `document_layout_analysis` (boolean, optional): When `true`, layout analysis is run before reading (useful for complex or table-heavy documents). Default is `false`.

**Request Body (multipart/form-data):**

* `file` (binary, optional): The document file to extract from. Provide either `file` or `url`, not both.
* `url` (string, optional): The URL of the document to extract from. Provide either `file` or `url`, not both.
* `template_ids` (array of strings, required): List of `template_id`s used for splitting and extraction.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.pardocs.com/v1/documents/extract?include_coordinates=true' \
    --header 'x-api-key: <api-key>' \
    --form 'file=@/path/to/document.pdf' \
    --form 'template_ids=["gAWADq4aB"]'
  ```

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

  url = "https://api.pardocs.com/v1/documents/extract"
  params = {"include_coordinates": True}
  headers = {"x-api-key": "<api-key>"}
  files = {"file": open("/path/to/document.pdf", "rb")}
  # Send template_ids as form field (e.g. JSON string or repeated key depending on client)
  data = {"template_ids": ["gAWADq4aB"]}

  response = requests.post(url, headers=headers, params=params, files=files, data=data)
  print(response.json())
  ```
</RequestExample>

**Response**

The response is a single object with:

* **`ocr`**: Array of OCR output per page.
* **`markdown`**: Full document text as markdown.
* **`result`**: Array of split sections. Each item has `document_type`, `pages`, and **`properties`** (the extracted key–value pairs for that section).

When `include_coordinates=true`, each value in `properties` is an object with **`value`**, **`page`**, and **`bounding_box_coordinates`** (normalized `[x1, y1, x2, y2]`) instead of a plain string or number, so you can map each field back to a region on the document.


## OpenAPI

````yaml openapi-documents POST /v1/documents/extract
openapi: 3.1.0
info:
  title: Document API
  version: 1.0.1
servers:
  - url: https://api.pardocs.com
security:
  - ApiKeyAuth: []
paths:
  /v1/documents/extract:
    post:
      parameters:
        - name: include_coordinates
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            When true, each extracted field in result includes value, page, and
            normalized bounding_box_coordinates [x1, y1, x2, y2] (0–1) for the
            source region in the document.
        - name: force_exclusive_template
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            When true, force the first template's document_type for the whole
            document instead of auto-splitting by type.
        - name: document_layout_analysis
          in: query
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            When true, run layout analysis before reading (e.g. for complex or
            table-heavy documents).
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - template_ids
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    Document file to extract from. Provide either file or url,
                    not both.
                url:
                  type: string
                  format: uri
                  description: >-
                    URL of the document to extract from. Provide either file or
                    url, not both.
                template_ids:
                  type: array
                  items:
                    type: string
                  description: >-
                    List of template_id values to use for splitting and
                    extraction.
      responses:
        '200':
          description: >-
            Successful Response. Returns ocr, markdown, and result (array of {
            document_type, pages, properties }). When include_coordinates=true,
            each property value is an object with value, page, and
            bounding_box_coordinates.
          content:
            application/json:
              schema:
                type: object
                properties:
                  ocr:
                    type: array
                    description: OCR output per page from the document.
                  markdown:
                    type: string
                    description: Converted markdown text of the full document.
                  result:
                    type: array
                    items:
                      type: object
                      properties:
                        document_type:
                          type: string
                        pages:
                          type: array
                          items:
                            type: integer
                        properties:
                          type: object
                          description: >-
                            Extracted key-value pairs (or
                            value/page/bounding_box_coordinates when
                            include_coordinates=true).
        4XX:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      required:
        - detail
      type: object
      properties:
        detail:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````