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

# ファイルをアップロード

> **対象アプリ**：Chatflow、Workflow、新しい Agent、チャットボット、Agent、テキストジェネレーター。

メッセージ送信時に使用するファイルをアップロードします。画像、ドキュメント、音声、動画のマルチモーダル理解が可能です。アップロードされたファイルは現在のエンドユーザーのみが使用できます。



## OpenAPI

````yaml /ja/api-reference/openapi_service.json post /files/upload
openapi: 3.0.1
info:
  title: Dify サービス API
  description: >-
    Dify アプリケーションとナレッジベースのための REST API です。アプリケーション系エンドポイントはアプリの API
    キーで、ナレッジ系エンドポイントはナレッジベースの API キーで認証します。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: Dify サービス API のベース URL です。セルフホスト環境では、独自の API ベース URL に置き換えてください。
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: API ベース URL のホストとパス（`https://` を除く）。
security:
  - ApiKeyAuth: []
tags:
  - name: チャットメッセージ
    description: チャットメッセージとインタラクションに関連する操作です。
  - name: ファイル操作
    description: ファイルのアップロードとプレビューの操作です。
  - name: エンドユーザー
    description: エンドユーザー情報に関連する操作です。
  - name: メッセージフィードバック
    description: ユーザーフィードバックの操作です。
  - name: 会話管理
    description: 会話管理に関連する操作です。
  - name: 音声・テキスト変換
    description: テキスト読み上げと音声認識の操作です。
  - name: アプリケーション設定
    description: アプリケーション設定と情報を取得する操作です。
  - name: アノテーション管理
    description: ダイレクト返信用のアノテーション管理に関連する操作です。
  - name: 人間の入力
    description: 人間の入力を要する一時停止中のワークフローの再開操作です。
  - name: ワークフロー実行
    description: ワークフローの実行と管理のための操作です。
  - name: 完了メッセージ
    description: テキスト生成に関連する操作です。
  - name: ナレッジベース
    description: ナレッジベースの作成、設定、取得を含むナレッジベース管理の操作です。
  - name: ドキュメント
    description: ナレッジベース内のドキュメントの作成、更新、管理のための操作です。
  - name: チャンク
    description: ドキュメントチャンクと子チャンクの管理のための操作です。
  - name: メタデータ
    description: ナレッジベースのメタデータフィールドとドキュメントメタデータ値の管理のための操作です。
  - name: タグ管理
    description: ナレッジベースタグとタグバインディングの管理のための操作です。
  - name: モデル
    description: 利用可能なモデルを取得するための操作です。
  - name: ナレッジパイプライン
    description: データソースプラグインとパイプライン実行を含むナレッジパイプラインの管理と実行のための操作です。
paths:
  /files/upload:
    post:
      tags:
        - ファイル操作
      summary: ファイルをアップロード
      description: >-
        **対象アプリ**：Chatflow、Workflow、新しい Agent、チャットボット、Agent、テキストジェネレーター。


        メッセージ送信時に使用するファイルをアップロードします。画像、ドキュメント、音声、動画のマルチモーダル理解が可能です。アップロードされたファイルは現在のエンドユーザーのみが使用できます。
      operationId: uploadBasicChatFileJa
      requestBody:
        description: ファイルアップロードリクエスト。multipart/form-data 形式が必要です。
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: アップロードするファイル。サポートされるタイプには画像、ドキュメント、音声、動画が含まれます。
                user:
                  type: string
                  description: >-
                    ユーザー識別子。開発者のルールで定義され、アプリケーション内で一意である必要があります。Service API と
                    WebApp のユーザー ID は独立しており、値が同じでも同じユーザーを指しません。省略した場合、アップロードは共有の
                    `DEFAULT-USER` エンドユーザーに帰属します。ファイルは、アップロード時と同じ `user`
                    値を持つリクエストからのみ使用できます。
      responses:
        '201':
          description: ファイルが正常にアップロードされました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadResponse'
              examples:
                uploadSuccess:
                  summary: レスポンス例
                  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` : リクエストにファイルが提供されていません。
            - `too_many_files` : 1 回のリクエストにつき 1 ファイルのみ許可されています。
            - `filename_not_exists_error` : アップロードされたファイルにファイル名がありません。
            - `invalid_param` : ファイル名に不正な文字（`/` または `\`）が含まれています。
          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` : ファイルサイズの上限を超えています。'
          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` : 許可されていないファイルタイプです。'
          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: 一意のファイル ID。
        name:
          type: string
          description: ファイル名。
        size:
          type: integer
          description: ファイルサイズ（バイト）。
        extension:
          type: string
          nullable: true
          description: ファイル拡張子。
        mime_type:
          type: string
          nullable: true
          description: ファイルの MIME タイプ。
        created_by:
          type: string
          format: uuid
          nullable: true
          description: ファイルをアップロードしたユーザーの ID。
        created_at:
          type: integer
          format: int64
          description: アップロードタイムスタンプ（Unix エポック秒）。
        preview_url:
          type: string
          nullable: true
          description: ファイルのプレビュー URL。
        source_url:
          type: string
          description: ファイルの署名付きダウンロード URL です。
        original_url:
          type: string
          nullable: true
          description: ファイルの元の URL。
        user_id:
          type: string
          format: uuid
          nullable: true
          description: 未使用です。常に `null` になります。
        tenant_id:
          type: string
          format: uuid
          nullable: true
          description: 関連付けられたテナントの ID。
        conversation_id:
          type: string
          format: uuid
          nullable: true
          description: 関連付けられた会話の ID。
        file_key:
          type: string
          nullable: true
          description: 未使用です。常に `null` になります。
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key 認証です。すべての API リクエストにおいて、`Authorization` HTTP ヘッダーに `Bearer `
        プレフィックスを付けた API Key を含めてください。例：`Authorization: Bearer {API_KEY}`。**API
        Key はサーバーサイドに保存し、クライアントサイドで共有・保存しないことを強く推奨します。API Key
        の漏洩は深刻な結果につながる可能性があります。**API Key が欠落または無効な場合、HTTP `401` とエラーコード
        `unauthorized` が返されます。

````