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

# Upload Docs

> Attach reference documents to the session, reusing the /agent intake
validation (PDF/image direct; office/HTML/EPUB staged to PDF at upload
when LibreOffice is available — otherwise the run-time pipeline converts;
spreadsheets stored NATIVELY on the sheet path — doc_kind='sheet',
page_count counts sheets). This route ADDITIONALLY accepts ``.md/.txt``
text files (D1 doc roles): stored as role-LOCKED context docs
(doc_kind='text') with an upload-time excerpt — never launched, their
content feeds the design agent's context. Stored through the
uploaded-files machinery (the shared ``intake.stage_agent_doc`` path —
the processor page's new-run upload uses the same helper WITHOUT the
text widening); the doc_key is the ``file-{id}`` reference launch_run
resolves.



## OpenAPI

````yaml https://www.datalab.to/openapi.json post /api/v1/agent-studio/sessions/{session_id}/docs
openapi: 3.1.0
info:
  title: Datalab API
  version: 0.0.1
servers:
  - url: https://www.datalab.to
    description: Datalab API
security: []
paths:
  /api/v1/agent-studio/sessions/{session_id}/docs:
    post:
      tags:
        - agent-studio
      summary: Upload Docs
      description: >-
        Attach reference documents to the session, reusing the /agent intake

        validation (PDF/image direct; office/HTML/EPUB staged to PDF at upload

        when LibreOffice is available — otherwise the run-time pipeline
        converts;

        spreadsheets stored NATIVELY on the sheet path — doc_kind='sheet',

        page_count counts sheets). This route ADDITIONALLY accepts ``.md/.txt``

        text files (D1 doc roles): stored as role-LOCKED context docs

        (doc_kind='text') with an upload-time excerpt — never launched, their

        content feeds the design agent's context. Stored through the

        uploaded-files machinery (the shared ``intake.stage_agent_doc`` path —

        the processor page's new-run upload uses the same helper WITHOUT the

        text widening); the doc_key is the ``file-{id}`` reference launch_run

        resolves.
      operationId: upload_docs_api_v1_agent_studio_sessions__session_id__docs_post
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: integer
            title: Session Id
        - name: wos-session
          in: cookie
          required: false
          schema:
            type: string
            title: Wos-Session
        - name: datalab_active_team
          in: cookie
          required: false
          schema:
            type: string
            title: Datalab Active Team
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: >-
                #/components/schemas/Body_upload_docs_api_v1_agent_studio_sessions__session_id__docs_post
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocsUploadResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    Body_upload_docs_api_v1_agent_studio_sessions__session_id__docs_post:
      properties:
        files:
          items:
            type: string
            contentMediaType: application/octet-stream
          type: array
          title: Files
          description: >-
            Reference documents: PDF/image/office/HTML/EPUB (processing docs),
            spreadsheets (sheet path), and .md/.txt text files (context-only).
      type: object
      required:
        - files
      title: Body_upload_docs_api_v1_agent_studio_sessions__session_id__docs_post
    DocsUploadResponse:
      properties:
        docs:
          items:
            $ref: '#/components/schemas/ReferenceDocResponse'
          type: array
          title: Docs
      type: object
      required:
        - docs
      title: DocsUploadResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ReferenceDocResponse:
      properties:
        id:
          type: integer
          title: Id
        name:
          type: string
          title: Name
        page_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Page Count
          description: >-
            Surface count of `doc_kind` surfaces: pages for page docs, SHEETS
            for sheet docs (spreadsheets have no pages — sheet path, plan A7).
            Always None for text docs.
        doc_kind:
          anyOf:
            - type: string
              enum:
                - page
                - sheet
                - text
            - type: 'null'
          title: Doc Kind
          description: >-
            What page_count counts (the locator surface vocabulary); 'text' =
            context-only .md/.txt doc. None = legacy row, page semantics.
        role:
          type: string
          enum:
            - process
            - context
          title: Role
          description: >-
            What the doc is FOR (D1): 'process' docs are exercised by
            commits/launches; 'context' docs feed the agent's context and never
            launch runs.
          default: process
        role_locked:
          type: boolean
          title: Role Locked
          description: >-
            True for text docs — they can only be context (no converter on the
            agent path covers text).
          default: false
        created:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created
      type: object
      required:
        - id
        - name
      title: ReferenceDocResponse
    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
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````