> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-docs-agent-app-service-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Upload Agent App File

> Upload a file for an Agent app conversation. Use the returned `id` as `upload_file_id` in the `files` array when calling Send Agent App Message. Uploaded files are scoped to the same `user` value.



## OpenAPI

````yaml /en/api-reference/openapi_agent.json post /files/upload
openapi: 3.0.1
info:
  title: Agent App API
  description: >-
    Agent apps expose a streaming service API for production integrations. Use
    the API key created from the Agent app API Access page. Public service API
    requests use the returned API base URL and do not include the Agent ID in
    the path; the API key identifies the backing app.
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: >-
      Base URL of the Agent App API. Use the Service API Base URL shown in the
      Agent app API Access page. 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: Agent Messages
    description: Send Agent app messages and stop running tasks.
  - name: Agent Files
    description: Upload files for Agent app conversations.
  - name: Agent Conversations
    description: List Agent app conversations and conversation messages.
  - name: Agent App
    description: Retrieve Agent app parameters and metadata.
paths:
  /files/upload:
    post:
      tags:
        - Agent Files
      summary: Upload Agent App File
      description: >-
        Upload a file for an Agent app conversation. Use the returned `id` as
        `upload_file_id` in the `files` array when calling Send Agent App
        Message. Uploaded files are scoped to the same `user` value.
      operationId: uploadAgentAppFile
      requestBody:
        description: File upload request. Requires multipart/form-data.
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - user
              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.
      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.**

````