---
title: "Upload an encrypted file"
method: POST
path: "/files/encrypted/upload"
tags: ["Files Encrypted", "dev-api"]
---

# Upload an encrypted file

`POST /files/encrypted/upload`

## Request

- Base URL: `https://gateway.prem.io`
- URL: `https://gateway.prem.io/files/encrypted/upload`
- Auth: HTTP bearer and API key in header `Authorization`

Upload a new encrypted file to the organization's secure file storage with client-side encryption

## Request body

- UploadFileEncryptedRequest: Request body for uploading an encrypted file
  - `encrypted_content` string, required: The encrypted file content as hexadecimal string
  - `encrypted_name` string, required: The encrypted original filename
  - `client_hash` string, required: Client-side hash for duplicate detection
  - `kid` string, required: Key identifier used for encryption
  - `wrapped_dek` string, required: Wrapped data encryption key
  - `mime_type` string, required: MIME type of the original file (encrypted on client side before sending)
  - `incognito` boolean: Whether the file is incognito (optional)
  - `version` union: Encryption version (optional)
    - integer
    - string
  - `encrypted_rag_dek` string: Encrypted RAG data encryption key
  - `rag_dek_nonce` string: Nonce used for RAG DEK encryption
  - `cipher_text` string: Cipher text for RAG encryption context
  - `encrypted_file_dek` string: Encrypted file data encryption key
  - `file_nonce` string: Nonce used for file encryption

## Response `200`

Encrypted file uploaded successfully

- object: Response containing the uploaded encrypted file information
  - `status` 200 | 201 | 202, required: Status code of the response
  - `data` object, nullable, required
    - `id` string, required: Unique identifier for the encrypted file
    - `version` string, required: Encryption version
    - `kid` string, required: Key identifier used for encryption
    - `wrapped_dek` string, required: Wrapped data encryption key
    - `file_name` string, required: Generated filename for storage
    - `file_path` string, required: Full path to the encrypted file in storage
    - `file_size` integer, required: File size in bytes
    - `type` string, required: Type of the file - always 'encrypted' for fully encrypted files
    - `mime_type` string, required: MIME type, encrypted by the client
    - `is_duplicate` boolean, required: Indicates if the file is a duplicate
    - `created_at` string, mysql-date-time: Timestamp when the file was created
    - `updated_at` string, mysql-date-time, nullable: Timestamp when the file was last updated
    - `original_name` string: Original filename
  - `error` string, nullable: Error message of the response, human readable
  - `message` string, nullable, required: Message of the response, human readable
  - `env` 'development' | 'production', required: API environment
  - `log` union: Useful informaiton, not always present, to debug the response
    - string
    - object
  - `validator` union: Validator response object, each key is the field name and value is the error message
    - object
    - unknown[]
      - unknown
  - `support_id` string, uuid, nullable: Support ID linked to the response, used to identify it when talking with our team.

## Other responses

- `400`: Bad request
- `401`: Access token is missing or invalid
- `403`: You do not have the required permissions to access this resource

## Changes

- **2026-11-13** `d46bc3931b34`: 9 warning
  - added the new `405.00` enum value to the `allOf[subschema #1]/status` response property for the response status `401`
  - added the new `405.00` enum value to the `allOf[subschema #1]/status` response property for the response status `403`
  - added the new `405.00` enum value to the `status` response property for the response status `400`
  - added the new `409.00` enum value to the `allOf[subschema #1]/status` response property for the response status `401`
  - …5 more
- **2026-10-16** `d5b1beb33be5`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/premai-io/apis/prem-studio-api/changes/files/encrypted/upload/post.md)

---

[API](https://skmtc.dev/premai-io/apis/prem-studio-api.md) - [All operations](https://skmtc.dev/premai-io/apis/prem-studio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/premai-io/apis/prem-studio-api/revisions/d46bc3931b34?raw)
