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

# Upload a Document

The **Upload a Document** endpoint allows you to upload a document to the ParDocs API. You can submit the document either as a file or via a URL. This endpoint is used to add new documents for processing or storage.

**Request Parameters:**

* **file** (form-data, optional): The document file you want to upload. Provide this if you are uploading a file directly.
* **url** (form-data, optional): The URL of the document you want to upload. Provide this if you are uploading a document from a URL.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.pardocs.com/v1/documents \
    --header 'Content-Type: multipart/form-data' \
    --header 'x-api-key: <api-key>' \
    --form file=@your/path/sample.pdf \
    --form url=https://url_to_your_document.pdf
  ```

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

  url = "https://api.pardocs.com/v1/documents"
  headers = {"x-api-key": "<api-key>"}
  files = {"file": open("your/path/sample.pdf", "rb")}
  // files = {"url": (None, "https://url_to_your_document.pdf")}

  response = requests.post(url, headers=headers, files=files)

  print(response.json())
  ```
</RequestExample>


## OpenAPI

````yaml openapi-documents POST /v1/documents
openapi: 3.1.0
info:
  title: Document API
  version: 1.0.1
servers:
  - url: https://api.pardocs.com
security:
  - ApiKeyAuth: []
paths:
  /v1/documents:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/DocumentFile'
              title: Body
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentResponse'
        4XX:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    DocumentFile:
      title: DocumentFile
      type: object
      description: >-
        The object can contain either a file or a URL pointing to the document
        to be analyzed. The properties are mutually exclusive, meaning you
        should provide either a file or a URL, but not both.
      properties:
        file:
          type: string
          format: binary
          title: File
          description: >-
            A binary file representing the document to be analyzed. This should
            be provided as a file upload, for example using a
            multipart/form-data request. The file can be in various formats such
            as .pdf, .docx, .eml, etc. Example usage: -F
            'files=@path/to/your-document.extension'.
        url:
          type: string
          minLength: 1
          format: uri
          title: Url
          description: >-
            A URI pointing to the document to be analyzed. This should be used
            if the document is hosted at a specific URL and can be accessed
            directly from the web.
    DocumentResponse:
      type: object
      properties:
        document_id:
          type: string
          description: ''
        document_name:
          type: string
          description: ''
        document_created_at:
          type: integer
          description: ''
    Error:
      required:
        - detail
      type: object
      properties:
        detail:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````