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

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

> ID で指定された特定のワークフローバージョンを実行します。ワークフローの特定の公開バージョンを実行する場合に便利です。



## OpenAPI

````yaml /ja/api-reference/openapi_workflow.json post /workflows/{workflow_id}/run
openapi: 3.0.1
info:
  title: ワークフローアプリAPI
  description: ワークフローアプリケーションはセッションなしの動作をサポートし、翻訳、記事作成、要約 AI などに最適です。
  version: 1.0.0
servers:
  - url: '{api_base_url}'
    description: Workflow App API のベース URL です。{api_base_url} を実際の API ベース URL に置き換えてください。
    variables:
      api_base_url:
        default: https://api.dify.ai/v1
        description: API の実際のベース URL
security:
  - ApiKeyAuth: []
tags:
  - name: ワークフロー
    description: ワークフローの実行と管理のための操作です。
  - name: ファイル操作
    description: ファイルのアップロードとダウンロードの操作です。
  - name: エンドユーザー
    description: エンドユーザー情報に関連する操作です。
  - name: 音声・テキスト変換
    description: 音声からテキストおよびテキストから音声への変換です。
  - name: アプリケーション設定
    description: アプリケーションの設定、パラメータ、メタデータです。
paths:
  /workflows/{workflow_id}/run:
    post:
      tags:
        - ワークフロー
      summary: ID でワークフローを実行
      description: ID で指定された特定のワークフローバージョンを実行します。ワークフローの特定の公開バージョンを実行する場合に便利です。
      operationId: runWorkflowByIdJa
      parameters:
        - name: workflow_id
          in: path
          required: true
          description: >-
            実行する特定バージョンのワークフロー ID です。この値は
            [ワークフローを実行](/api-reference/ワークフロー/ワークフローを実行) のレスポンスおよび
            [ワークフロー実行詳細を取得](/api-reference/ワークフロー/ワークフロー実行詳細を取得) の `workflow_id`
            フィールドで返されます。
          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: >-
                  サーバー送信イベント (SSE) のストリームです。各イベントは `data: ` プレフィックス付きの JSON
                  オブジェクトで、2 つの改行で終了します。


                  **SSE パースガイド：**各イベントは `data: ` プレフィックス付きの JSON
                  オブジェクトの行で、`\n\n` で終了します。JSON をパースする前に `data: `
                  プレフィックスを除去してください。JSON 内の `event`
                  フィールドがイベントタイプを決定します。終了イベント（`message_end`、`workflow_finished`、`error`
                  など）を受信するとストリームは終了します。`ping` イベント（10
                  秒ごとに接続維持のために送信）は無視してください。ストリーム内でエラーイベントが発生しても HTTP ステータスコードは常に
                  `200` です。
        '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` : 有効なモデルプロバイダーの認証情報が見つかりません。
            - `provider_quota_exceeded` : モデルプロバイダーのクォータが使い切られました。
            - `model_currently_not_support` : 現在のモデルは利用できません。
            - `completion_request_error` : Workflow execution request failed.
            - `invalid_param` : Required parameter missing or invalid.
          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: Workflow is a draft and cannot be executed.
                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.
        '404':
          description: '`not_found` : ワークフローが見つかりません。'
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: Workflow not found.
        '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
        の漏洩は深刻な結果につながる可能性があります。**

````