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

# 停止工作流任务

> 停止正在运行的工作流任务。仅在 `streaming` 模式下支持。



## OpenAPI

````yaml /zh/api-reference/openapi_workflow.json post /workflows/tasks/{task_id}/stop
openapi: 3.0.1
info:
  title: 工作流应用 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:
  /workflows/tasks/{task_id}/stop:
    post:
      tags:
        - 工作流
      summary: 停止工作流任务
      description: 停止正在运行的工作流任务。仅在 `streaming` 模式下支持。
      operationId: stopWorkflowTaskGenerationCn
      parameters:
        - name: task_id
          in: path
          required: true
          description: 任务 ID，可以从 [执行工作流](/api-reference/工作流/执行工作流) API 的流式分块返回中获取。
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - user
              properties:
                user:
                  type: string
                  description: 用户标识符，必须与 [执行工作流](/api-reference/工作流/执行工作流) 请求中传递的用户一致。
            examples:
              example:
                summary: 请求示例
                value:
                  user: user_workflow_123
      responses:
        '200':
          $ref: '#/components/responses/SuccessResult'
        '400':
          description: |-
            - `not_workflow_app` : 应用模式与 API 路由不匹配。
            - `invalid_param` : 必要参数缺失或无效。
          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.
                invalid_param:
                  summary: invalid_param
                  value:
                    status: 400
                    code: invalid_param
                    message: Arg user must be provided.
components:
  responses:
    SuccessResult:
      description: 操作成功。
      content:
        application/json:
          schema:
            type: object
            properties:
              result:
                type: string
                enum:
                  - success
                description: 操作结果。
          examples:
            success:
              summary: 响应示例
              value:
                result: success
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key 认证。对于所有 API 请求，请在 `Authorization` HTTP 头中包含您的 API Key，并加上
        `Bearer ` 前缀。示例：`Authorization: Bearer {API_KEY}`。**强烈建议将 API Key
        存储在服务端，不要在客户端共享或存储，以避免 API Key 泄漏导致严重后果。**

````