> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.konfidant.app/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.konfidant.app/_mcp/server.

# Complete Encrypted File Upload

POST https://www.konfidant.app/api/v1/files/{fileKey}/complete

Step 3 of a file share, after the ciphertext `PUT` has finished. Verifies that the uploaded object has the declared size and a valid KNF1 header, then returns the single-use download URL. Succeeds exactly once per upload. Uploads that are not completed within 2 hours expire.

Reference: https://docs.konfidant.app/konfidant-api/complete-file-upload

## Authentication

- `Authorization` header (bearer token, required) — Konfidant API key (`kf_live_...` or `kf_test_...`), created by an organization admin in the dashboard.

## Request

### Path parameters

- `fileKey` (string, required) — The `file_key` returned by `POST /api/v1/files`.

## Response

### 201

Created

- `download_url` (string, required) — Single-use download URL with the server-issued token in the fragment (`#t=...`). It does not open the share by itself: append `&k=<base64url key>` to build the share link you send to the recipient.
- `file_id` (string, required, nullable) — Share ID; null unless verified burn is enabled.
- `expires_at` (datetime, required) — When the share link expires (ISO 8601).
- `verified_burn` (boolean, required) — Whether the organization has verified burn enabled. When false, no share record is stored and the ID is null.

## Errors

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)

### 403 Forbidden Error

Forbidden: missing scope, plan without API access, or quota exceeded

- `error` (string, required)
- `code` (string, optional) — `api_quota_exceeded` when the organization's API share allowance is used up.
- `required_scope` (string, optional)
- `available_scopes` (list of string, optional)

### 404 Not Found Error

Not Found: unknown file key, or the upload was already completed

- `error` (string, required)

### 409 Conflict Error

Conflict: the ciphertext has not been uploaded yet; retry after the `PUT` finished

- `error` (string, required)

### 410 Gone Error

Gone: the upload slot expired; start again with `POST /api/v1/files`

- `error` (string, required)

### 422 Unprocessable Entity Error

Unprocessable: the uploaded object does not match `ciphertext_size` or is not KNF1; it has been deleted

- `error` (string, required)

### 429 Too Many Requests Error

Rate limit exceeded

- `error` (string, required)
- `limit` (integer, optional)
- `window_seconds` (integer, optional)
- `retry_after_seconds` (integer, optional)

### 502 Bad Gateway Error

Share service unavailable; retry later

- `error` (string, required)

## Examples

**Response**

```json
{
  "download_url": "https://download.konfidant.app/#t=hvs.CAESIABCDEFG...",
  "file_id": "681da863-a551-4b0e-8f3c-6d2e9a1b7c40",
  "expires_at": "2026-10-05T12:00:00.000Z",
  "verified_burn": true
}
```

**SDK Code**

```python completeFileUpload_example
import requests

url = "https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript completeFileUpload_example
const url = 'https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go completeFileUpload_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby completeFileUpload_example
require 'uri'
require 'net/http'

url = URI("https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java completeFileUpload_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php completeFileUpload_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp completeFileUpload_example
using RestSharp;

var client = new RestClient("https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift completeFileUpload_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://www.konfidant.app/api/v1/files/3f9a0c5e7b1d2a4f6e8c0b9d7a5f3e1c2b4d6f8a0e9c7b5d3f1a2c4e6b8d0f9a/complete")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```