> ## 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_workflow.json post /workflows/run
openapi: 3.0.1
info:
  title: ワークフローアプリAPI
  description: ワークフローアプリケーションはセッションなしの動作をサポートし、翻訳、記事作成、要約 AI などに最適です。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: Workflow App 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:
  /workflows/run:
    post:
      tags:
        - ワークフロー
      summary: ワークフローを実行
      description: ワークフローを実行します。公開済みのワークフローがないと実行できません。
      operationId: executeWorkflowJp
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowExecutionRequest'
            examples:
              streaming_example:
                summary: リクエスト例 - ストリーミングモード
                value:
                  inputs:
                    query: >-
                      Summarize this text: The quick brown fox jumps over the
                      lazy dog.
                  response_mode: streaming
                  user: user_workflow_123
              blocking_example:
                summary: リクエスト例 - ブロッキングモード
                value:
                  inputs:
                    query: 'Translate this to French: Hello world'
                  response_mode: blocking
                  user: user_workflow_456
              with_file_array_variable:
                summary: Request Example - File array input
                value:
                  inputs:
                    my_documents:
                      - type: document
                        transfer_method: local_file
                        upload_file_id: a1b2c3d4-5678-90ab-cdef-1234567890ab
                      - type: image
                        transfer_method: remote_url
                        url: https://example.com/image.jpg
                  response_mode: blocking
                  user: user_workflow_789
      responses:
        '200':
          description: >-
            リクエスト成功。コンテンツタイプと構造はリクエストの `response_mode` パラメータに依存します。


            - `response_mode` が `blocking` の場合、 `application/json` で
            `WorkflowBlockingResponse` オブジェクトを返します。

            - `response_mode` が `streaming` の場合、 `text/event-stream` で
            `ChunkWorkflowEvent` オブジェクトのストリームを返します。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowBlockingResponse'
              examples:
                blockingResponse:
                  summary: レスポンス例 - ブロッキングモード
                  value:
                    task_id: c3800678-a077-43df-a102-53f23ed20b88
                    workflow_run_id: fb47b2e6-5e43-4f90-be01-d5c5a088d156
                    data:
                      id: fb47b2e6-5e43-4f90-be01-d5c5a088d156
                      workflow_id: 7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345
                      status: succeeded
                      outputs:
                        result: Bonjour le monde
                      error: null
                      elapsed_time: 1.23
                      total_tokens: 150
                      total_steps: 3
                      created_at: 1705407629
                      finished_at: 1705407630
            text/event-stream:
              schema:
                type: string
                description: >-
                  Server-Sent Events (SSE) のストリーム。


                  **パース**：各行は `data: ` で始まり JSON オブジェクトが続き、`\n\n` で終了します。JSON
                  をパースする前に `data: ` プレフィックスを除去し、`event`
                  フィールドを読み取ってイベントタイプを判定してください。`ping` イベント（接続維持のため 10
                  秒ごとに送信）は無視してください。


                  **ストリームライフサイクル**：`workflow_finished`、`workflow_paused`、または
                  `error` イベントを受信するとストリームが閉じます。エラーはストリーム内の `error` イベントとして HTTP
                  ステータス `200` で配信されます。ステータスコードではなくイベントペイロードを確認して詳細を取得してください。


                  **推論イベント**：

                  - `reasoning_chunk`：`reasoning_format` が `separated` の LLM
                  ノードが発行する思考過程のデルタです。連続する `reasoning_chunk`
                  イベントを連結すると、完全な推論を復元できます。`is_final: true` のイベントはノードの思考完了を示し、空の
                  `reasoning` を伴う場合があります。ペイロードは `data` の下にあり、チャットアプリとは異なり
                  `message_id` や `conversation_id` は含まれません。並行する `text_chunk`
                  ストリームには `<think>` タグが含まれません。


                  **人間の入力イベント**：

                  - `human_input_required`：ワークフローが人間の入力ノードに到達した際に
                  `workflow_paused` と同時に発行されます。ペイロードの `form_token` を使用して、[人間の入力
                  API](/api-reference/人間の入力/人間の入力フォームを取得) でフォーム処理を進めます。

                  - `human_input_form_filled`：受信者がフォームを送信し、ワークフロー実行が再開されます。

                  -
                  `human_input_form_timeout`：応答がないままフォームが期限切れ。タイムアウトのフォールバックエッジが定義されている場合、ワークフローはそのエッジを通って実行されます。
              examples:
                streamingResponse:
                  summary: レスポンス例 - ストリーミングモード
                  value: >-
                    data: {"event": "workflow_started", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id":
                    "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "inputs": {"query":
                    "Translate this"}, "created_at": 1705407629, "reason":
                    "initial"}} data: {"event": "node_started", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id":
                    "node_exec_1", "node_id": "node_1", "node_type": "llm",
                    "title": "LLM Node", "index": 1, "created_at": 1705407629}}
                    data: {"event": "reasoning_chunk", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data":
                    {"reasoning": "Let me translate that.", "node_id": "node_1",
                    "is_final": false}} data: {"event": "reasoning_chunk",
                    "task_id": "c3800678-a077-43df-a102-53f23ed20b88",
                    "workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156",
                    "data": {"reasoning": "", "node_id": "node_1", "is_final":
                    true}} data: {"event": "text_chunk", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"text":
                    "Bonjour", "from_variable_selector": ["node_1", "text"]}}
                    data: {"event": "workflow_finished", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id":
                    "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "status":
                    "succeeded", "outputs": {"result": "Bonjour le monde"},
                    "elapsed_time": 1.23, "total_tokens": 150, "total_steps": 3,
                    "created_at": 1705407629, "finished_at": 1705407630}}
                humanInputPause:
                  summary: レスポンス例 - 人間の入力での一時停止
                  value: >-
                    data: {"event": "workflow_started", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "workflow_id":
                    "7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345", "inputs": {"draft":
                    "Hello"}, "created_at": 1705407629, "reason": "initial"}}
                    data: {"event": "human_input_required", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data": {"form_id":
                    "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "form_token":
                    "tok_abc123", "node_id": "approval_node", "node_title":
                    "Approval", "form_content": "Please review the draft.",
                    "inputs": [{"type": "paragraph", "output_variable_name":
                    "comment", "default": null}], "actions": [{"id": "approve",
                    "title": "Approve", "button_style": "primary"}],
                    "display_in_ui": false, "resolved_default_values":
                    {"comment": ""}, "expiration_time": 1705494029}} data:
                    {"event": "workflow_paused", "task_id":
                    "c3800678-a077-43df-a102-53f23ed20b88", "workflow_run_id":
                    "fb47b2e6-5e43-4f90-be01-d5c5a088d156", "data":
                    {"workflow_run_id": "fb47b2e6-5e43-4f90-be01-d5c5a088d156",
                    "status": "paused", "created_at": 1705407629,
                    "elapsed_time": 0.5}}
        '400':
          description: |-
            - `not_workflow_app` : App mode does not match the API route.
            - `provider_not_initialize` : 有効なモデルプロバイダーの認証情報が見つかりません。
            - `provider_quota_exceeded` : モデルプロバイダーのクォータが使い切られました。
            - `model_currently_not_support` : 現在のモデルは利用できません。
            - `completion_request_error` : Workflow execution request failed.
            - `invalid_param` : Invalid parameter value.
          content:
            application/json:
              examples:
                not_workflow_app:
                  summary: not_workflow_app
                  value:
                    status: 400
                    code: not_workflow_app
                    message: Please check if your app mode matches the right API route.
                provider_not_initialize:
                  summary: provider_not_initialize
                  value:
                    status: 400
                    code: provider_not_initialize
                    message: >-
                      No valid model provider credentials found. Please go to
                      Settings -> Model Provider to complete your provider
                      credentials.
                provider_quota_exceeded:
                  summary: provider_quota_exceeded
                  value:
                    status: 400
                    code: provider_quota_exceeded
                    message: >-
                      Your quota for Dify Hosted OpenAI has been exhausted.
                      Please go to Settings -> Model Provider to complete your
                      own provider credentials.
                model_currently_not_support:
                  summary: model_currently_not_support
                  value:
                    status: 400
                    code: model_currently_not_support
                    message: >-
                      Dify Hosted OpenAI trial currently not support the GPT-4
                      model.
                completion_request_error:
                  summary: completion_request_error
                  value:
                    status: 400
                    code: completion_request_error
                    message: Completion request failed.
                invalid_param:
                  summary: invalid_param
                  value:
                    status: 400
                    code: invalid_param
                    message: Arg user must be provided.
        '429':
          description: |-
            - `too_many_requests` : このアプリケーションへの同時リクエストが多すぎます。
            - `rate_limit_error` : アップストリームのモデルプロバイダーのレート制限を超えました。
          content:
            application/json:
              examples:
                too_many_requests:
                  summary: too_many_requests
                  value:
                    status: 429
                    code: too_many_requests
                    message: Too many requests. Please try again later.
                rate_limit_error:
                  summary: rate_limit_error
                  value:
                    status: 429
                    code: rate_limit_error
                    message: Rate Limit Error
        '500':
          description: '`internal_server_error` : 内部サーバーエラー。'
          content:
            application/json:
              examples:
                internal_server_error:
                  summary: internal_server_error
                  value:
                    status: 500
                    code: internal_server_error
                    message: Internal Server Error.
