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

# Add Files To Collection

> Link existing uploaded files to a collection.



## OpenAPI

````yaml https://www.datalab.to/openapi.json post /api/v1/collections/{collection_id}/files
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/collections/{collection_id}/files:
    post:
      tags:
        - collections
      summary: Add Files To Collection
      description: Link existing uploaded files to a collection.
      operationId: add_files_to_collection_api_v1_collections__collection_id__files_post
      parameters:
        - name: collection_id
          in: path
          required: true
          schema:
            type: integer
            title: Collection 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/AddFilesToCollectionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CollectionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    AddFilesToCollectionRequest:
      properties:
        uploaded_file_ids:
          items:
            type: integer
          type: array
          maxItems: 100
          minItems: 1
          title: Uploaded File Ids
      type: object
      required:
        - uploaded_file_ids
      title: AddFilesToCollectionRequest
    CollectionResponse:
      properties:
        id:
          type: integer
          title: Id
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        archived:
          type: boolean
          title: Archived
        file_count:
          type: integer
          title: File Count
          default: 0
        files:
          items:
            $ref: '#/components/schemas/CollectionFileResponse'
          type: array
          title: Files
        s3_source:
          anyOf:
            - $ref: '#/components/schemas/CollectionS3SourceResponse'
            - type: 'null'
        s3_status:
          anyOf:
            - $ref: '#/components/schemas/CollectionS3StatusResponse'
            - type: 'null'
        created:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created
        updated:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated
      type: object
      required:
        - id
        - name
        - description
        - archived
        - created
        - updated
      title: CollectionResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CollectionFileResponse:
      properties:
        uploaded_file_id:
          type: integer
          title: Uploaded File Id
        original_filename:
          type: string
          title: Original Filename
        file_size:
          type: integer
          title: File Size
        content_type:
          type: string
          title: Content Type
        sort_order:
          type: integer
          title: Sort Order
        source_type:
          type: string
          enum:
            - upload
            - s3
          title: Source Type
          default: upload
        external_key:
          anyOf:
            - type: string
            - type: 'null'
          title: External Key
        external_etag:
          anyOf:
            - type: string
            - type: 'null'
          title: External Etag
        external_last_modified:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: External Last Modified
        external_deleted_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: External Deleted At
        last_eval_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Last Eval Score
        last_score_breakdown:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Last Score Breakdown
      type: object
      required:
        - uploaded_file_id
        - original_filename
        - file_size
        - content_type
        - sort_order
      title: CollectionFileResponse
    CollectionS3SourceResponse:
      properties:
        id:
          type: integer
          title: Id
        bucket:
          type: string
          title: Bucket
        prefix:
          anyOf:
            - type: string
            - type: 'null'
          title: Prefix
        region:
          anyOf:
            - type: string
            - type: 'null'
          title: Region
        credentials_type:
          type: string
          enum:
            - access_key
            - public
          title: Credentials Type
        aws_access_key_id:
          type: string
          title: Aws Access Key Id
        aws_secret_access_key_redacted:
          type: string
          title: Aws Secret Access Key Redacted
        sync_status:
          type: string
          title: Sync Status
        last_sync_started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Sync Started At
        last_sync_completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Sync Completed At
        last_sync_file_count:
          type: integer
          title: Last Sync File Count
        last_sync_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Sync Error
        output_bucket:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Bucket
        output_prefix:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Prefix
        output_region:
          anyOf:
            - type: string
            - type: 'null'
          title: Output Region
        output_credentials_type:
          type: string
          enum:
            - source
            - access_key
          title: Output Credentials Type
        output_aws_access_key_id:
          type: string
          title: Output Aws Access Key Id
        output_aws_secret_access_key_redacted:
          type: string
          title: Output Aws Secret Access Key Redacted
        writeback_status:
          type: string
          title: Writeback Status
        last_writeback_run_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Last Writeback Run Id
        last_writeback_started_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Writeback Started At
        last_writeback_completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Writeback Completed At
        last_writeback_file_count:
          type: integer
          title: Last Writeback File Count
        last_writeback_total_file_count:
          type: integer
          title: Last Writeback Total File Count
        last_writeback_failed_file_count:
          type: integer
          title: Last Writeback Failed File Count
        last_writeback_error:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Writeback Error
        last_writeback_error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Writeback Error Code
        last_writeback_manifest_uri:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Writeback Manifest Uri
      type: object
      required:
        - id
        - bucket
        - prefix
        - region
        - credentials_type
        - aws_access_key_id
        - aws_secret_access_key_redacted
        - sync_status
        - last_sync_started_at
        - last_sync_completed_at
        - last_sync_file_count
        - last_sync_error
        - output_bucket
        - output_prefix
        - output_region
        - output_credentials_type
        - output_aws_access_key_id
        - output_aws_secret_access_key_redacted
        - writeback_status
        - last_writeback_run_id
        - last_writeback_started_at
        - last_writeback_completed_at
        - last_writeback_file_count
        - last_writeback_total_file_count
        - last_writeback_failed_file_count
        - last_writeback_error
        - last_writeback_error_code
        - last_writeback_manifest_uri
      title: CollectionS3SourceResponse
    CollectionS3StatusResponse:
      properties:
        collection_id:
          type: integer
          title: Collection Id
        sync_status:
          type: string
          title: Sync Status
        writeback_status:
          type: string
          title: Writeback Status
      type: object
      required:
        - collection_id
        - sync_status
        - writeback_status
      title: CollectionS3StatusResponse
    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

````