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

# Request Upload Url

> Request a presigned upload URL for direct client-side upload to storage.

This is the recommended upload flow:
1. Client calls this endpoint with filename and content_type
2. Backend creates a pending file record and returns presigned PUT URL
3. Client uploads directly to storage using the presigned URL
4. Client calls /confirm to verify upload and get actual file size



## OpenAPI

````yaml https://www.datalab.to/openapi.json post /api/v1/files/upload
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/files/upload:
    post:
      tags:
        - files
      summary: Request Upload Url
      description: |-
        Request a presigned upload URL for direct client-side upload to storage.

        This is the recommended upload flow:
        1. Client calls this endpoint with filename and content_type
        2. Backend creates a pending file record and returns presigned PUT URL
        3. Client uploads directly to storage using the presigned URL
        4. Client calls /confirm to verify upload and get actual file size
      operationId: request_upload_url_api_v1_files_upload_post
      parameters:
        - 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/RequestUploadUrlRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestUploadUrlResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    RequestUploadUrlRequest:
      properties:
        filename:
          type: string
          title: Filename
          description: Original filename (used for storage path and metadata)
        content_type:
          type: string
          title: Content Type
          description: MIME type of the file
        processing_location:
          anyOf:
            - type: string
            - type: 'null'
          title: Processing Location
          description: >-
            Optional residency region override (e.g. us, eu). When provided, the
            direct-upload URL is issued for storage in that region.
      type: object
      required:
        - filename
        - content_type
      title: RequestUploadUrlRequest
      description: Request to get a presigned upload URL.
    RequestUploadUrlResponse:
      properties:
        file_id:
          type: integer
          title: File Id
          description: Unique file ID (use this to confirm upload)
        upload_url:
          type: string
          title: Upload Url
          description: Presigned PUT URL to upload the file to
        expires_in:
          type: integer
          title: Expires In
          description: URL expiry time in seconds
          default: 3600
        reference:
          type: string
          title: Reference
          description: File reference in datalab://file-{id} format
      type: object
      required:
        - file_id
        - upload_url
        - reference
      title: RequestUploadUrlResponse
      description: Response with presigned PUT URL for direct storage upload.
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````