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

# Cancel workflow runs

> Stop a workflow's active runs by concurrency key, or all of them.



## OpenAPI

````yaml api-reference/workflows/openapi.json POST /v1/workflows/{workflowId}/runs/cancel
openapi: 3.0.3
info:
  title: Persistence Workflows API
  version: '1.0'
  description: Start, inspect, cancel, and wake published event-to-call workflow runs.
servers:
  - url: https://api.persistence.dev
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Workflows
paths:
  /v1/workflows/{workflowId}/runs/cancel:
    post:
      tags:
        - Workflows
      summary: Cancel workflow runs
      description: >-
        Stop every active run for the given concurrency keys (1-500), or every
        active run when all is true.
      operationId: cancelWorkflowRuns
      parameters:
        - name: workflowId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelRunsRequest'
      responses:
        '200':
          description: Cancelled run ids
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelRunsEnvelope'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    CancelRunsRequest:
      type: object
      properties:
        concurrencyKeys:
          type: array
          minItems: 1
          maxItems: 500
          items:
            type: string
          description: >-
            Cancel active runs that share these keys. Mutually exclusive with
            all.
        all:
          type: boolean
          description: Cancel every active run for this workflow.
        reason:
          type: string
    CancelRunsEnvelope:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
          example: true
        data:
          $ref: '#/components/schemas/CancelRunsResult'
    CancelRunsResult:
      type: object
      required:
        - cancelled
      properties:
        cancelled:
          type: array
          items:
            type: string
    Error:
      type: object
      properties:
        code:
          type: string
        error:
          type: string
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Workspace API key with workflow run, and workflow read to check status.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.