> ## 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

> **Available for**: Chatflow, Workflow, New Agent, Chatbot, Agent, Text Generator apps.

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_service.json post /files/upload
openapi: 3.0.1
info:
  title: Dify Service API
  description: >-
    REST API for Dify applications and knowledge bases. Application endpoints
    authenticate with an app API key; knowledge endpoints authenticate with a
    dataset API key.
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: >-
      Base URL of the Dify Service API. For self-hosted deployments, replace it
      with your own API base URL.
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - name: Chat Messages
    description: Operations related to chat messages and interactions.
  - name: Files
    description: File upload and preview operations.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: User feedback operations.
  - name: Conversations
    description: Operations related to managing conversations.
  - name: Audio
    description: Text-to-Speech and Speech-to-Text operations.
  - name: Applications
    description: Operations to retrieve application settings and information.
  - name: Annotations
    description: Operations related to managing annotations for direct replies.
  - name: Human Input
    description: Endpoints for resuming paused workflows that require human input.
  - name: Workflow Runs
    description: Operations for executing and managing workflows.
  - name: Completion Messages
    description: Operations related to text generation and completion.
  - name: Knowledge Bases
    description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
  - name: Documents
    description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
  - name: Chunks
    description: Operations for managing document chunks and child chunks.
  - name: Metadata
    description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
  - name: Tags
    description: Operations for managing knowledge base tags and tag bindings.
  - name: Models
    description: Operations for retrieving available models.
  - name: Knowledge Pipeline
    description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
paths:
  /files/upload:
    post:
      tags:
        - Files
      summary: Upload File
      description: >-
        **Available for**: Chatflow, Workflow, New Agent, Chatbot, Agent, Text
        Generator apps.


        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: uploadChatFile
      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: >-
                    Identifier for the end user, defined by your application's
                    rules and unique within the app. Service API and WebApp user
                    IDs are separate, even when identical. If omitted, the
                    upload is attributed to the shared `DEFAULT-USER` end user;
                    a file can only be used later by requests carrying the same
                    `user` value.
      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: >-
                      https://upload.dify.ai/files/a1b2c3d4-5678-90ab-cdef-1234567890ab/file-preview?timestamp=1705407629&nonce=8b3e26a5&sign=rN5DXW3xkVGwGE5MSvptu_BhQVXpMbXWmVJ0ib0LMzI=
                    original_url: null
                    user_id: null
                    tenant_id: 11223344-5566-7788-99aa-bbccddeeff00
                    conversation_id: null
                    file_key: null
        '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.

            - `invalid_param` : The filename contains invalid characters (`/` or
            `\`).
          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.
                invalid_param:
                  summary: invalid_param
                  value:
                    status: 400
                    code: invalid_param
                    message: Filename contains invalid characters
        '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
          description: Signed URL for downloading the file.
        original_url:
          type: string
          nullable: true
          description: Original URL of the file.
        user_id:
          type: string
          format: uuid
          nullable: true
          description: Unused; always `null`.
        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: Unused; always `null`.
  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.**
        Requests with a missing or invalid API key fail with HTTP `401` and
        error code `unauthorized`.

````