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

# Link User File To Project

> Link an existing user file to a specific project for the current user.

Creates the association in the Project__UserFile join table if it does not exist.
Returns the linked user file snapshot.



## OpenAPI

````yaml POST /user/projects/{project_id}/files/{file_id}
openapi: 3.1.0
info:
  title: Onyx API
  description: Onyx API for AI-powered enterprise search and chat
  version: Development
servers:
  - url: https://cloud.onyx.app/api
security: []
paths:
  /user/projects/{project_id}/files/{file_id}:
    post:
      tags:
        - public
      summary: Link User File To Project
      description: >-
        Link an existing user file to a specific project for the current user.


        Creates the association in the Project__UserFile join table if it does
        not exist.

        Returns the linked user file snapshot.
      operationId: link_user_file_to_project
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: integer
            title: Project Id
        - name: file_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: File Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserFileSnapshot'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    UserFileSnapshot:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        temp_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Temp Id
        name:
          type: string
          title: Name
        project_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Project Id
        user_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: User Id
        file_id:
          type: string
          title: File Id
        created_at:
          type: string
          format: date-time
          title: Created At
        status:
          $ref: '#/components/schemas/UserFileStatus'
        last_accessed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Accessed At
        file_type:
          anyOf:
            - type: string
            - type: 'null'
          title: File Type
        chat_file_type:
          $ref: '#/components/schemas/ChatFileType'
        token_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Token Count
        chunk_count:
          anyOf:
            - type: integer
            - type: 'null'
          title: Chunk Count
      type: object
      required:
        - id
        - name
        - user_id
        - file_id
        - created_at
        - status
        - last_accessed_at
        - file_type
        - chat_file_type
        - token_count
        - chunk_count
      title: UserFileSnapshot
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UserFileStatus:
      type: string
      enum:
        - PROCESSING
        - COMPLETED
        - FAILED
        - CANCELED
        - DELETING
      title: UserFileStatus
    ChatFileType:
      type: string
      enum:
        - image
        - document
        - plain_text
        - csv
      title: ChatFileType
    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:
    BearerAuth:
      type: http
      scheme: bearer
      description: Authorization header with Bearer token

````