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

# Stop Workflow Task

> **Available for**: Workflow

Stops a running task.

Stopping is idempotent and tells you nothing about the task: stopping a task that has already finished, that does not exist, or that belongs to another API key also returns `{"result": "success"}`, without stopping anything.

**Standard API equivalent**: [Stop Workflow Task](/en/3.13.x/develop/api/workflow-runs/stop-workflow-task). The contract is the same; only authentication and availability errors differ.



## OpenAPI

````yaml /en/3.13.x/develop/api/openapi_service.json post /v2/workflows/tasks/{task_id}/stop
openapi: 3.0.1
info:
  title: Dify Service API
  description: >-
    REST API for Dify applications and knowledge bases. Application endpoints
    authenticate with an app API key; knowledge endpoints authenticate with a
    dataset API key.
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: >-
      Base URL of the Dify Service API. Replace it with your deployment's API
      endpoint.
    variables:
      api_base_url:
        default: api.example.com/v1
        description: Host and path of the API base URL, without the `https://` prefix.
security:
  - ApiKeyAuth: []
tags:
  - name: Chat Messages
    description: Operations related to chat messages and interactions.
  - name: Files
    description: File upload and preview operations.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: User feedback operations.
  - name: Conversations
    description: Operations related to managing conversations.
  - name: Audio
    description: Text-to-Speech and Speech-to-Text operations.
  - name: Applications
    description: Operations to retrieve application settings and information.
  - name: Annotations
    description: Operations related to managing annotations for direct replies.
  - name: Human Input
    description: Endpoints for resuming paused workflows that require human input.
  - name: Workflow Runs
    description: Operations for executing and managing workflows.
  - name: Completion Messages
    description: Operations related to text generation and completion.
  - name: Knowledge Bases
    description: >-
      Operations for managing knowledge bases, including creation,
      configuration, and retrieval.
  - name: Documents
    description: >-
      Operations for creating, updating, and managing documents within a
      knowledge base.
  - name: Chunks
    description: Operations for managing document chunks and child chunks.
  - name: Metadata
    description: >-
      Operations for managing knowledge base metadata fields and document
      metadata values.
  - name: Tags
    description: Operations for managing knowledge base tags and tag bindings.
  - name: Models
    description: Operations for retrieving available models.
  - name: Knowledge Pipeline
    description: >-
      Operations for managing and running knowledge pipelines, including
      datasource plugins and pipeline execution.
  - name: Deployed Environments
    description: >-
      Endpoints served by deployed environments over the `v2` base URL. Deployed
      environments serve only the endpoints in this group; calling any other
      path there returns `404 not_found`. Authentication and errors differ from
      the standard Service API; each page here is authoritative for deployed
      environments.
