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

# Upload File

> Upload a file for use when sending messages, enabling multimodal understanding of images, documents, audio, and video. Uploaded files are for use by the current end-user only.



## OpenAPI

````yaml /en/api-reference/openapi_completion.json post /files/upload
openapi: 3.0.1
info:
  title: Completion App API
  description: >-
    The text generation application offers non-session support and is ideal for
    translation, article writing, summarization AI, and more.
  version: 1.0.0
servers:
  - url: '{api_base_url}'
    description: >-
      The base URL for the Completion App API. Replace {api_base_url} with the
      actual API base URL provided for your application.
    variables:
      api_base_url:
        default: https://api.dify.ai/v1
        description: Actual base URL of the API
security:
  - ApiKeyAuth: []
tags:
  - name: Completions
    description: Operations related to text generation and completion.
  - name: Files
    description: Operations related to file management.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: Operations related to user feedback.
  - name: TTS
    description: Operations related to Text-to-Speech and Speech-to-Text.
  - name: Applications
    description: Operations to retrieve application settings and information.
paths:
  /files/upload:
    post:
      tags:
        - Files
      summary: Upload File
      description: >-
        Upload a file for use when sending messages, enabling multimodal
        understanding of images, documents, audio, and video. Uploaded files are
        for use by the current end-user only.
      operationId: uploadFile
      requestBody:
        description: File upload request. Requires multipart/form-data.
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    The file to be uploaded. Supported types include images,
                    documents, audio, and video.
                user:
                  type: string
                  description: >-
                    User identifier, defined by the developer's rules, must be
                    unique within the application.
      responses:
        '201':
          description: File uploaded successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadResponse'
              examples:
                uploadSuccess:
                  summary: Response Example
                  value:
                    id: a1b2c3d4-5678-90ab-cdef-1234567890ab
                    name: product-photo.png
                    size: 204800
                    extension: png
                    mime_type: image/png
                    created_by: f1e2d3c4-b5a6-7890-abcd-ef1234567890
                    created_at: 1705407629
                    preview_url: null
                    source_url: null
                    original_url: null
                    user_id: f1e2d3c4-b5a6-7890-abcd-ef1234567890
                    tenant_id: 11223344-5566-7788-99aa-bbccddeeff00
                    conversation_id: null
                    file_key: uploads/product-photo.png
        '400':
          description: |-
            - `no_file_uploaded` : No file was provided in the request.
            - `too_many_files` : Only one file is allowed per request.
            - `filename_not_exists_error` : The uploaded file has no filename.
          content:
            application/json:
              examples:
                no_file_uploaded:
                  summary: no_file_uploaded
                  value:
                    status: 400
                    code: no_file_uploaded
                    message: Please upload your file.
                too_many_files:
                  summary: too_many_files
                  value:
                    status: 400
                    code: too_many_files
                    message: Only one file is allowed.
                filename_not_exists_error:
                  summary: filename_not_exists_error
                  value:
                    status: 400
                    code: filename_not_exists_error
                    message: The specified filename does not exist.
        '413':
          description: '`file_too_large` : File size exceeded.'
          content:
            application/json:
              examples:
                file_too_large:
                  summary: file_too_large
                  value:
                    status: 413
                    code: file_too_large
                    message: File size exceeded.
        '415':
          description: '`unsupported_file_type` : File type not allowed.'
          content:
            application/json:
              examples:
                unsupported_file_type:
                  summary: unsupported_file_type
                  value:
                    status: 415
                    code: unsupported_file_type
                    message: File type not allowed.
components:
  schemas:
    FileUploadResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique file ID.
        name:
          type: string
          description: File name.
        size:
          type: integer
          description: File size in bytes.
        extension:
          type: string
          nullable: true
          description: File extension.
        mime_type:
          type: string
          nullable: true
          description: MIME type of the file.
        created_by:
          type: string
          format: uuid
          nullable: true
          description: ID of the user who uploaded the file.
        created_at:
          type: integer
          format: int64
          description: Upload timestamp (Unix epoch seconds).
        preview_url:
          type: string
          nullable: true
          description: Preview URL for the file.
        source_url:
          type: string
          nullable: true
          description: Source URL of the file.
        original_url:
          type: string
          nullable: true
          description: Original URL of the file.
        user_id:
          type: string
          format: uuid
          nullable: true
          description: ID of the associated user.
        tenant_id:
          type: string
          format: uuid
          nullable: true
          description: ID of the associated tenant.
        conversation_id:
          type: string
          format: uuid
          nullable: true
          description: ID of the associated conversation.
        file_key:
          type: string
          nullable: true
          description: Storage key for the file.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key authentication. For all API requests, include your API Key in
        the `Authorization` HTTP Header, prefixed with `Bearer `. Example:
        `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API
        Key on the server-side, not shared or stored on the client-side, to
        avoid possible API-Key leakage that can lead to serious consequences.**

````