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

# Upload and link document

> Uploads a file and immediately links it to the agent session.



## OpenAPI

````yaml /api-reference/openapi.en.json post /agent-sessions/{session_id}/upload
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:
  /agent-sessions/{session_id}/upload:
    post:
      tags:
        - Public API
        - Public API - Agent Sessions
      summary: Upload and link document
      description: Uploads a file and immediately links it to the agent session.
      operationId: upload_and_link_document_agent_sessions__session_id__upload_post
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Session Id
        - name: X-End-User-ID
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-End-User-Id
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_and_link_document_agent_sessions__session_id__upload_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicDocument'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    Body_upload_and_link_document_agent_sessions__session_id__upload_post:
      properties:
        file:
          type: string
          format: binary
          title: File
        api_metadata:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Metadata
          description: Custom API metadata (JSON string).
      type: object
      required:
        - file
      title: Body_upload_and_link_document_agent_sessions__session_id__upload_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

````