paths:
  /v2/workflows/tasks/{task_id}/stop:
    post:
      tags:
        - Deployed Environments
      summary: Stop Workflow Task
      description: >-
        **Available for**: Workflow


        Stops a running task.


        Stopping is idempotent and tells you nothing about the task: stopping a
        task that has already finished, that does not exist, or that belongs to
        another API key also returns `{"result": "success"}`, without stopping
        anything.


        **Standard API equivalent**: [Stop Workflow
        Task](/en/3.13.x/develop/api/workflow-runs/stop-workflow-task). The
        contract is the same; only authentication and availability errors
        differ.
      operationId: stopDeployedWorkflowTask
      parameters:
        - name: task_id
          in: path
          required: true
          description: >-
            Task ID, from the response or the streaming events of [Run
            Workflow](/en/3.13.x/develop/api/deployed-environments/run-workflow).
          schema:
            type: string
            format: uuid
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                user:
                  type: string
                  description: >-
                    End-user identifier, defined by your app and unique within
                    it. Accepted for compatibility; the stop is authorized by
                    the API key and task alone. See [End User
                    Identity](/en/3.13.x/develop/api/guides/end-user-identity).
            examples:
              example:
                summary: Request Example
                value:
                  user: user_workflow_123
      responses:
        '200':
          description: The stop was accepted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    description: Always `success`.
              examples:
                ok:
                  summary: Response Example
                  value:
                    result: success
        '400':
          description: >-
            `invalid_request`: the stop request does not match the deployment's
            workspace, app, or environment. Ask your administrator to check the
            deployment routing.
          content:
            application/json:
              examples:
                invalid_request:
                  summary: invalid_request
                  value:
                    code: invalid_request
                    message: runtime route identity does not match task identity
                    status: 400
        '401':
          description: >-
            - `token_invalid`: the API key is missing, malformed, or unknown.

            - `unauthorized`: the API key has been revoked.

            - `runtime_identity_invalid`: the request's signed identity does not
            match the task; send the request again.
          content:
            application/json:
              examples:
                token_invalid:
                  summary: token_invalid
                  value:
                    code: token_invalid
                    message: invalid api token
                    status: 401
                unauthorized:
                  summary: unauthorized
                  value:
                    code: unauthorized
                    message: Access token is invalid
                    status: 401
                runtime_identity_invalid:
                  summary: runtime_identity_invalid
                  value:
                    code: runtime_identity_invalid
                    message: runtime identity is invalid
                    status: 401
        '403':
          description: '`forbidden`: the app''s API access is turned off in **Access Point**.'
          content:
            application/json:
              examples:
                forbidden:
                  summary: forbidden
                  value:
                    code: forbidden
                    message: The app's API service has been disabled.
                    status: 403
        '404':
          description: '`not_found`: `task_id` is not a canonical lowercase UUID.'
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    code: not_found
                    message: unsupported appdeploy service api endpoint
                    status: 404
        '503':
          description: >-
            - `deployment_undeployed`: the app is undeployed from this
            environment.

            - `deployment_not_ready`: a deployment is in progress; retry
            shortly.

            - `apprunner_not_deployed`: the environment is not available, for
            example while it is being deleted.

            - `enterprise_unavailable`: a platform-side routing service is
            temporarily unavailable; retry shortly.

            - `service_not_ready`: the environment couldn't apply the stop, for
            example because the task's version is no longer deployed there;
            retry shortly.
          content:
            application/json:
              examples:
                deployment_undeployed:
                  summary: deployment_undeployed
                  value:
                    code: deployment_undeployed
                    message: deployment is not deployed
                    status: 503
                deployment_not_ready:
                  summary: deployment_not_ready
                  value:
                    code: deployment_not_ready
                    message: deployment is in progress
                    status: 503
                apprunner_not_deployed:
                  summary: apprunner_not_deployed
                  value:
                    code: apprunner_not_deployed
                    message: apprunner not deployed for this environment
                    status: 503
                enterprise_unavailable:
                  summary: enterprise_unavailable
                  value:
                    code: enterprise_unavailable
                    message: enterprise routing service unavailable
                    status: 503
                service_not_ready:
                  summary: service_not_ready
                  value:
                    code: service_not_ready
                    message: task revision is not assigned to this runner
                    status: 503
      servers:
        - url: https://{deployed_api_base_url}
          description: >-
            Base URL shared by every deployed environment: the standard Service
            API address, with `/v2` in place of `/v1`.
          variables:
            deployed_api_base_url:
              default: api.example.com
              description: >-
                On the app's **Access Point** tab, copy the full URL from any
                deployed environment's **Backend Service API** card, then remove
                the `https://` prefix and the trailing `/v2`.
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        Every request authenticates with an API key: `Authorization: Bearer
        {API_KEY}`. App endpoints take an app API key; knowledge endpoints take
        a knowledge base API key ([Get
        Started](/en/3.13.x/develop/api/guides/get-started)).


        Keep keys server-side; never embed them in client code. Requests with a
        missing or invalid key fail with HTTP `401` (`unauthorized`).

````