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

# Complete Multipart Upload

> Finalize a multipart upload

## Overview

Completes a multipart upload by assembling all uploaded parts. After this, call `/s3/entries` to register the file in Drime.

## Request Body

<ParamField body="key" type="string" required>
  S3 key from `createMultipartUpload`
</ParamField>

<ParamField body="uploadId" type="string" required>
  Upload ID from `createMultipartUpload`
</ParamField>

<ParamField body="parts" type="array" required>
  Array of uploaded parts with their ETags

  <Expandable title="Part object properties">
    <ParamField body="PartNumber" type="integer" required>
      Part number (1-indexed)
    </ParamField>

    <ParamField body="ETag" type="string" required>
      ETag from S3 upload response (must include quotes)
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="location" type="string">
  Final S3 location of the assembled file
</ResponseField>

<ResponseField name="status" type="string">
  Request status (`success`)
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://app.drime.cloud/api/v1/s3/multipart/complete \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "key": "uploads/1e4cbca8.../1e4cbca8...",
      "uploadId": "AFNhWKh6Cn6f...",
      "parts": [
        {"PartNumber": 1, "ETag": "\"22b1d5721320f9da081e4987f0e0ce65\""},
        {"PartNumber": 2, "ETag": "\"479df46a73824ca1a5e44efe64d3dbb7\""}
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  // After uploading all parts...
  const response = await fetch('https://app.drime.cloud/api/v1/s3/multipart/complete', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      key,
      uploadId,
      parts: uploadedParts // Array of { PartNumber, ETag }
    })
  });

  const { location } = await response.json();
  console.log('Upload complete:', location);

  // Now register the file with /s3/entries
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://app.drime.cloud/api/v1/s3/multipart/complete',
      headers={'Authorization': 'Bearer YOUR_ACCESS_TOKEN'},
      json={
          'key': key,
          'uploadId': upload_id,
          'parts': [
              {'PartNumber': 1, 'ETag': '"22b1d5721320f9da081e4987f0e0ce65"'},
              {'PartNumber': 2, 'ETag': '"479df46a73824ca1a5e44efe64d3dbb7"'}
          ]
      }
  )

  print('Upload complete:', response.json()['location'])
  ```
</RequestExample>

<ResponseExample>
  ```json 200 - Success theme={null}
  {
    "location": "https://xxx.r2.cloudflarestorage.com/drimestorage/uploads%2F1e4cbca8...%2F1e4cbca8...",
    "status": "success"
  }
  ```
</ResponseExample>

<Warning>
  ETags must include the surrounding quotes (e.g., `"abc123"`). These are returned in the S3 response headers.
</Warning>
