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

# Set Doc Role

> Flip one reference doc between 'process' and 'context' (D1 doc roles
— the chip toggle). Text docs are role-LOCKED to context (400). A
same-role PATCH is an idempotent no-op (200, no event). A real flip
appends a USER-actor activity event (consumable — the brain learns and
reacts) and ticks the session. Flipping to context does NOT cancel
in-flight runs — runs pin their inputs at launch (chronology honesty).



## OpenAPI

````yaml https://www.datalab.to/openapi.json patch /api/v1/agent-studio/sessions/{session_id}/docs/{doc_id}
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/{doc_id}:
    patch:
      tags:
        - agent-studio
      summary: Set Doc Role
      description: |-
        Flip one reference doc between 'process' and 'context' (D1 doc roles
        — the chip toggle). Text docs are role-LOCKED to context (400). A
        same-role PATCH is an idempotent no-op (200, no event). A real flip
        appends a USER-actor activity event (consumable — the brain learns and
        reacts) and ticks the session. Flipping to context does NOT cancel
        in-flight runs — runs pin their inputs at launch (chronology honesty).
      operationId: >-
        set_doc_role_api_v1_agent_studio_sessions__session_id__docs__doc_id__patch
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: integer
            title: Session Id
        - name: doc_id
          in: path
          required: true
          schema:
            type: integer
            title: Doc 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:
          application/json:
            schema:
              $ref: '#/components/schemas/DocRoleRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReferenceDocResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    DocRoleRequest:
      properties:
        role:
          type: string
          enum:
            - process
            - context
          title: Role
      type: object
      required:
        - role
      title: DocRoleRequest
      description: |-
        PATCH /sessions/{id}/docs/{doc_id} — flip one reference doc's role
        (D1 doc roles). Text docs are role-LOCKED to context (400).
    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
    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
        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

````