> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# ID でワークフローを実行

> **対象アプリ**：Workflow。

特定の公開済みワークフローバージョンを、パスの `workflow_id` で指定して実行します。リクエストボディ、レスポンス、ストリーミングの挙動は [ワークフローを実行](/ja/3.11.x/develop/api/workflow-runs/run-workflow) と同じで、実行されるバージョンだけが異なります。



## OpenAPI

````yaml /ja/3.11.x/develop/api/openapi_service.json post /workflows/{workflow_id}/run
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.example.com/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:
  /workflows/{workflow_id}/run:
    post:
      tags:
        - ワークフロー実行
      summary: ID でワークフローを実行
      description: >-
        **対象アプリ**：Workflow。


        特定の公開済みワークフローバージョンを、パスの `workflow_id`
        で指定して実行します。リクエストボディ、レスポンス、ストリーミングの挙動は
        [ワークフローを実行](/ja/3.11.x/develop/api/workflow-runs/run-workflow)
        と同じで、実行されるバージョンだけが異なります。
      operationId: runWorkflowByIdJa
      parameters:
        - name: workflow_id
          in: path
          required: true
          description: >-
            実行する公開済みワークフローバージョンです。[ワークフローを実行](/ja/3.11.x/develop/api/workflow-runs/run-workflow)
            のレスポンスおよび
            [ワークフロー実行詳細を取得](/ja/3.11.x/develop/api/workflow-runs/get-workflow-run-detail)
            の `workflow_id` フィールドで返されます。公開済みバージョンを指定する必要があります。ドラフトバージョンの ID は
            `bad_request` で拒否されます。
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowExecutionRequest'
            examples:
              example:
                summary: リクエスト例
                value:
                  inputs:
                    query: Summarize this article
                  response_mode: blocking
                  user: user_workflow_123
      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: Article summary here
                      error: null
                      elapsed_time: 2.45
                      total_tokens: 280
                      total_steps: 4
                      created_at: 1705407629
                      finished_at: 1705407631
            text/event-stream:
              schema:
                type: string
                description: >-
                  Server-Sent Events (SSE) のストリームです。解析は
                  [ストリーミングレスポンスの処理](/ja/3.11.x/develop/api/guides/streaming)
                  に従ってください：`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` は `null` となり、`conversation_id` は含まれません。並行する
                  `text_chunk` ストリームには `<think>` タグが含まれません。


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

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

                  - `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.
            - `bad_request` : Workflow is a draft or has an invalid ID format.
            - `provider_not_initialize` : 有効なモデルプロバイダーの認証情報が見つかりません。
            - `completion_request_error` : Workflow execution request failed.
            - `invalid_param` : リクエストパラメータが不足または無効です（`user` の欠落など）。
          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.
                bad_request:
                  summary: bad_request
                  value:
                    status: 400
                    code: bad_request
                    message: >-
                      Cannot use draft workflow version. Workflow ID:
                      7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345. Please use a
                      published workflow version or leave workflow_id empty.
                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.
                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.
        '404':
          description: '`not_found` : ワークフローが見つかりません。'
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: >-
                      Workflow not found with id:
                      7c3e33d4-2a8b-4e5f-9b1a-d3c6e8f12345
        '429':
          description: '- `too_many_requests` : このアプリケーションへの同時リクエストが多すぎます。'
          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.
        '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: >-
            ワークフロー入力変数のキーと値のペアです。アプリが期待する変数名と型は、[アプリケーションのパラメータ情報を取得](/ja/3.11.x/develop/api/applications/get-app-parameters)
            の `user_input_form` フィールドで確認できます。


            ファイル型の変数には、`type`、`transfer_method`、および `url` または `upload_file_id`
            を持つファイルオブジェクトの配列を渡します。
          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`
            を持つ後続のリクエストにのみ表示されます。[エンドユーザーの識別](/ja/3.11.x/develop/api/guides/end-user-identity)
            を参照してください。
        files:
          type: array
          items:
            $ref: '#/components/schemas/InputFileObject'
          nullable: true
          description: >-
            ファイルリストです。ファイルとテキストを組み合わせて入力する場合に適しており、モデルが Vision
            機能をサポートしている場合にのみ使用できます。ローカルファイルを添付するには、まず
            [ファイルをアップロード](/ja/3.11.x/develop/api/files/upload-file)
            でアップロードし、返された `id` を `upload_file_id` として `transfer_method:
            local_file` で使用します。
    WorkflowBlockingResponse:
      type: object
      properties:
        task_id:
          type: string
          format: uuid
          description: >-
            進行中の実行のタスク ID
            です。[ワークフロータスクを停止](/ja/3.11.x/develop/api/workflow-runs/stop-workflow-task)
            と組み合わせて、実行中のワークフローをキャンセルします。実行中のみ有効です。
        workflow_run_id:
          type: string
          format: uuid
          description: >-
            このワークフロー実行記録の永続的な識別子です。[ワークフロー実行詳細を取得](/ja/3.11.x/develop/api/workflow-runs/get-workflow-run-detail)
            と組み合わせて、実行後に結果を取得します。
        data:
          $ref: '#/components/schemas/WorkflowFinishedData'
    InputFileObject:
      type: object
      required:
        - type
        - transfer_method
      properties:
        type:
          type: string
          enum:
            - image
            - document
            - 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: >-
            事前に [ファイルをアップロード](/ja/3.11.x/develop/api/files/upload-file) API
            でアップロードして取得したファイル ID です（`transfer_method` が `local_file` の場合に使用）。
      anyOf:
        - properties:
            transfer_method:
              enum:
                - remote_url
            url:
              type: string
              format: url
          required:
            - url
          not:
            required:
              - upload_file_id
        - properties:
            transfer_method:
              enum:
                - local_file
            upload_file_id:
              type: string
          required:
            - upload_file_id
          not:
            required:
              - url
    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 キーで認証します：`Authorization: Bearer
        {API_KEY}`。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API
        キーを使用します（[Dify API
        クイックスタート](/ja/3.11.x/develop/api/guides/get-started)）。


        キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP
        `401`（`unauthorized`）で失敗します。

````