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

# Attach files to a running session

> Attaches files to the session. Each attaches the file's content as it is now, is placed in the sandbox on the session's next tool call, and is visible to the agent from its next turn under the session's files directory. All-or-nothing: one unknown file_id answers 404 and one path colliding with, or nesting inside, another's answers 409, and nothing is attached either way. A member session of a multi-agent tree answers 409: files are attached to its root. A completed, failed, or cancelled root session is accepted, and its next message resumes it with the file already staged.



## OpenAPI

````yaml /managed-agents/openapi.yaml post /managed-agents/v1/sessions/{session_id}/resources
openapi: 3.1.0
info:
  title: Managed Agents API
  version: 0.13.0
  description: >-
    The Recursion Managed Agents REST API. Authenticate with a Recursion API key
    as a bearer token. An organization-scoped key acts in its own organization
    and needs nothing else; a tenant-scoped key must also send
    `x-organization-id` with an organization id or `default`. Field names follow
    each operation's published schema.
servers:
  - url: https://api.recursion.labelbox.com
security:
  - bearerAuth: []
paths:
  /managed-agents/v1/sessions/{session_id}/resources:
    post:
      tags:
        - Sessions
      summary: Attach files to a running session
      description: >-
        Attaches files to the session. Each attaches the file's content as it is
        now, is placed in the sandbox on the session's next tool call, and is
        visible to the agent from its next turn under the session's files
        directory. All-or-nothing: one unknown file_id answers 404 and one path
        colliding with, or nesting inside, another's answers 409, and nothing is
        attached either way. A member session of a multi-agent tree answers 409:
        files are attached to its root. A completed, failed, or cancelled root
        session is accepted, and its next message resumes it with the file
        already staged.
      operationId: managedAgentsAddSessionResources
      parameters:
        - description: Session id (UUID) as returned by startSession or listSessions.
          in: path
          name: session_id
          required: true
          schema:
            description: Session id (UUID) as returned by startSession or listSessions.
            format: uuid
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ManagedAgentsAddSessionResourcesRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsSessionResourceListResponse'
          description: >-
            Response body of GET and POST /v1/sessions/{session_id}/resources. A
            POST returns only the resources it attached.
        '400':
          description: The request was rejected by schema or semantic validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '401':
          description: The caller is unauthenticated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '403':
          description: The caller lacks a required permission or capability.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiErrorForbidden'
        '404':
          description: No such resource is reachable for this caller.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '409':
          description: >-
            The request conflicts with the resource state, or with an in-flight
            idempotent replay.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '413':
          description: The request exceeds a size or transaction budget.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '415':
          description: The request body uses a media type this operation does not accept.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiErrorUnsupportedMediaType'
        '429':
          headers:
            Retry-After:
              description: Seconds the caller should wait before retrying.
              schema:
                type: string
              style: simple
          description: A rate limit is exhausted. Honor `Retry-After`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '500':
          description: An unexpected server-side failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '502':
          description: The service returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiErrorBadGateway'
        '503':
          headers:
            Retry-After:
              description: Seconds the caller should wait before retrying.
              schema:
                type: string
              style: simple
          description: A dependency is unavailable. Retryable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiError'
        '504':
          headers:
            Retry-After:
              description: When to retry, as delay seconds or an HTTP date.
              schema:
                type: string
          description: The service did not respond before the timeout. Retryable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ManagedAgentsApiErrorGatewayTimeout'
