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

# Prepare session for file upload

> Initiate a file upload session and get the upload URLs.



## OpenAPI

````yaml /api-reference/openapi.yml post /file-upload/prepare
openapi: 3.0.3
info:
  title: DataLinks
  version: 2.2.3
servers:
  - url: https://api.datalinks.com/api/v1
    description: production server
security:
  - bearerAuth: []
  - openId:
      - implicit
paths:
  /file-upload/prepare:
    post:
      tags:
        - fileUpload
      summary: Prepare session for file upload
      description: Initiate a file upload session and get the upload URLs.
      operationId: prepareFileUpload
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FileUploadPrepareSessionRequest'
        required: true
      responses:
        '200':
          description: Returns the file upload session details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadPrepareSessionResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    FileUploadPrepareSessionRequest:
      required:
        - filesToUpload
      type: object
      properties:
        filesToUpload:
          type: array
          items:
            $ref: '#/components/schemas/FileUploadPrepareSessionRequestFileToUpload'
      description: A request contaning list of pairs of file names and their sizes.
    FileUploadPrepareSessionResponse:
      required:
        - files
        - sessionId
      type: object
      properties:
        sessionId:
          $ref: '#/components/schemas/UploadSessionId'
        files:
          type: array
          items:
            $ref: '#/components/schemas/FileUploadPrepareSessionResponseFileInfo'
      description: A response containing the upload ID and key for the multipart upload.
    FileUploadPrepareSessionRequestFileToUpload:
      required:
        - filename
        - size
      type: object
      properties:
        filename:
          type: string
          description: Name of the file to be uploaded.
        size:
          type: integer
          description: Size of the file in bytes.
          format: int64
      description: Information about each file to be uploaded.
    UploadSessionId:
      type: string
      description: Unique identifier for the upload session.
      format: uuid
      example: 24b49ba0-6b5c-4950-94c1-1622939cc481
    FileUploadPrepareSessionResponseFileInfo:
      required:
        - fileId
        - filename
        - key
        - partSize
        - presignedUrls
        - uploadId
      type: object
      properties:
        fileId:
          $ref: '#/components/schemas/UploadFileId'
        uploadId:
          type: string
          description: Upload identifier
        key:
          type: string
          description: Name of the file to be uploaded.
        filename:
          type: string
          description: File name
        partSize:
          type: integer
          description: Size of the part to be uploaded
          format: int64
        presignedUrls:
          type: array
          description: List of presiggned ULR where file has to be uploaded
          items:
            $ref: '#/components/schemas/FileUploadPrepareSessionResponsePresignedInfo'
      description: Information about each file to be uploaded.
    ErrorResponse:
      required:
        - error_code
        - message
      type: object
      properties:
        error_code:
          type: string
          example: UNAUTHORIZED
        error_message:
          type: string
          example: ''
        message:
          type: string
          example: Missing authentication token
        sub_errors:
          type: array
          items:
            required:
              - code
              - message
            type: object
            properties:
              code:
                type: string
              message:
                type: string
    UploadFileId:
      type: string
      description: Unique identifier for a file
      format: uuid
      example: 311fe2cb-1c85-46a4-a8d9-f63a88da44fd
    FileUploadPrepareSessionResponsePresignedInfo:
      required:
        - partSize
        - url
      type: object
      properties:
        url:
          type: string
          description: URL for the presigned upload.
        partSize:
          type: integer
          description: Size of the part to be uploaded
          format: int64
      description: Information about each file to be uploaded.
  responses:
    Unauthorized:
      description: >-
        Unauthorized. This error occurs if the authentication token is missing
        or invalid.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: Forbidden. The user does not have access to this resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      description: >
        Use a Bearer token for authentication. Submit the token using the
        `Authorization`

        header: `Authorization: Bearer <token>`.
      scheme: bearer
    openId:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: >-
            https://login.datalinks.com/realms/datalinks-realm/protocol/openid-connect/auth
          scopes:
            openid: openid

````