components:
  schemas:
    WorkflowExecutionRequest:
      type: object
      required:
        - inputs
        - user
      properties:
        inputs:
          type: object
          description: >-
            ワークフロー入力変数のキーと値のペアです。ファイル型変数の値は、`type`、`transfer_method`、および `url`
            または `upload_file_id`
            を持つファイルオブジェクトの配列である必要があります。アプリが期待する変数名と型については、[アプリケーションのパラメータ情報を取得](/api-reference/アプリケーション設定/アプリケーションのパラメータ情報を取得)
            レスポンスの `user_input_form` フィールドを参照してください。
          additionalProperties:
            oneOf:
              - type: string
              - type: number
              - type: boolean
              - type: object
              - type: array
                items:
                  $ref: '#/components/schemas/InputFileObject'
        response_mode:
          type: string
          enum:
            - streaming
            - blocking
          description: >-
            レスポンスモードです。同期レスポンスには `blocking`（Cloudflare タイムアウトは `100
            s`）、サーバー送信イベントには `streaming` を使用します。省略した場合、デフォルトはブロッキング動作になります。
        user:
          type: string
          description: >-
            開発者のルールで定義されるユーザー識別子で、アプリケーション内で一意である必要があります。この識別子はデータアクセスの範囲を限定します——ワークフロー実行とファイルは同じ
            `user` 値でクエリした場合にのみ表示されます。
        files:
          type: array
          items:
            $ref: '#/components/schemas/InputFileObject'
          nullable: true
          description: >-
            ファイルリストです。ファイルとテキストを組み合わせて入力する場合に適しており、モデルが Vision
            機能をサポートしている場合にのみ使用できます。ローカルファイルを添付するには、まず
            [ファイルをアップロード](/api-reference/ファイル操作/ファイルをアップロード) でアップロードし、返された `id`
            を `upload_file_id` として `transfer_method: local_file` で使用します。
    WorkflowBlockingResponse:
      type: object
      properties:
        task_id:
          type: string
          format: uuid
          description: >-
            進行中の実行のタスク ID です。[ワークフロータスクを停止](/api-reference/ワークフロー/ワークフロータスクを停止)
            と組み合わせて、実行中のワークフローをキャンセルします。実行中のみ有効です。
        workflow_run_id:
          type: string
          format: uuid
          description: >-
            このワークフロー実行記録の永続的な識別子です。[ワークフロー実行詳細を取得](/api-reference/ワークフロー/ワークフロー実行詳細を取得)
            と組み合わせて、実行後に結果を取得します。
        data:
          $ref: '#/components/schemas/WorkflowFinishedData'
    InputFileObject:
      type: object
      required:
        - type
        - transfer_method
      properties:
        type:
          type: string
          enum:
            - document
            - image
            - audio
            - video
            - custom
          description: ファイルタイプ。
        transfer_method:
          type: string
          enum:
            - remote_url
            - local_file
          description: 転送方法です。ファイル URL の場合は `remote_url`、アップロードファイルの場合は `local_file` です。
        url:
          type: string
          format: url
          description: ファイル URL（`transfer_method` が `remote_url` の場合）です。
        upload_file_id:
          type: string
          description: >-
            [ファイルをアップロード](/api-reference/ファイル操作/ファイルをアップロード) API
            から取得したアップロード済みファイル ID です（`transfer_method` が `local_file` の場合に使用）。
    WorkflowFinishedData:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ワークフロー実行 ID です。
        workflow_id:
          type: string
          format: uuid
          description: Workflow ID.
        status:
          type: string
          description: >-
            ワークフローの実行ステータスです。`running` は実行中、`succeeded` は正常完了、`failed`
            は実行エラー、`stopped` は手動停止、`partial-succeeded` は一部のノードが成功し他が失敗、`paused`
            は人間の入力待ちを示します。
        outputs:
          type: object
          additionalProperties: true
          nullable: true
          description: ワークフローからの出力データです。
        error:
          type: string
          nullable: true
          description: ワークフローが失敗した場合のエラーメッセージです。
        elapsed_time:
          type: number
          format: float
          description: 合計経過時間（秒）です。
        total_tokens:
          type: integer
          description: 全ノードで消費された合計トークン数です。
        total_steps:
          type: integer
          description: 実行されたワークフローの合計ステップ数です。
        created_at:
          type: integer
          format: int64
          description: ワークフロー実行が作成された Unix タイムスタンプです。
        finished_at:
          type: integer
          format: int64
          nullable: true
          description: ワークフロー実行が完了した Unix タイムスタンプです。
        created_by:
          type: object
          additionalProperties: true
          description: 作成者情報です。ストリーミングの `workflow_finished` イベントにのみ存在します。
        exceptions_count:
          type: integer
          nullable: true
          description: 実行中に発生した例外の数です。ストリーミングの `workflow_finished` イベントにのみ含まれます。
        files:
          type: array
          items:
            type: object
            additionalProperties: true
          nullable: true
          description: ワークフロー実行中に生成されたファイルです。ストリーミングの `workflow_finished` イベントにのみ存在します。
  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
        の漏洩は深刻な結果につながる可能性があります。**

````