components:
  schemas:
    ManagedAgentsAddSessionResourcesRequest:
      description: >-
        Request body for attaching files to a running session. The files are
        staged into the sandbox on the session's next tool call and are visible
        to the agent from its next turn.
      properties:
        resources:
          description: >-
            Files to attach. All-or-nothing: one unknown file_id or one path
            collision refuses the whole batch and attaches nothing.
          items:
            $ref: '#/components/schemas/ManagedAgentsSessionResourceRequest'
          maxItems: 500
          minItems: 1
          type:
            - array
            - 'null'
      type: object
      example:
        resources:
          - file_id: 9f8b1c2d-3e4f-5a6b-7c8d-9e0f1a2b3c4d
            mount_path: example
            relative_path: example
            type: file
    ManagedAgentsSessionResourceListResponse:
      description: >-
        Response body of GET and POST /v1/sessions/{session_id}/resources. A
        POST returns only the resources it attached.
      properties:
        resources:
          description: >-
            Every file attached to the session, in attachment order, each with
            its sandbox path once staged.
          items:
            $ref: '#/components/schemas/ManagedAgentsSessionResource'
          type:
            - array
            - 'null'
      required:
        - resources
      type: object
      example:
        resources:
          - byte_size: 1
            created_at: '2026-02-18T09:30:00.000Z'
            file_id: 9f8b1c2d-3e4f-5a6b-7c8d-9e0f1a2b3c4d
            filename: example
            media_type: example
            mount_path: example
            relative_path: example
            resource_id: 9f8b1c2d-3e4f-5a6b-7c8d-9e0f1a2b3c4d
            sha256: example
            type: file
    ManagedAgentsApiError:
      type: object
      properties:
        code:
          type: string
          minLength: 1
          description: Stable machine-readable error code.
          enum:
            - analytics
            - analytics_not_ready
            - artifact_fetch_unavailable
            - artifact_generation_mismatch
            - artifact_hash_mismatch
            - artifact_invalid_events
            - artifact_invalid_json
            - artifact_not_allowlisted
            - artifact_size_mismatch
            - atomic_ingest_timeout
            - auth_unavailable
            - automation_event_source_invalid
            - automation_memory_unavailable
            - automation_reference_invalid
            - automation_runs_unconfigured
            - automations_unconfigured
            - bad_gateway
            - built_in_catalog_unavailable
            - built_in_integrations_unconfigured
            - compute_offerings_unavailable
            - conflict
            - content_store_request_canceled
            - content_store_unavailable
            - content_store_upload_timeout
            - credential_encryption_unconfigured
            - delegate_preparation_failed
            - entity_family_not_permitted
            - environment_not_verified
            - evaluation_cancellation_pending
            - evaluation_deletion_pending
            - event_admission_unavailable
            - event_ingress_unavailable
            - event_source_verification_credential_invalid
            - event_sources_unconfigured
            - execution_unconfigured
            - file_quota_exceeded
            - file_storage_unconfigured
            - forbidden
            - gateway_timeout
            - gestalt_unconfigured
            - github_rate_limited
            - github_unavailable
            - handoff_access_invalid
            - handoff_access_unavailable
            - handoff_access_unsupported
            - handoff_capture_unavailable
            - handoff_requires_retest
            - handoff_revoke_unavailable
            - handoff_signal_unavailable
            - idempotency_conflict
            - idempotency_in_progress
            - idempotency_unavailable
            - ingest_policy_changed
            - ingest_policy_not_found
            - ingest_policy_revoked
            - integrations_unconfigured
            - internal_error
            - invalid_json
            - invalid_pull_request_review_result
            - invalid_request
            - invalid_scope
            - invariant_violation
            - live_fleet_unconfigured
            - managed_agents_unavailable
            - missing_dependency
            - model_gateway_metadata_missing
            - model_gateway_unconfigured
            - model_gateway_unreachable
            - mutation_transaction_budget_exceeded
            - not_found
            - page_token_expired
            - payload_too_large
            - persistence_busy
            - precondition_failed
            - precondition_required
            - provider_registration_unsupported
            - provider_selection_unsupported
            - rate_limit_exceeded
            - rate_limited
            - repository_automation_unconfigured
            - request_too_large
            - reserved_source_type
            - revision_conflict
            - run_log_store_unavailable
            - runner_image_resolution_failed
            - sandbox_provider_disabled
            - service_unavailable
            - session_analyst_busy
            - session_analyst_model_unavailable
            - session_analyst_unconfigured
            - session_start_admission_unavailable
            - session_start_not_admitted
            - setup_fallback_environment_unsafe
            - setup_run_finished
            - setup_run_in_progress
            - setup_run_limit
            - setup_run_not_started
            - setup_runs_unavailable
            - skill_storage_unconfigured
            - slack_channels_rejected
            - slack_channels_unavailable
            - slack_channels_unconfigured
            - slack_connection_malformed
            - slack_event_intake_unavailable
            - slack_installation_mismatch
            - slack_missing_scope
            - slack_rate_limited
            - slack_reapproval_required
            - source_ownership_mismatch
            - source_revision_conflict
            - spanner_unavailable
            - streaming_unsupported
            - submission_transaction_budget_exceeded
            - task_version_number_conflict
            - team_board_unconfigured
            - too_many_streams
            - unauthorized
            - unsupported_media_type
            - vault_creation_retired
            - version_content_conflict
            - webhook_delivery_too_large
            - workspace_boundary_denied
        message:
          type: string
          minLength: 1
          description: Human-readable error message.
        details:
          description: Optional structured error details.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - code
        - message
      additionalProperties: false
      description: Standard flat error response.
    ManagedAgentsApiErrorForbidden:
      type: object
      properties:
        code:
          type: string
          minLength: 1
          description: Stable machine-readable error code.
          enum:
            - forbidden
        message:
          type: string
          minLength: 1
          description: Human-readable error message.
        details:
          description: Optional structured error details.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - code
        - message
      additionalProperties: false
      description: Standard flat error response.
    ManagedAgentsApiErrorUnsupportedMediaType:
      type: object
      properties:
        code:
          type: string
          minLength: 1
          description: Stable machine-readable error code.
          enum:
            - unsupported_media_type
        message:
          type: string
          minLength: 1
          description: Human-readable error message.
        details:
          description: Optional structured error details.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - code
        - message
      additionalProperties: false
      description: Standard flat error response.
    ManagedAgentsApiErrorBadGateway:
      type: object
      properties:
        code:
          type: string
          minLength: 1
          description: Stable machine-readable error code.
          enum:
            - bad_gateway
        message:
          type: string
          minLength: 1
          description: Human-readable error message.
        details:
          description: Optional structured error details.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - code
        - message
      additionalProperties: false
      description: Standard flat error response.
    ManagedAgentsApiErrorGatewayTimeout:
      type: object
      properties:
        code:
          type: string
          minLength: 1
          description: Stable machine-readable error code.
          enum:
            - gateway_timeout
        message:
          type: string
          minLength: 1
          description: Human-readable error message.
        details:
          description: Optional structured error details.
          type: object
          propertyNames:
            type: string
          additionalProperties: {}
      required:
        - code
        - message
      additionalProperties: false
      description: Standard flat error response.
    ManagedAgentsSessionResourceRequest:
      description: One file to attach to a session.
      properties:
        file_id:
          description: >-
            The file to mount. Must belong to the caller's organization and not
            have expired.
          format: uuid
          type: string
        mount_path:
          description: >-
            The same place named absolutely, with the session's files directory
            as its root: /data/input.csv lands at data/input.csv, as does the
            directory's own absolute path copied from a session's resource list,
            and the /mnt/session/uploads/ prefix is accepted as an alias for the
            directory. Any other absolute root is likewise a path beneath the
            directory, never a mount elsewhere. Paths take the same shape rules
            as relative_path (no . or .. segments, no control characters, at
            most 255 characters); the filename's reserved-character rule does
            not apply to paths. Set this or relative_path; both are accepted
            only when they agree.
          type: string
        relative_path:
          description: >-
            Where the file lands relative to the session's files directory, e.g.
            data/input.csv. Defaults to the file's own name. Must be unique
            within the session and may not contain . or .. segments.
          type: string
        type:
          description: Always file.
          enum:
            - file
          type: string
      type: object
      example:
        file_id: 9f8b1c2d-3e4f-5a6b-7c8d-9e0f1a2b3c4d
        mount_path: example
        relative_path: example
        type: file
    ManagedAgentsSessionResource:
      description: >-
        A file attached to a session. The file is placed read-only in the
        session's sandbox under its files directory, and the agent knows it is
        there, so it can read it with read_file or from a shell without being
        told where to look.
      properties:
        byte_size:
          description: Size of the file in bytes.
          format: int64
          type: integer
        created_at:
          description: When the resource was attached.
          format: date-time
          type: string
        file_id:
          description: The attached file.
          type: string
        filename:
          description: The file's name at upload.
          type: string
        media_type:
          description: The file's declared media type.
          type: string
        mount_path:
          description: >-
            The absolute path where the file is readable inside the sandbox.
            Absent until staging reaches the sandbox; a resource attached
            mid-session is staged on the next sandbox call.
          type: string
        relative_path:
          description: >-
            Where the file lands relative to the session's files directory.
            Defaults to the filename; set it on attach to rename the file or
            place it in a subdirectory.
          type: string
        resource_id:
          description: Server-assigned id of the attachment, used to detach it.
          type: string
        sha256:
          description: >-
            SHA-256 of the bytes the session mounts. Frozen at attach: a later
            change to the file does not change this session.
          type: string
        type:
          description: Always file.
          enum:
            - file
          type: string
      required:
        - resource_id
        - type
        - file_id
        - filename
        - media_type
        - byte_size
        - sha256
        - relative_path
        - created_at
      type: object
      example:
        byte_size: 1
        created_at: '2026-02-18T09:30:00.000Z'
        file_id: 9f8b1c2d-3e4f-5a6b-7c8d-9e0f1a2b3c4d
        filename: example
        media_type: example
        mount_path: example
        relative_path: example
        resource_id: 9f8b1c2d-3e4f-5a6b-7c8d-9e0f1a2b3c4d
        sha256: example
        type: file
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A Recursion API key, created in the console under API keys.

````