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

# Ingest documents from files or URLs

> Unified endpoint to ingest documents from various sources.

This endpoint can handle file uploads and URL scraping in a single request.
It uses multipart/form-data.

- To upload files, include them in the 'files' part of the form.
- To scrape URLs, provide a comma-separated string in the 'urls' form field.
- Specify workspace IDs to associate the ingested documents with specific workspaces.

**Note:** Supported file types depend on the server's active capabilities (e.g. audio/video files require transcription to be enabled).



## OpenAPI

````yaml /api-reference/openapi.en.json post /documents
openapi: 3.1.0
info:
  title: UBIK Public API
  description: Publicly accessible API endpoints for UBIK.
  version: '1.0'
servers:
  - url: https://app.ubik-agent.com/api/v1
    description: Production Server
security: []
paths:
  /documents:
    post:
      tags:
        - Public API
        - Public API - Documents
      summary: Ingest documents from files or URLs
      description: >-
        Unified endpoint to ingest documents from various sources.


        This endpoint can handle file uploads and URL scraping in a single
        request.

        It uses multipart/form-data.


        - To upload files, include them in the 'files' part of the form.

        - To scrape URLs, provide a comma-separated string in the 'urls' form
        field.

        - Specify workspace IDs to associate the ingested documents with
        specific workspaces.


        **Note:** Supported file types depend on the server's active
        capabilities (e.g. audio/video files require transcription to be
        enabled).
      operationId: ingest_documents_documents_post
      parameters:
        - name: X-End-User-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-End-User-Id
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_ingest_documents_documents_post'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/PublicDocument'
                title: Response Ingest Documents Documents Post
        '400':
          description: Bad Request
          content:
            application/json:
              example:
                detail: Either 'files' or 'urls' must be provided.
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    Body_ingest_documents_documents_post:
      properties:
        files:
          anyOf:
            - items:
                type: string
                format: binary
              type: array
            - type: 'null'
          title: Files
          description: A list of files to upload.
        urls:
          anyOf:
            - type: string
            - type: 'null'
          title: Urls
          description: A comma-separated list of URLs to scrape.
        workspace_ids:
          anyOf:
            - type: string
            - type: 'null'
          title: Workspace Ids
          description: A comma-separated list of workspace IDs to add the documents to.
        api_metadata:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Metadata
          description: Custom API metadata (JSON string).
        scraping_mode:
          type: string
          title: Scraping Mode
          description: Scraping mode ('Simple Scraping' or 'Crawling').
          default: Simple Scraping
        crawl_depth:
          type: integer
          title: Crawl Depth
          description: The maximum depth for crawling links.
          default: 2
        same_domain_only:
          type: boolean
          title: Same Domain Only
          description: Whether to only crawl links on the same domain.
          default: true
        limit:
          type: integer
          title: Limit
          description: The maximum number of pages to crawl.
          default: 10
        delay:
          type: number
          title: Delay
          description: The delay in seconds between requests.
          default: 1
        youtube_download_format:
          type: string
          title: Youtube Download Format
          description: The format to download YouTube videos in ('audio' or 'video').
          default: audio
      type: object
      title: Body_ingest_documents_documents_post
    PublicDocument:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: The unique identifier for the document.
        name:
          type: string
          title: Name
          description: The display name of the document.
        file_type:
          anyOf:
            - type: string
            - type: 'null'
          title: File Type
          description: The MIME type of the document file.
        status:
          type: string
          title: Status
          description: The current processing status of the document.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: The timestamp when the document was created.
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: The timestamp when the document was last updated.
        processing_pipeline:
          anyOf:
            - type: string
            - type: 'null'
          title: Processing Pipeline
          description: The name of the processing pipeline used for this document.
        error_message:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Message
          description: If processing failed, this field will contain the error message.
        api_metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Api Metadata
          description: >-
            Custom API metadata resolved for the current user. Useful for
            retrieving stored external references (e.g. {'internal_app_ref':
            'REF-123'}). Note: This value is resolved based on the request's
            external_user_id. A document shared globally but also scoped to a
            specific user may return different metadata depending on who is
            asking.
        file_name:
          anyOf:
            - type: string
            - type: 'null'
          title: File Name
          description: The original file name of the document.
        markdown_content:
          anyOf:
            - type: string
            - type: 'null'
          title: Markdown Content
          description: The full content of the document converted to Markdown format.
      type: object
      required:
        - id
        - name
        - status
        - created_at
        - updated_at
      title: PublicDocument
    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:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-KEY

````