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

# Upload File

> Mixin for organization access validation.

Automatically resolves and validates organization access on every request,
making the organization available as self.organization.

For API key auth:  organization is derived from the key (no org_id param needed).
For user auth:     organization_id must be provided in the request
                   (kwargs / headers / body / query params).

Usage:
    class MyView(BaseOrganizationAccessMixin, APIView):
        def get(self, request):
            # self.organization is automatically available
            return Response({"org": self.organization.name})

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url "https://api.roe-ai.com/v1/datasets/files/upload/?organization_id=YOUR_ORG_ID" \
    --header "Authorization: Bearer YOUR_API_KEY" \
    --header "Content-Type: multipart/form-data" \
    --form "file=@/path/to/your/file.pdf" \
    --form "dataset_id=YOUR_DATASET_ID"
  ```
</RequestExample>


## OpenAPI

````yaml POST /v1/datasets/files/upload/
openapi: 3.1.0
info:
  title: Roe AI API
  version: 1.0.0
  description: Complete API documentation for Roe AI platform
servers:
  - url: https://api.roe-ai.com
    description: Production API
security: []
paths:
  /v1/datasets/files/upload/:
    post:
      tags:
        - v1
      description: >-
        Mixin for organization access validation.


        Automatically resolves and validates organization access on every
        request,

        making the organization available as self.organization.


        For API key auth:  organization is derived from the key (no org_id param
        needed).

        For user auth:     organization_id must be provided in the request
                           (kwargs / headers / body / query params).

        Usage:
            class MyView(BaseOrganizationAccessMixin, APIView):
                def get(self, request):
                    # self.organization is automatically available
                    return Response({"org": self.organization.name})
      operationId: v1_datasets_files_upload_create
      parameters:
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
            format: uuid
          description: >-
            Organization ID. This is required for access control. It can be
            provided via query or request body depending on the endpoint.
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/FileUploadRequestRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileInfo'
              examples:
                Example:
                  value:
                    id: 123e4567-e89b-12d3-a456-426614174000
                    dataset:
                      id: 123e4567-e89b-12d3-a456-426614174001
                      name: default
                      creator:
                        id: 1
                        email: test@roe-ai.com
                        first_name: Test
                        last_name: Roe
                        is_active: true
                      created_at: '2024-04-29T14:11:16.688751-07:00'
                    name: test1.txt
                    size: 0
                    creator:
                      id: 1
                      email: test@roe-ai.com
                      first_name: Test
                      last_name: Roe
                      is_active: true
                    created_at: '2024-07-01T16:15:51.964998-07:00'
          description: File uploaded
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Example:
                  value:
                    error: Bad request
          description: Bad request
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                Example:
                  value:
                    error: Internal server error
          description: Internal server error
components:
  schemas:
    FileUploadRequestRequest:
      type: object
      properties:
        file:
          type: string
          format: binary
          description: File to upload.
        organization_id:
          type: string
          minLength: 1
          description: >-
            Organization ID. If not provided, file will be uploaded to personal
            dataset.
        metadata:
          description: Optional metadata for the file in JSON format.
      required:
        - file
    FileInfo:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        dataset:
          $ref: '#/components/schemas/DatasetInfo'
        name:
          type: string
          maxLength: 1024
        size:
          type: integer
          maximum: 2147483647
          minimum: -2147483648
        creator:
          oneOf:
            - $ref: '#/components/schemas/UserInfo'
            - type: 'null'
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - created_at
        - creator
        - dataset
        - id
        - name
        - size
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Error message
      required:
        - message
    DatasetInfo:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        name:
          type: string
          maxLength: 1024
        creator:
          oneOf:
            - $ref: '#/components/schemas/UserInfo'
            - type: 'null'
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        organization:
          type: string
          format: uuid
      required:
        - created_at
        - creator
        - id
        - name
        - organization
    UserInfo:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        email:
          type: string
          format: email
          title: Email address
          maxLength: 254
        first_name:
          type: string
          maxLength: 150
        last_name:
          type: string
          maxLength: 150
        display_name:
          type: string
          readOnly: true
      required:
        - display_name
        - email
        - id

````