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

# Upload an encrypted file

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



## OpenAPI

````yaml post /files/encrypted/upload
openapi: 3.1.0
info:
  title: Prem API
  description: Reference documentation for the Prem API.
  version: 1.0.0
  termsOfService: https://prem.io/terms
  contact:
    name: API Support
    url: https://help.prem.io
    email: support@premai.io
servers:
  - url: https://gateway.prem.io
    description: Production API server
security: []
paths:
  /files/encrypted/upload:
    post:
      tags:
        - Files Encrypted
        - dev-api
      summary: Upload an encrypted file
      description: >-
        Upload a new encrypted file to the organization's secure file storage
        with client-side encryption
      operationId: uploadFileEncrypted
      requestBody:
        $ref: '#/components/requestBodies/uploadFileEncryptedRequest'
      responses:
        '200':
          $ref: '#/components/responses/uploadFileEncryptedResponse'
        '400':
          $ref: '#/components/responses/400'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
      security:
        - BearerAuth: []
          ApiKeyAuth: []
components:
  requestBodies:
    uploadFileEncryptedRequest:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/uploadFileEncryptedRequest'
  responses:
    '400':
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: integer
                enum:
                  - 400
                  - 401
                  - 403
                  - 404
                  - 429
                  - 502
                  - 503
                description: Status code of the response
              data:
                type:
                  - object
                  - 'null'
                description: Response data containing the requested object
              error:
                type:
                  - string
                  - 'null'
                examples:
                  - Some error message
                description: Error message of the response, human readable
              message:
                type: 'null'
              env:
                type: string
                enum:
                  - development
                  - production
                description: API environment
              log:
                type:
                  - string
                  - object
                  - 'null'
                examples:
                  - request_id: req_1234567890
                  - Some pertinent log message
                description: Useful informaiton, not always present, to debug the response
              validator:
                type:
                  - object
                  - array
                  - 'null'
                examples:
                  - email: Invalid email address
                    password: Password is required
                description: >-
                  Validator response object, each key is the field name and
                  value is the error message
              support_id:
                type:
                  - string
                  - 'null'
                format: uuid
                examples:
                  - support_uuidv7-something-else
                description: >-
                  Support ID linked to the response, used to identify it when
                  talking with our team
            required:
              - status
              - error
              - message
              - env
              - log
              - support_id
            additionalProperties: false
    '401':
      description: Access token is missing or invalid
      content:
        application/json:
          schema:
            allOf:
              - type: object
                properties:
                  status:
                    type: integer
                    enum:
                      - 400
                      - 401
                      - 403
                      - 404
                      - 429
                      - 502
                      - 503
                    description: Status code of the response
                  data:
                    type:
                      - object
                      - 'null'
                    description: Response data containing the requested object
                  error:
                    type:
                      - string
                      - 'null'
                    examples:
                      - Some error message
                    description: Error message of the response, human readable
                  message:
                    type: 'null'
                  env:
                    type: string
                    enum:
                      - development
                      - production
                    description: API environment
                  log:
                    type:
                      - string
                      - object
                      - 'null'
                    examples:
                      - request_id: req_1234567890
                      - Some pertinent log message
                    description: >-
                      Useful informaiton, not always present, to debug the
                      response
                  validator:
                    type:
                      - object
                      - array
                      - 'null'
                    examples:
                      - email: Invalid email address
                        password: Password is required
                    description: >-
                      Validator response object, each key is the field name and
                      value is the error message
                  support_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    examples:
                      - support_uuidv7-something-else
                    description: >-
                      Support ID linked to the response, used to identify it
                      when talking with our team
                required:
                  - status
                  - error
                  - message
                  - env
                  - log
                  - support_id
                additionalProperties: false
              - properties:
                  status:
                    type: integer
                    enum:
                      - 401
    '403':
      description: You do not have the required permissions to access this resource
      content:
        application/json:
          schema:
            allOf:
              - type: object
                properties:
                  status:
                    type: integer
                    enum:
                      - 400
                      - 401
                      - 403
                      - 404
                      - 429
                      - 502
                      - 503
                    description: Status code of the response
                  data:
                    type:
                      - object
                      - 'null'
                    description: Response data containing the requested object
                  error:
                    type:
                      - string
                      - 'null'
                    examples:
                      - Some error message
                    description: Error message of the response, human readable
                  message:
                    type: 'null'
                  env:
                    type: string
                    enum:
                      - development
                      - production
                    description: API environment
                  log:
                    type:
                      - string
                      - object
                      - 'null'
                    examples:
                      - request_id: req_1234567890
                      - Some pertinent log message
                    description: >-
                      Useful informaiton, not always present, to debug the
                      response
                  validator:
                    type:
                      - object
                      - array
                      - 'null'
                    examples:
                      - email: Invalid email address
                        password: Password is required
                    description: >-
                      Validator response object, each key is the field name and
                      value is the error message
                  support_id:
                    type:
                      - string
                      - 'null'
                    format: uuid
                    examples:
                      - support_uuidv7-something-else
                    description: >-
                      Support ID linked to the response, used to identify it
                      when talking with our team
                required:
                  - status
                  - error
                  - message
                  - env
                  - log
                  - support_id
                additionalProperties: false
              - properties:
                  status:
                    type: integer
                    enum:
                      - 403
    uploadFileEncryptedResponse:
      description: Encrypted file uploaded successfully
      content:
        application/json:
          schema:
            allOf:
              - $ref: '#/components/schemas/Response200'
              - $ref: '#/components/schemas/uploadFileEncryptedResponse'
  schemas:
    uploadFileEncryptedRequest:
      type: object
      description: Request body for uploading an encrypted file
      properties:
        encrypted_content:
          type: string
          description: The encrypted file content as hexadecimal string
          examples:
            - 0123456789abcdef...
        encrypted_name:
          type: string
          description: The encrypted original filename
          maxLength: 1024
          examples:
            - encrypted_filename
        client_hash:
          type: string
          description: Client-side hash for duplicate detection
          examples:
            - 04b9e2ec43133ae7287f97764c0beda19f304374e1d6bfe4fcc36ad54502e5dc
        kid:
          type: string
          description: Key identifier used for encryption
          examples:
            - key_01234567-89ab-cdef-0123-456789abcdef
        wrapped_dek:
          type: string
          description: Wrapped data encryption key
          examples:
            - 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
        mime_type:
          type: string
          description: >-
            MIME type of the original file (encrypted on client side before
            sending)
          examples:
            - encrypted_mime_type_data
        incognito:
          type: boolean
          description: Whether the file is incognito (optional)
          examples:
            - true
        version:
          type:
            - integer
            - string
          description: Encryption version (optional)
          examples:
            - 1
        encrypted_rag_dek:
          type: string
          description: Encrypted RAG data encryption key
          examples:
            - 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
        rag_dek_nonce:
          type: string
          description: Nonce used for RAG DEK encryption
          examples:
            - 0123456789abcdef0123456789abcdef
        cipher_text:
          type: string
          description: Cipher text for RAG encryption context
          examples:
            - cipher_text_data
        encrypted_file_dek:
          type: string
          description: Encrypted file data encryption key
          examples:
            - 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
        file_nonce:
          type: string
          description: Nonce used for file encryption
          examples:
            - 0123456789abcdef0123456789abcdef
      required:
        - encrypted_content
        - client_hash
        - kid
        - wrapped_dek
        - encrypted_name
        - mime_type
      additionalProperties: false
    Response200:
      type: object
      properties:
        status:
          type: integer
          enum:
            - 200
            - 201
            - 202
          description: Status code of the response
        data:
          type:
            - object
            - array
            - 'null'
          description: Response data containing the requested object
        error:
          type:
            - string
            - 'null'
          examples:
            - Invalid email address
          description: Error message of the response, human readable
        message:
          type:
            - string
            - 'null'
          examples:
            - Resource created successfully
          description: Message of the response, human readable
        env:
          type: string
          enum:
            - development
            - production
          description: API environment
        log:
          type:
            - string
            - object
            - 'null'
          examples:
            - request_id: req_1234567890
            - Some pertinent log message
          description: Useful informaiton, not always present, to debug the response
        validator:
          type:
            - object
            - array
            - 'null'
          examples:
            - email: Invalid email address
              password: Password is required
          description: >-
            Validator response object, each key is the field name and value is
            the error message
        support_id:
          type:
            - string
            - 'null'
          format: uuid
          examples:
            - support_uuidv7-something-else
          description: >-
            Support ID linked to the response, used to identify it when talking
            with our team
      required:
        - status
        - data
        - message
        - env
      examples:
        - status: 200
          data:
            id: '123'
          error: null
          log: null
          validator: null
          support_id: null
          message: Resource created successfully
          env: development
    uploadFileEncryptedResponse:
      type: object
      description: Response containing the uploaded encrypted file information
      properties:
        data:
          type: object
          properties:
            id:
              type: string
              description: Unique identifier for the encrypted file
              examples:
                - file_0198042e-6dde-7b9c-bc91-452a7e0c833b
            version:
              type: string
              description: Encryption version
              examples:
                - '1'
                - '2'
            kid:
              type: string
              description: Key identifier used for encryption
              examples:
                - key_01234567-89ab-cdef-0123-456789abcdef
            wrapped_dek:
              type: string
              description: Wrapped data encryption key
              examples:
                - >-
                  0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
            file_name:
              type: string
              description: Generated filename for storage
              examples:
                - 0198042e-6dde-76e0-b817-3afb324e29ac.enc
            file_path:
              type: string
              description: Full path to the encrypted file in storage
              examples:
                - >-
                  encrypted/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/user_0196b0e9-11d8-7f26-b1d2-bd47054e4827/0198042e-6dde-76e0-b817-3afb324e29ac.enc
            file_size:
              type: integer
              description: File size in bytes
              examples:
                - 1060793
            type:
              type: string
              description: Type of the file - always 'encrypted' for fully encrypted files
              examples:
                - encrypted
            mime_type:
              type: string
              description: MIME type, encrypted by the client
              examples:
                - encrypted_mime_type_data
            is_duplicate:
              type: boolean
              description: Indicates if the file is a duplicate
              examples:
                - false
            created_at:
              type: string
              format: mysql-date-time
              description: Timestamp when the file was created
              examples:
                - '2025-07-13 16:26:48.415'
            updated_at:
              type:
                - string
                - 'null'
              format: mysql-date-time
              description: Timestamp when the file was last updated
              examples:
                - null
            original_name:
              type: string
              description: Original filename
              examples:
                - encrypted-original-filename
          required:
            - id
            - version
            - kid
            - wrapped_dek
            - file_name
            - file_path
            - file_size
            - type
            - mime_type
            - is_duplicate
          additionalProperties: false
      required:
        - data
      examples:
        - data:
            id: file_0198042e-6dde-7b9c-bc91-452a7e0c833b
            version: '1'
            kid: key_01234567-89ab-cdef-0123-456789abcdef
            wrapped_dek: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
            file_name: 0198042e-6dde-76e0-b817-3afb324e29ac.enc
            file_path: >-
              encrypted/org_0196b0e9-11d8-7f26-b1d2-bd47054e4827/user_0196b0e9-11d8-7f26-b1d2-bd47054e4827/0198042e-6dde-76e0-b817-3afb324e29ac.enc
            file_size: 1060793
            type: encrypted
            mime_type: encrypted_mime_type_data
            is_duplicate: false
            created_at: '2025-07-13 16:26:48.415'
            updated_at: null
            original_name: encrypted-original-filename
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: 'Send your access token as header Authorization: Bearer {accessToken}'
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Your API key that starts with sk_live or sk_test. You can create yours
        at go.prem.io/api-keys.

````