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

# Complete a multipart upload

> Complete a multipart upload after all parts have been uploaded to S3.

After uploading all parts using the presigned URLs from the initiate endpoint,
call this endpoint with the ID, key, and all part ETags to finalize the upload.

The input should contain:
- `id`: the ID from the multipart upload initiation (previously called uploadId)
- `key`: the S3 key from the multipart upload initiation
- `parts`: array of objects with partNumber and eTag for each uploaded part

Complete a multipart upload after all parts have been uploaded to S3. This is the final step in the multipart upload workflow.

<Info>
  After uploading all parts using the presigned URLs from the initiate endpoint,
  call this endpoint with the ID, key, and all part ETags to finalize the
  upload.
</Info>

## How It Works

<Steps>
  <Step title="1. Upload All Parts">
    Upload each part to its respective presigned URL using PUT requests
  </Step>

  <Step title="2. Collect ETags">
    Extract the ETag from the response headers of each part upload
  </Step>

  <Step title="3. Complete Upload">
    Call this endpoint with all part ETags to finalize the multipart upload
  </Step>
</Steps>

## Request Parameters

### Request Body

The request body must contain a JSON object with the following properties:

| Property | Type   | Required | Description                                                              |
| -------- | ------ | -------- | ------------------------------------------------------------------------ |
| id       | string | Yes      | The ID from the multipart upload initiation (previously called uploadId) |
| key      | string | Yes      | The S3 key from the multipart upload initiation                          |
| parts    | array  | Yes      | Array of objects with partNumber and eTag for each uploaded part         |

#### Parts Array Structure

Each object in the `parts` array should contain:

| Property   | Type   | Required | Description                              |
| ---------- | ------ | -------- | ---------------------------------------- |
| partNumber | number | Yes      | Sequential part number (1, 2, 3, ...)    |
| eTag       | string | Yes      | ETag value from the part upload response |

## Complete Workflow Example

1. **Initiate Upload**: Call `/prod/v1/files/upload/multipart` to get presigned URLs
2. **Upload Parts**: Use PUT requests to upload each part to its presigned URL
3. **Complete Upload**: Call this endpoint with all part ETags to finalize

<Note>
  After completion, the file will be automatically processed according to the
  parameters specified during initiation (OCR model, schema locking, etc.).
</Note>


## OpenAPI

````yaml post /prod/v1/files/upload/multipart/complete
openapi: 3.0.0
info:
  title: Public API
  description: >-

    ### Welcome to fileAI’s Public API Documentation.

    This API allows users to check the health of the system, upload and manage
    files, and manage AI Schemas.

    Should you have any questions, please reach out to fileAI via the “Contact a
    Developer” link below.



    [Contact a Developer](mailto:support@file.ai)



    ### Prerequisites


    Before using our API, please ensure you complete the following prerequisites

    - You must have a fileAI account. Sign up or login
    [here](https://orion.file.ai/en/sign-up)

    - You must have an API Key. After creating your fileAI account, you can
    generate your API Key. Refer to the Authentication section below for more
    details.



    ### Authentication

    All API requests require an API key for authentication.

    - To obtain your API key, please log in to your fileAI account and navigate
    to Project Settings in your dashboard

    - Keep your API key secure and do not share it publicly.


    ![Authentication](https://fileai-static-assets.s3.us-west-2.amazonaws.com/public-api-service/authentication.png)


    ### How to Use Your API Key

    Once you have your API key:

    - Click the Authorize button on the top-right of this page

    - Enter your API Key under Value

    - Click Authorize to start making authenticated requests directly from the
    documentation


    ![How to Use Your API
    Key](https://fileai-static-assets.s3.us-west-2.amazonaws.com/public-api-service/how-to-use-api-keys.png)
        
  version: '1.0'
  contact: {}
servers:
  - url: https://api.orion.file.ai
security: []
tags:
  - name: Public API V1
paths:
  /prod/v1/files/upload/multipart/complete:
    post:
      tags:
        - Public API V1
      summary: Complete a multipart upload
      description: >-
        Complete a multipart upload after all parts have been uploaded to S3.


        After uploading all parts using the presigned URLs from the initiate
        endpoint,

        call this endpoint with the ID, key, and all part ETags to finalize the
        upload.


        The input should contain:

        - `id`: the ID from the multipart upload initiation (previously called
        uploadId)

        - `key`: the S3 key from the multipart upload initiation

        - `parts`: array of objects with partNumber and eTag for each uploaded
        part
      operationId: PublicAPIController_completeMultipartUploadRequest
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CompleteMultipartUploadForPAInput'
      responses:
        '201':
          description: Multipart upload completed successfully
          content:
            application/json:
              example:
                location: >-
                  https://s3.amazonaws.com/bucket/org_123/workspace_456/device/file_abc/document.pdf
                key: org_123/workspace_456/device/file_abc/document.pdf
                etag: '"abc123def456-2"'
                success: true
        '401':
          description: Invalid API key | API key is missing
          content:
            application/json:
              example:
                message: Invalid API key
                error: Unauthorized
                statusCode: 401
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                  statusCode:
                    type: number
        '403':
          description: Access denied. You are in readonly mode.
          content:
            application/json:
              example:
                message: Access denied. You are in readonly mode.
                error: Forbidden
                statusCode: 403
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                  statusCode:
                    type: number
        '422':
          description: Invalid input parameters
          content:
            application/json:
              examples:
                invalidId:
                  summary: Invalid id
                  value:
                    message: Invalid id.
                    error: Unprocessable Entity
                    statusCode: 422
                invalidKey:
                  summary: Invalid key
                  value:
                    message: Invalid key.
                    error: Unprocessable Entity
                    statusCode: 422
                invalidParts:
                  summary: Invalid parts
                  value:
                    message: Invalid parts. At least one part is required.
                    error: Unprocessable Entity
                    statusCode: 422
                s3Error:
                  summary: S3 multipart upload error
                  value:
                    message: >-
                      Error generate multi presigned url:: The specified upload
                      does not exist.
                    error: Internal Server Error
                    statusCode: 500
              schema:
                type: object
                properties:
                  message:
                    type: string
                  error:
                    type: string
                  statusCode:
                    type: number
        '429':
          description: Too Many Requests
          content:
            application/json:
              example:
                statusCode: 429
                message: Too Many Requests
              schema:
                type: object
                properties:
                  statusCode:
                    type: number
                  message:
                    type: string
      security:
        - x-api-key: []
components:
  schemas:
    CompleteMultipartUploadForPAInput:
      type: object
      properties:
        id:
          type: string
          description: ID from the multipart upload initiation
          example: upload_abc123xyz
        key:
          type: string
          description: S3 key from the multipart upload initiation
          example: org_123/workspace_456/device/file_abc/document.pdf
        parts:
          description: Array of completed parts with part numbers and ETags
          example:
            - partNumber: 1
              eTag: '"etag1"'
            - partNumber: 2
              eTag: '"etag2"'
          type: array
          items:
            $ref: '#/components/schemas/CompletedMultiPartForPA'
      required:
        - id
        - key
        - parts
    CompletedMultiPartForPA:
      type: object
      properties:
        partNumber:
          type: number
          description: Part number
          example: 1
        eTag:
          type: string
          description: ETag returned from S3 after uploading the part
          example: '"33a64df551425fcc55e4d42a148795d9f25f89d4"'
      required:
        - partNumber
        - eTag
  securitySchemes:
    x-api-key:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication

````