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

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

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



## OpenAPI

````yaml /ja/api-reference/openapi_completion.json post /files/upload
openapi: 3.0.1
info:
  title: Completion アプリ API
  description: テキスト生成アプリケーションはセッションなしで動作し、翻訳、記事作成、要約 AI などに最適です。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: テキスト生成アプリ 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: アプリケーション設定と情報を取得する操作です。
paths:
  /files/upload:
    post:
      tags:
        - ファイル操作
      summary: ファイルをアップロード
      description: >-
        メッセージ送信時に使用するファイルをアップロードします。画像、ドキュメント、音声、動画のマルチモーダル理解が可能です。アップロードされたファイルは現在のエンドユーザーのみが使用できます。
      operationId: uploadCompletionFileJp
      requestBody:
        description: ファイルアップロードリクエスト。multipart/form-data 形式が必要です。
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - user
              properties:
                file:
                  type: string
                  format: binary
                  description: アップロードするファイル。サポートされるタイプには画像、ドキュメント、音声、動画が含まれます。
                user:
                  type: string
                  description: >-
                    ユーザー識別子。開発者のルールで定義され、アプリケーション内で一意である必要があります。Service API と
                    WebApp のユーザー ID は独立しており、値が同じでも同じユーザーを指しません。
      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: 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` : リクエストにファイルが提供されていません。
            - `too_many_files` : 1 回のリクエストにつき 1 ファイルのみ許可されています。
            - `filename_not_exists_error` : アップロードされたファイルにファイル名がありません。
          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` : ファイルサイズの上限を超えています。'
          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
          nullable: true
          description: ファイルのソース URL。
        original_url:
          type: string
          nullable: true
          description: ファイルの元の URL。
        user_id:
          type: string
          format: uuid
          nullable: true
          description: 関連付けられたユーザーの ID。
        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: ファイルのストレージキー。
  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
        の漏洩は深刻な結果につながる可能性があります。**

````